From 311c4bd6ba2a5e9e38eb4f2ad6b3866df05c11de Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Thu, 30 Oct 2025 01:37:12 -0700 Subject: clean up the first two instruction macros ever written they had some minor confusing stuff going on; now they don't Force-Push: yes Change-Id: Ie3756cf18222cb8b3f4794f57d91cb5229be715e --- quine.asm | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'quine.asm') diff --git a/quine.asm b/quine.asm index 64f55d3..dc7eb51 100644 --- a/quine.asm +++ b/quine.asm @@ -369,26 +369,18 @@ end macro ;;; ------------ -; TODO what register size does this use? -macro mov.b target, source - match =rax?, target - db 0xB8 - dd source - else match =rdi?, target - db 0xBF - dd source - else - assert 0 - end match +macro mov.dreg.dimm target, source + dwordreg treg, target + opcodereg 0xB8, treg + dd source end macro -; TODO what register size does this use? -macro mov.dreg.dimm target, source +macro mov.qreg.dimm target, source + qwordreg treg, target rex.w db 0xC7 - qwordreg reg, target - modrm 3, 0, reg + modrm 3, 0, treg dd source end macro @@ -1723,7 +1715,7 @@ _start: ;;; and the kernel would trust us, but this gives us more options for ;;; interoperating with other runtimes. ;;; - mov.b rax, 9 ; mmap() + mov.qreg.qimm rax, 9 ; mmap() mov.qreg.qimm rdi, heap_requested_address ; address (very arbitrary) mov.qreg.qimm rsi, heap_size ; size (one meg) mov.qreg.qimm rdx, 0x03 ; protection (read+write) @@ -2509,8 +2501,8 @@ defword QUIT, 0 defword SYS_EXIT, 0 dq $ + 0x8 ; codeword - mov.b rax, 60 ; syscall number - mov.b rdi, 0 ; exit code + mov.qreg.qimm rax, 60 ; syscall number + mov.qreg.qimm rdi, 0 ; exit code syscall ; In the event we're still here, let's minimize confusion. @@ -2532,7 +2524,7 @@ defword SYS_WRITE, 0 pop.qreg rcx ; address from stack pop.qreg rdx ; length from stack, passed directly push.qreg rsi ; save rsi - mov.b rax, 1 ; syscall number + mov.qreg.qimm rax, 1 ; syscall number mov.qreg.qimm rdi, 1 ; file descriptor mov.qreg.qreg rsi, rcx ; pass address syscall -- cgit 1.4.1