summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--quine.asm33
1 files changed, 11 insertions, 22 deletions
diff --git a/quine.asm b/quine.asm
index 467613a..f38f3c4 100644
--- a/quine.asm
+++ b/quine.asm
@@ -1,7 +1,12 @@
 ; fasmg hello.asm hello && chmod 755 hello && ./hello; echo $?
 ;
+; ***WARNING*** this version leaves the error message scrolled off the top of
+; the screen and you see stale output
 ; fasmg quine.asm quine && ./quine > quine2; echo "exit code:" $?; echo; hexdump -C quine; echo; hexdump -C quine2; cmp quine quine2; echo; echo "compare:" $?
 ; ZydisDisasm -64 quine
+;
+; rm quine2; fasmg quine.asm quine && ./quine > quine2; echo "exit code:" $?; echo; hexdump -C quine; echo; hexdump -C quine2; echo; cmp quine quine2 ; echo $?
+
 
 
 macro rex.0
@@ -197,28 +202,12 @@ end macro
 ; This uses opcode 0x89.
 macro mov.rel.q target, offset, source
   match =rsp, target
-    match =rax, source
-      rex.w
-      db 0x89
-      modrm 1, 0, 4
-      sib 0, 4, 4
-      db offset
-    else match =rdx, source
-      ;mov.rel.q rsp, 0x60, rdx                 ; size in file
-      ; todo doesn't work yet
-      rex.w
-      db 0x89
-      ;0x44 0100 0100
-      ;     01 000 100
-      ;0x54 0101 0100
-      ;     01 010 100
-      
-      modrm 1, 2, 4 ; <- changing this reg value should do it, but...
-      sib 0, 4, 4
-      db offset
-    else
-      assert 0
-    end match
+    qwordreg sreg, source
+    rex.w
+    db 0x89
+    modrm 1, sreg, 4
+    sib 0, 4, 4
+    db offset
   else
     assert 0
   end match