summary refs log tree commit diff
path: root/quine.asm
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2025-10-30 01:37:12 -0700
committerIrene Knapp <ireneista@irenes.space>2025-10-30 01:37:12 -0700
commit311c4bd6ba2a5e9e38eb4f2ad6b3866df05c11de (patch)
tree616aa38a2d5cbd5365a3804c6e0424e015de2936 /quine.asm
parent7207d6ef21d53a8f5805e3de755d9982c6bdee2e (diff)
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
Diffstat (limited to 'quine.asm')
-rw-r--r--quine.asm30
1 files changed, 11 insertions, 19 deletions
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