diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2018-01-24 23:27:45 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2018-01-24 23:27:45 -0800 |
commit | d1df4aca1746f480dca384e63f8bcb4f3ac1d42c (patch) | |
tree | aae42c0835870a57102ea9fe10458d97412a469d /subx | |
parent | bc9f26de6737e762e5e6045fc874d68842e98bca (diff) | |
download | mu-d1df4aca1746f480dca384e63f8bcb4f3ac1d42c.tar.gz |
4197 - done supporting all indirect addressing modes
Diffstat (limited to 'subx')
-rw-r--r-- | subx/014index_addressing.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/subx/014index_addressing.cc b/subx/014index_addressing.cc index 8ab545d3..e811290d 100644 --- a/subx/014index_addressing.cc +++ b/subx/014index_addressing.cc @@ -69,3 +69,47 @@ uint32_t effective_address_from_sib(uint8_t mod) { +run: effective address is initially 0x60 (disp32) +run: effective address is 0x60 +run: storing 0x00000011 + +//: + +:(scenario add_r32_to_mem_at_base_r32_index_r32_plus_disp8) +% Reg[3].i = 0x10; // source +% Reg[0].i = 0x59; // dest base +% Reg[1].i = 0x5; // dest index +% SET_WORD_IN_MEM(0x60, 1); +# op ModR/M SIB displacement immediate + 01 5c 08 02 # add EBX to *(EAX+ECX+2) +# ModR/M in binary: 01 (indirect+disp8 mode) 011 (src EBX) 100 (dest in SIB) +# SIB in binary: 00 (scale 1) 001 (index ECX) 000 (base EAX) ++run: add EBX to r/m32 ++run: effective address is initially 0x59 (EAX) ++run: effective address is 0x5e (after adding ECX*1) ++run: effective address is 0x60 (after adding disp8) ++run: storing 0x00000011 + +:(before "End Mod 1 Special-cases(addr)") +case 4: // exception: mod 0b01 rm 0b100 => incoming SIB (scale-index-base) byte + addr = effective_address_from_sib(mod); + break; + +//: + +:(scenario add_r32_to_mem_at_base_r32_index_r32_plus_disp32) +% Reg[3].i = 0x10; // source +% Reg[0].i = 0x59; // dest base +% Reg[1].i = 0x5; // dest index +% SET_WORD_IN_MEM(0x60, 1); +# op ModR/M SIB displacement immediate + 01 9c 08 02 00 00 00 # add EBX to *(EAX+ECX+2) +# ModR/M in binary: 10 (indirect+disp32 mode) 011 (src EBX) 100 (dest in SIB) +# SIB in binary: 00 (scale 1) 001 (index ECX) 000 (base EAX) ++run: add EBX to r/m32 ++run: effective address is initially 0x59 (EAX) ++run: effective address is 0x5e (after adding ECX*1) ++run: effective address is 0x60 (after adding disp32) ++run: storing 0x00000011 + +:(before "End Mod 2 Special-cases(addr)") +case 4: // exception: mod 0b10 rm 0b100 => incoming SIB (scale-index-base) byte + addr = effective_address_from_sib(mod); + break; |