diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-07-07 23:13:25 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-07-07 23:13:25 -0700 |
commit | c90fa6534ecbdf3e61f19ce2b7cabbc2957ef202 (patch) | |
tree | a841f3e18c9a65ef2dcd22c603b623bcedaa7643 | |
parent | 97a9bd1756d5ea934372847bb9f1dfa8a4ad256d (diff) | |
download | mu-c90fa6534ecbdf3e61f19ce2b7cabbc2957ef202.tar.gz |
4325
-rw-r--r-- | subx/ex1.1.subx | 1 | ||||
-rw-r--r-- | subx/ex1.2.subx | 1 | ||||
-rw-r--r-- | subx/ex2.subx | 4 | ||||
-rw-r--r-- | subx/ex3.subx | 9 |
4 files changed, 11 insertions, 4 deletions
diff --git a/subx/ex1.1.subx b/subx/ex1.1.subx index 97e52d60..112fb86f 100644 --- a/subx/ex1.1.subx +++ b/subx/ex1.1.subx @@ -8,6 +8,7 @@ # instruction mod, reg, Reg/Mem bits scale, index, base # 1-3 bytes 0/1 byte 0/1 byte 0/1/2/4 bytes 0/1/2/4 bytes bb 2a 00 00 00 # copy 0x2a (42) to EBX + # exit(EBX) b8 01 00 00 00 # copy 1 to EAX cd 80 # int 80h diff --git a/subx/ex1.2.subx b/subx/ex1.2.subx index 21f6560f..cc8b55da 100644 --- a/subx/ex1.2.subx +++ b/subx/ex1.2.subx @@ -8,6 +8,7 @@ # instruction mod, reg, Reg/Mem bits scale, index, base # 1-3 bytes 0/1 byte 0/1 byte 0/1/2/4 bytes 0/1/2/4 bytes bb 42/imm32 # copy 0x2a (42) to EBX + # exit(EBX) b8 1/imm32 # copy 1 to EAX cd 128/imm8 # int 80h diff --git a/subx/ex2.subx b/subx/ex2.subx index aed8dc8d..39829cef 100644 --- a/subx/ex2.subx +++ b/subx/ex2.subx @@ -3,9 +3,9 @@ # opcode ModR/M SIB displacement immediate # instruction mod, reg, Reg/Mem bits scale, index, base # 1-3 bytes 0/1 byte 0/1 byte 0/1/2/4 bytes 0/1/2/4 bytes - bb 1/imm32 # copy 42 to EBX + bb 1/imm32 # copy 1 to EBX 81 c3 1/imm32 # add 1 to EBX - # exit + # exit(EBX) b8 1/imm32 # copy 1 to EAX cd 128/imm8 # int 80h diff --git a/subx/ex3.subx b/subx/ex3.subx index df793f5d..06249ebf 100644 --- a/subx/ex3.subx +++ b/subx/ex3.subx @@ -3,20 +3,25 @@ # opcode ModR/M SIB displacement immediate # instruction mod, reg, Reg/Mem bits scale, index, base # 1-3 bytes 0/1 byte 0/1 byte 0/1/2/4 bytes 0/1/2/4 bytes - # result: EBX + # result: EBX = 0 # 0: e_entry = 0x08048054 bb 0/imm32 # copy 0 to EBX - # counter: ECX + # counter: ECX = 1 b9 1/imm32 # copy 1 to ECX # 10: loop: 0x0804805e + # while (ECX <= 10) 81 f9 10/imm32 # compare ECX, 10/imm 7f 0a # jump-if-greater exit (+10) + # EBX += ECX 01 cb # add ECX to EBX + # ECX++ 81 c1 1/imm32 # add 1 to ECX + # loop eb ee # jump loop (-18; -00010010; 11101110) # 28: exit: 0x08048070 + # exit(EBX) b8 1/imm32 # copy 1 to EAX cd 128/imm8 # int 80h |