diff options
author | Nicholas Tay <nick@windblume.net> | 2023-10-23 21:34:30 +1100 |
---|---|---|
committer | Nicholas Tay <nick@windblume.net> | 2023-10-23 21:36:14 +1100 |
commit | cd646947074a1793d2d9d7ba556853f92be0bab2 (patch) | |
tree | 6893288dff3b161c0de2db8be4ab7d786123d4d7 /pasmgen-linux.asm | |
parent | 28dfc3448c1eb127834d26b308a0b2e985be79c8 (diff) | |
download | pasmgen-cd646947074a1793d2d9d7ba556853f92be0bab2.tar.gz pasmgen-cd646947074a1793d2d9d7ba556853f92be0bab2.tar.bz2 pasmgen-cd646947074a1793d2d9d7ba556853f92be0bab2.zip |
Factor non-linux parts out
Diffstat (limited to 'pasmgen-linux.asm')
-rw-r--r-- | pasmgen-linux.asm | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/pasmgen-linux.asm b/pasmgen-linux.asm new file mode 100644 index 0000000..56113e6 --- /dev/null +++ b/pasmgen-linux.asm @@ -0,0 +1,75 @@ +format ELF64 executable + +segment readable executable + +main: + ;; No arg preload case + cmp [rsp], word 1 + jne argparse + + mov r8, qword 3 + mov r9, qword 2 + mov r10, qword 3 + + jmp generate + +argparse: + ;; Check args (need 3) + cmp [rsp], word 3 + jle fail + + ;; load arg1 + mov r8, [rsp+16] + mov r8, [r8] + and r8, 0xFF + sub r8, 48 + + ;; load arg2 + mov r9, [rsp+24] + mov r9, [r9] + and r9, 0xFF + sub r9, 48 + + ;; load arg3 + mov r10, [rsp+32] + mov r10, [r10] + and r10, 0xFF + sub r10, 48 + + jmp generate + +ok: + ;; Write + mov rdi, 1 ;; stdout + mov rdx, rsi + mov rsi, out_buf + mov rax, 0x01 + syscall + + ;; Exit (code 0) + mov rdi, 0 + mov rax, 0x3c + syscall + +fail: + ;; Write + mov rdi, 1 ;; stdout + mov rsi, usage + mov rdx, usage_len + mov rax, 0x01 + syscall + + ;; Exit 1 + mov rdi, 1 + mov rax, 0x3c + syscall + + +include 'pasmgen.inc' + + +segment readable writeable + +include 'constants.inc' + +out_buf rb 64 |