Skip to content

Commit

Permalink
add arm assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
Tantatorn-dev committed Oct 3, 2021
1 parent 823146e commit fa808f9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Assembly(ARM)/Tantatorn-dev/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
coffee: coffee.o
ld -macosx_version_min 11.0.0 -o coffee coffee.o -lSystem -syslibroot `xcrun -sdk macosx --show-sdk-path` -e _start -arch arm64

coffee.o: coffee.s
as -o coffee.o coffee.s

clean:
rm coffee.o
30 changes: 30 additions & 0 deletions Assembly(ARM)/Tantatorn-dev/coffee.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Assembler program to convert coffee to code
// to stdout.
//
//
.global _start // Provide program starting address to linker
.align 2

// Setup the parameters

_start: mov x3, #0
adr x1, coffee // store coffee in a register
adr x1, code // replace coffee with code

// print out the result
mov x0, #1 // 1 = StdOut
mov x2, #6 // length of our string
mov X16, #4 // MacOS write system call
svc 0 // Call to output the string
cmp x3, #9 //
add x3, x3, #1 //

// Setup the parameters to exit the program

mov X0, #0 // Use 0 return code
mov X16, #1 // Service command code 1 terminates this program
svc 0 // Call MacOS to terminate the program

coffee: .ascii "Coffee\n"
code: .ascii "Code\n"

0 comments on commit fa808f9

Please sign in to comment.