TEST.s
authoryu.dongliang <18588496441@163.com>
Fri, 26 Dec 2025 16:14:20 +0000 (00:14 +0800)
committeryu.dongliang <18588496441@163.com>
Fri, 26 Dec 2025 16:14:20 +0000 (00:14 +0800)
TEST.s [new file with mode: 0644]
inst.s

diff --git a/TEST.s b/TEST.s
new file mode 100644 (file)
index 0000000..7e805d4
--- /dev/null
+++ b/TEST.s
@@ -0,0 +1,6 @@
+.text
+.global test
+
+test:
+       mov %eax,%ebx
+       ret
diff --git a/inst.s b/inst.s
index 82417d20a9301aab18ff5ec075ccc92962a3c6cf..48472f59854b24f379f6c7dc59e88cd71949190c 100644 (file)
--- a/inst.s
+++ b/inst.s
@@ -38,24 +38,29 @@ asm_make_inst:
        call asm_find_opcode
        movq %rax, v_op
 
-       leaq fmt, %rdi
-       movb 10(%rax), %al
-       movzbq %al, %rsi
-       xorq  %rax, %rax
-       call  printf
+#ModRM = 0x3 = mode register
+       movq $0x3, %rsi
+       shlq $6, %rsi
 
-       leaq fmt, %rdi
        movq v_src, %rax
        movb 8(%rax), %al
-       movzbq %al, %rsi
-       xorq  %rax, %rax
-       call  printf
+       movzbq %al, %rax
+       shlq $3, %rax
+       orq  %rax, %rsi
 
-       leaq fmt, %rdi
        movq v_dst, %rax
        movb 8(%rax), %al
-       movzbq %al, %rsi
+       movzbq %al, %rax
+       orq  %rax, %rsi
+
+       shlq $8, %rsi
+       movq v_op, %rax
+       movb 10(%rax), %al
+       movzbq %al, %rax
+       orq  %rax, %rsi
+
        xorq  %rax, %rax
+       leaq fmt, %rdi
        call  printf
 
        pop  %rbp