diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-10-02 11:21:05 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-10-02 11:21:05 -0700 |
commit | 8871cd05a9d09ade1e61771661a126c43b4a7f02 (patch) | |
tree | f7bdca82a13b740195c3ec00c34b7733fc58ab0c | |
parent | 5a2cb154eb016aa8b84ad939f63eb56dd7a0a90f (diff) | |
download | mu-8871cd05a9d09ade1e61771661a126c43b4a7f02.tar.gz |
4650
-rw-r--r-- | subx/examples/ex1.subx | 4 | ||||
-rw-r--r-- | subx/examples/ex3.subx | 10 | ||||
-rw-r--r-- | subx/examples/ex4.subx | 18 | ||||
-rw-r--r-- | subx/examples/ex6.subx | 10 |
4 files changed, 21 insertions, 21 deletions
diff --git a/subx/examples/ex1.subx b/subx/examples/ex1.subx index 790e24fe..579ac9f4 100644 --- a/subx/examples/ex1.subx +++ b/subx/examples/ex1.subx @@ -12,9 +12,9 @@ # 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 - bb/copy 2a/imm32 # copy 42 to EBX + bb/copy . . . . . . . 2a/imm32 # copy 42 to EBX # exit(EBX) - b8/copy 1/imm32 # copy to EAX + b8/copy . . . . . . . 1/imm32 # copy to EAX cd/syscall 0x80/imm8 # vim:ft=subx diff --git a/subx/examples/ex3.subx b/subx/examples/ex3.subx index 0a90e26e..caa4d9cf 100644 --- a/subx/examples/ex3.subx +++ b/subx/examples/ex3.subx @@ -12,16 +12,16 @@ # 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 # result: EBX = 0 - bb/copy 0/imm32 # copy to EBX + bb/copy . . . . . . . 0/imm32 # copy to EBX # counter: ECX = 1 - b9/copy 1/imm32 # copy to ECX + b9/copy . . . . . . . 1/imm32 # copy to ECX $loop: # while (counter <= 10) - 81 7/subop/compare 3/mod/direct 1/rm32/ECX 0xa/imm32 # compare ECX + 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0xa/imm32 # compare ECX 7f/jump-if-greater $exit/disp8 # result += counter - 01/add 3/mod/direct 3/rm32/EBX 1/r32/ECX # add ECX to EBX + 01/add 3/mod/direct 3/rm32/EBX . . . 1/r32/ECX . . # add ECX to EBX # ++counter 41/inc-ECX # loop @@ -29,7 +29,7 @@ $loop: $exit: # exit(EBX) - b8/copy 1/imm32 # copy to EAX + b8/copy . . . . . . . 1/imm32 # copy to EAX cd/syscall 0x80/imm8 # vim:ft=subx:nowrap diff --git a/subx/examples/ex4.subx b/subx/examples/ex4.subx index 965acd22..2d5f05b2 100644 --- a/subx/examples/ex4.subx +++ b/subx/examples/ex4.subx @@ -11,28 +11,28 @@ # read(stdin, x, 1) # fd = 0 (stdin) - bb/copy 0/imm32 # copy to EBX + bb/copy . . . . . . . 0/imm32 # copy to EBX # initialize x (location to write result to) - b9/copy x/imm32 # copy to ECX + b9/copy . . . . . . . x/imm32 # copy to ECX # size = 1 character - ba/copy 1/imm32 # copy to EDX + ba/copy . . . . . . . 1/imm32 # copy to EDX # read(fd, x, size) - b8/copy 3/imm32/read # copy to EAX + b8/copy . . . . . . . 3/imm32/read # copy to EAX cd/syscall 0x80/imm8 # write(stdout, x, 1) # fd = 1 (stdout) - bb/copy 1/imm32 # copy to EBX + bb/copy . . . . . . . 1/imm32 # copy to EBX # initialize x (location to read from) - b9/copy x/imm32 # copy to ECX + b9/copy . . . . . . . x/imm32 # copy to ECX # size = 1 character - ba/copy 1/imm32 # copy to EDX + ba/copy . . . . . . . 1/imm32 # copy to EDX # write(fd, x, size) - b8/copy 4/imm32/write # copy to EAX + b8/copy . . . . . . . 4/imm32/write # copy to EAX cd/syscall 0x80/imm8 # exit(EBX) - b8/copy 1/imm32/exit # copy to EAX + b8/copy . . . . . . . 1/imm32/exit # copy to EAX cd/syscall 0x80/imm8 == data diff --git a/subx/examples/ex6.subx b/subx/examples/ex6.subx index 17a0c6fe..9172cab3 100644 --- a/subx/examples/ex6.subx +++ b/subx/examples/ex6.subx @@ -12,17 +12,17 @@ # write(stdout, x, size) # fd = 1 (stdout) - bb/copy 1/imm32 # copy to EBX + bb/copy . . . . . . . 1/imm32 # copy to EBX # initialize x (location to write result to) - b9/copy x/imm32 # copy to ECX + b9/copy . . . . . . . x/imm32 # copy to ECX # initialize size - 8b/copy 0/mod/indirect 5/rm32/.disp32 2/r32/EDX size/disp32 # copy *size to EDX + 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 2/r32/EDX size/disp32 . # copy *size to EDX # write(fd, x, size) - b8/copy 4/imm32/write # copy to EAX + b8/copy . . . . . . . 4/imm32/write # copy to EAX cd/syscall 0x80/imm8 # exit(EBX) - b8/copy 1/imm32/exit # copy to EAX + b8/copy . . . . . . . 1/imm32/exit # copy to EAX cd/syscall 0x80/imm8 == data |