-
macOS M1 pro assembly tutorial ❤️코딩Coding/한글Rust강의★내가★공부하려고만듬 2022. 6. 30. 18:42728x90
ARM64 M1 macbook기준
https://github.com/below/HelloSiliconas first.asm -o hello.o
.o 파일 만들로 ld로 만들면 나옴
https://smist08.wordpress.com/2021/01/08/apple-m1-assembly-language-hello-world/
macos M1 assembly compile 힌트
https://www.reddit.com/r/asm/comments/m8rsjt/apple_m1_assembly_helloworld_fails_to_compile_can/
https://stackoverflow.com/questions/69974380/how-to-compile-arm-assembly-on-an-m1-macbook
as
말고 다른 방법을 assembly코드를 캄파일 하는 방법 해보자
https://smist08.wordpress.com/2021/01/08/apple-m1-assembly-language-hello-world/
Learning ARM64 Assembly. Need help!
**--SOLVED--**
Hi everyone!
I've just started learning Assembly on my M1 Mac and I was suggested to use [this github repo](https://github.com/below/HelloSilicon) as a reference.
I succeeded in printing out a string, and now I'm trying to figure out how to sum two values and output the result.I came up with this code:.global _start .align 2 _start: mov X3, #0x2 mov X4, #0x5 add X5, X3, X4 //put X3+X4 in X5 //print mov X0, #1 //stdout add X1, X5, #0x30 //add '0' to X5 and put result in X1 mov X2, #1 //string size is 1 mov X16, #4 //write system call svc #0x80 //end mov X0, #0 mov X16, #1 //exit system call svc #0x80
.global _start
.align 2
_start:
mov X3, #0x2
mov X4, #0x5
add X5, X3, X4 //put X3+X4 in X5
//print
mov X0, #1 //stdout
add X1, X5, #0x30 //add '0' to X5 and put result in X1
mov X2, #1 //string size is 1
mov X16, #4 //write system call
svc #0x80
//end
mov X0, #0
mov X16, #1 //exit system call
svc #0x80
What I'm trying to do here is to:
1. put arbitrary values into X3 and X4 registers
2. sum those two values and put the result in the X5 register
3. convert X5's value into ASCII by adding 0x30 (or '0')
4. use stdout to print the 1 character long string
But, unfortunately, it doesn't work: it executes correctly but doesn't output anything. What am I doing wrong here? Any clarification is highly appreciated!
Thank you so much! :)
\----------
ps: this is the makefile I'm using:
addexmp: addexmp.o
ld -o addexmp addexmp.o -lSystem -syslibroot `xcrun -sdk macosx --show-sdk-path` -e _start -arch arm64
addexmp.o: addexmp.s
as -arch arm64 -o addexmp.o addexmp.s
I'm executing it from terminal using "make" command and then "./addexmp".
​
**-- SOLUTION --**
Following the advice provided by u/TNorthover, I stored the char in the stack with
str X5, [SP, #0x0]
and then used SP as the parameter for the X1 register.
i시리즈 계열
intel cpu
an asssembler for the x86 CPU architecture portable to nearly every modern platform,
https://www.nasm.us/
x86만 ㅜㅜ
https://medium.com/@thisura1998/hello-world-assembly-program-on-macos-mojave-d5d65f0ce7c6
mac M1 컴파일 가능한거 찾아보자 ㅜㅜ
Assembly Language Programming with ARM
https://youtu.be/gfmRrPjnEw4
내가 공부하려고 정리
한글강의Assembly언어001(Arm64)_ld_as_C언어_Assembly언어로 변환 #assembly
https://youtu.be/9yt1Enp4EwU
반응형'코딩Coding > 한글Rust강의★내가★공부하려고만듬' 카테고리의 다른 글
Rust❤️ tsoding / Rust - doubly-linked-list (0) 2022.07.04 C# on Linux❤️ — Advent of Code 2020 Day 13 - Tsoding Daily (0) 2022.07.03 Pointers in C/C++❤️ (0) 2022.07.03 C++❤️]3D Graphics Engine #1 - Triangles & Projection (0) 2022.07.03 zig❤️ ray tracer in Zig동영상 만들 예정 (0) 2022.06.30 fractal 모형 2가지 julia-sets & mandelbrot-set (0) 2022.06.29 Rust Mandelbrot-set❤️동영상 만들 예정 (0) 2022.06.29 Mandelbrot-set ❤️모아 놓은 GitHub (0) 2022.06.29