about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--historical/asm-notes.txt88
1 files changed, 88 insertions, 0 deletions
diff --git a/historical/asm-notes.txt b/historical/asm-notes.txt
new file mode 100644
index 0000000..100c681
--- /dev/null
+++ b/historical/asm-notes.txt
@@ -0,0 +1,88 @@
+  This was a very early file, working notes that were part of bringing up the
+earliest drafts of the flatassembler version of Evocation. It's here in case
+it's of historical interest.
+
+
+HLT will drop you into the debugger
+  db 0xf4       ; HLT DO NOT SUBMIT
+
+or perhaps you want to do a clean exit()
+  mov.b rax, 60 ; DO NOT SUBMIT
+  mov.b rdi, 0  ; DO NOT SUBMIT
+  syscall       ; DO NOT SUBMIT
+
+
+    ; opcode c7 is Ev, Iz. c6 is Eb, Ib
+    ; Eb: ModR/M to follow, byte
+    ; consider 1100 011w : 11 000 reg : imm
+    ; also consider 1011 w reg : imm for bytes
+
+32-bit target, 8-bit source
+  match =eax?, target
+    db 0xB8
+    dd source
+  else match =edi?, target
+    db 0xBF
+    dd source
+
+64-bit target, 32-bit source
+  match =rax?, target            ; mov rax, 0x1234
+    db 0x48, 0xC7, 0xC0
+    dd source
+;   48                           eAX REX.W prefix
+;                                    (DEC is the 32-bit meaning, ignore it)
+;                                    eAX -> register identifier,
+;                                           width depends on operand
+;                                    REX.W -> set 64-bit operand mode
+;           c7                    Grp 11^1A - MOV Ev, Iz
+;                                    immediate to register
+;                                    1A -> bits 5,4,3 of ModR/M are opcode
+;                                          extension
+;                                    E -> modR/M byte to follow for operand
+;                                    v -> word of appropriate size
+;                                    I -> immediate data
+;                                    z -> 32-bit operand
+;              c0                ModR/M byte
+;              0b11000000
+;                11               mod: always 11
+;                  000            op/reg: Mov Ev, Iz
+;                     00x         w absent
+;                       0         w (ignored)
+
+
+
+  match =rdi, target             ; mov rdi, 0x1234
+    db 0x48, 0xC7, 0xC7
+    dd source
+;   7:   48 c7 c7 2a 00 00 00    mov    $0x2a,%rdi
+;   48                           eAX REX.W prefix
+;                                    (DEC is the 32-bit meaning, ignore it)
+;           c7                   Grp 11^1A - MOV Ev, Iz
+;                                    immediate to register
+;                                    1A -> bits 5,4,3 of ModR/M are opcode
+;                                          extension
+;                                    Ev -> ModR/M to follow for 32-bit operand
+;                                    Iz -> Immediate data, 32-bits
+;              c7                ModR/M byte
+;              0b11000111
+;                11               mod: always 11
+;                  000            op/reg: Mov Ev, Iz
+;                     11x         w present
+;                       1         w true; use EDI
+
+
+
+64-bit target, 64-bi source
+
+  match =rdi, target             ; mov rdi, 0x1234
+    db 0x48, 0xB8, 0x38
+    dq source
+
+  match =rsi, target
+    db 0x48, 0xB8, 0x30
+    dq source
+    ; opcode c7 is Ev, Iz. c6 is Eb, Ib
+    ; Eb: ModR/M to follow, byte
+    ; consider 1100 011w : 11 000 reg : imm
+    ; also consider 1011 w reg : imm for bytes
+