diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-07-28 14:31:58 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-07-28 14:31:58 -0700 |
commit | 5cea4ef897c0aac2b35315c4208140e0ed66bd34 (patch) | |
tree | 2a2ea5aa3907b99b344006120266730d86c4f0d4 /subx | |
parent | b3a3d14f98305af875c9363b9e894965cd4b45f7 (diff) | |
download | mu-5cea4ef897c0aac2b35315c4208140e0ed66bd34.tar.gz |
4449
Diffstat (limited to 'subx')
-rw-r--r-- | subx/ex3.subx | 6 | ||||
-rw-r--r-- | subx/ex4.subx | 10 | ||||
-rw-r--r-- | subx/ex5.subx | 10 | ||||
-rw-r--r-- | subx/ex6.subx | 7 |
4 files changed, 14 insertions, 19 deletions
diff --git a/subx/ex3.subx b/subx/ex3.subx index b2d6d7c4..9439b3d3 100644 --- a/subx/ex3.subx +++ b/subx/ex3.subx @@ -17,12 +17,12 @@ b9/copy 1/imm32 # copy 1 to ECX loop: - # while (ECX <= 10) + # while (counter <= 10) 81 7/subop/compare 3/mod/direct 1/rm32/ecx 0xa/imm32 # compare ECX, 10/imm 7f/jump-if exit/disp8 # jump-if-greater exit - # EBX += ECX + # result += counter 01/add 3/mod/direct 3/rm32/ebx 1/r32/ecx # add ECX to EBX - # ECX++ + # ++counter 81 0/subop/add 3/mod/direct 1/rm32/ecx 1/imm32 # add 1 to ECX # loop eb/jump loop/disp8 # jump loop diff --git a/subx/ex4.subx b/subx/ex4.subx index db4abae3..0d5f76a8 100644 --- a/subx/ex4.subx +++ b/subx/ex4.subx @@ -12,25 +12,23 @@ ## read(stdin, x, 1) # fd = 0 (stdin) bb/copy 0/imm32 # copy 0 to EBX - # set location to write to + # initialize x (location to write result to) b9/copy 0x080490a7/imm32 # copy to ECX # size = 1 character ba/copy 1/imm32 # copy 1 to EDX - # syscall = read + # read(fd, x, size) b8/copy 3/imm32 # copy 3 to EAX - # call cd/syscall 0x80/imm8 # int 80h ## write(stdout, x, 1) # fd = 1 (stdout) bb/copy 1/imm32 # copy 1 to EBX - # set location to write to + # initialize x (location to read from) b9/copy 0x080490a7/imm32 # copy to ECX # size = 1 character ba/copy 1/imm32 # copy 1 to EDX - # syscall = write + # write(fd, x, size) b8/copy 4/imm32 # copy 4 to EAX - # call cd/syscall 0x80/imm8 # int 80h ## exit(EBX) diff --git a/subx/ex5.subx b/subx/ex5.subx index 540d0315..bdbfe6f4 100644 --- a/subx/ex5.subx +++ b/subx/ex5.subx @@ -19,25 +19,23 @@ ## read(stdin, x, 1) # fd = 0 (stdin) bb/copy 0/imm32 # copy 0 to EBX - # set location to read character to + # initialize x (location to write result to) 89/copy 3/mod/direct 1/rm32/ECX 5/r32/EBP # copy EBP to ECX # size = 1 character ba/copy 1/imm32 # copy 1 to EDX - # syscall = read + # read(fd, x, size) b8/copy 3/imm32 # copy 3 to EAX - # call cd/syscall 0x80/imm8 # int 80h ## write(stdout, x, 1) # fd = 1 (stdout) bb/copy 1/imm32 # copy 1 to EBX - # set location of character to write out + # initialize x (location to read from) 89/copy 3/mod/direct 1/rm32/ECX 5/r32/EBP # copy EBP to ECX # size = 1 character ba/copy 1/imm32 # copy 1 to EDX - # syscall = write + # write(fd, x, size) b8/copy 4/imm32 # copy 4 to EAX - # call cd/syscall 0x80/imm8 # int 80h ## exit(EBX) diff --git a/subx/ex6.subx b/subx/ex6.subx index 685076e7..2c9555d8 100644 --- a/subx/ex6.subx +++ b/subx/ex6.subx @@ -13,14 +13,13 @@ ## write(stdout, x, 1) # fd = 1 (stdout) bb/copy 1/imm32 # copy 1 to EBX - # set location to write out + # initialize x (location to write result to) b9/copy 0x08049097/imm32 # copy to ECX - # set size + # initialize size ba/copy 0x08049093/imm32 # copy to EDX 8b/copy 0/mod/indirect 2/rm32/edx 2/r32/edx # copy *EDX to EDX - # syscall = write + # write(fd, x, size) b8/copy 4/imm32 # copy 4 to EAX - # call cd/syscall 0x80/imm8 # int 80h ## exit(EBX) |