diff options
Diffstat (limited to 'subx/examples/ex4.subx')
-rw-r--r-- | subx/examples/ex4.subx | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/subx/examples/ex4.subx b/subx/examples/ex4.subx index 3c4f8949..9e062cb2 100644 --- a/subx/examples/ex4.subx +++ b/subx/examples/ex4.subx @@ -5,35 +5,31 @@ # $ subx run examples/ex4 == code -# instruction effective address operand displacement immediate -# op subop mod rm32 base index scale r32 -# 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes +# read(stdin, x, 1) + # fd = 0 (stdin) +bb/copy-to-EBX 0/imm32 + # initialize x (location to write result to) +b9/copy-to-ECX x/imm32 + # size = 1 character +ba/copy-to-EDX 1/imm32 + # read(fd, x, size) +b8/copy-to-EAX 3/imm32/read +cd/syscall 0x80/imm8 - # read(stdin, x, 1) - # fd = 0 (stdin) - bb/copy-to-EBX 0/imm32 - # initialize x (location to write result to) - b9/copy-to-ECX x/imm32 - # size = 1 character - ba/copy-to-EDX 1/imm32 - # read(fd, x, size) - b8/copy-to-EAX 3/imm32/read - cd/syscall 0x80/imm8 +# write(stdout, x, 1) + # fd = 1 (stdout) +bb/copy-to-EBX 1/imm32 + # initialize x (location to read from) +b9/copy-to-ECX x/imm32 + # size = 1 character +ba/copy-to-EDX 1/imm32 + # write(fd, x, size) +b8/copy-to-EAX 4/imm32/write +cd/syscall 0x80/imm8 - # write(stdout, x, 1) - # fd = 1 (stdout) - bb/copy-to-EBX 1/imm32 - # initialize x (location to read from) - b9/copy-to-ECX x/imm32 - # size = 1 character - ba/copy-to-EDX 1/imm32 - # write(fd, x, size) - b8/copy-to-EAX 4/imm32/write - cd/syscall 0x80/imm8 - - # exit(EBX) - b8/copy-to-EAX 1/imm32/exit - cd/syscall 0x80/imm8 +# exit(EBX) +b8/copy-to-EAX 1/imm32/exit +cd/syscall 0x80/imm8 == data x: |