diff options
author | Paul Duncan <pabs@pablotron.org> | 2024-07-24 22:39:59 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2024-07-24 22:39:59 -0400 |
commit | b328a92f0e3c648bad7ef47a98f1db75e545789a (patch) | |
tree | ed6d37508d13cf3296f8ad57dc7214b0697e979d /hi.s | |
download | alonzo-sucks-arm64-main.tar.bz2 alonzo-sucks-arm64-main.zip |
Diffstat (limited to 'hi.s')
-rw-r--r-- | hi.s | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -0,0 +1,31 @@ +// hi.s: print "alonzo sucks!" to standard output and then exit. +// +// uses write() and exit() linux system calls directly to elide libc and +// assembles to a static, 384 byte arm64 binary. + +// entry point +// +// uses 32-bit registers (wN) instead of 64-bit registers (xN) to +// save a few bytes in the assembled binary +.text +.global _start +_start: + // write(stdout, msg, len) + mov w0, #1 // stdout fd (1) + ldr w1, =msg // message + mov w2, len // message length + mov w8, #64 // write() (64) + svc #0 // call write() + + // exit(0) + mov w0, #0 // exit code (0) + mov w8, #93 // exit() (93) + svc #0 // call exit() + +// message and message length +// +// technically the message belongs in the .rodata section, but sticking +// it here allows it to be packed after _start and the saves ~60 bytes +// in the assembled binary +msg: .ascii "alonzo sucks!\n" // message (14 bytes) +len = . - msg // message length |