From 8b0e4759beaa550f7b1d19a44cf86a9ae04268f7 Mon Sep 17 00:00:00 2001 From: andromeda Date: Mon, 23 Mar 2026 23:54:27 +0100 Subject: [PATCH] update example in readme --- twasm/README.md | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/twasm/README.md b/twasm/README.md index 3b63414..dfb198d 100644 --- a/twasm/README.md +++ b/twasm/README.md @@ -340,8 +340,10 @@ this program doesn't do anything useful, it's just a test ```nasm xor eax, eax -inc rax -mov [ rax ], rdx +inc rax ; inline comment +; one line comment +mov rdx, [rax] +mov [rax], rdx hlt ``` @@ -350,30 +352,19 @@ hlt ```nasm 0x0053 ; xor -0xFE20 ; space 0x0010 ; eax -0xFE2C ; comma -0xFE20 ; space 0x0010 ; eax -0xFE0A ; newline 0x0054 ; inc -0xFE20 ; space 0x0000 ; rax -0xFE0A ; newline 0x0056 ; mov -0xFE20 ; space -0x1004 ; open bracket (4) -0xFE20 ; space |1 -0x0000 ; rax |2 -0xFE20 ; space |3 -0x0052 ; close bracket |4 -0xFE2C ; comma -0xFE20 ; space 0x0003 ; rdx -0xFE0A ; newline +0x1000 ; memory address: register +0x0000 ; rax +0x0056 ; mov +0x1000 ; memory address: register +0x0000 ; rax +0x0003 ; rdx 0x004F ; hlt -0xFE0A ; newline -0xFE00 ; null terminator ``` #### nasm output with the above example program, bits 64 @@ -393,6 +384,13 @@ hlt ; reg 000b ; RAX ; r/m 000b ; RAX +0x48 ; 64 Bit Operand Size prefix +0x8B ; MOV r16/32/64 r/m16/32/64 +0x10 ; ModR/M byte + ; mod 00b ; indirect addressing, no displacement + ; reg 010b ; RDX + ; r/m 000b ; [RAX] + 0x48 ; 64 Bit Operand Size prefix 0x89 ; MOV r/m16/32/64 r16/32/64 0x10 ; ModR/M byte