-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
823146e
commit fa808f9
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |