0

If: (I believe the registers are adjacent to one another...)

 A BYTE 0xB, 0d20, 0d10, 0d13, 0x0C
 B WORD 0d30, 0d40, 0d70, 0hB 
 D DWORD 0xB0, 0x200, 0x310, 0x400, 0x500, 0x600 

Then:

  • What is [A+2]? The answer is 0d20 or 0x15
  • What is [B+2]? The answer is 40 or 0x28
  • What is [D+4]? Not sure
  • What is [D-10]? Not sure

I think those are the answers but I am not sure. Since a WORD is 1 BYTE, AND DWORD is 2 WORDS, then as a result when you are counting the array of [B+2] for example, you should be starting at 0d30, then 0d40 (count two WORD). And [A+2] is 0d20 because you are counting two bytes. What am I doing wrong?

So is it because: Taking into account that the first value of A,B, and D are offsets x86 is little endian... A = 0d10, count 2 more from there B...bytes (in decimal) = 30,0,40,0,70,0,11,0 B is 0d40, count 2 more bytes from that D...bytes (in hex) = 0x200, 0,0,0,...0,2,0,0,...0x10,3,0,0,...0,4,0,0,...0,5,0,0,...0,6,‌​0,0 D is 0x200. Count 4 bytes from there. Count 10 bytes backwards from 0xb0. So wouldn't [D-10] be equal to 0x0C?

Also if I did [B-3], would it be 0d13? I was told it actually is between 0d10 and 0d13 such that it will be 0A0D and due to little endian will be 0D0A. Is that correct?

2
  • 1
    This is for Windows x86 MASM. Thanks!! Commented Oct 16, 2016 at 4:28
  • 1
    While the The M is for MicroSoft, the OS really has nothing to do with this problem. Commented Oct 16, 2016 at 4:31

1 Answer 1

2

What is [A+2]? The answer is 0d20 or 0x15

Start at [A] (which is the same as [A+0]), go forward two bytes

A BYTE 0xB, 0d20, 0d10, 0d13, 0x0C
       ^0   ^1    ^2   

Answer: 0d10

What is [B+2]? The answer is 40 or 0x28

A word is two bytes

Offsets are always in bytes. Therefore +2 = +2 bytes = +1 word

B WORD 0d30, 0d40, 0d70, 0hB 
   ^0    ^+2  <--bytes
   ^0    ^+1  <--words

Answer: 0d40

What is [D+4]? Not sure

Each dword is four bytes

Indexes are always in bytes, so +4 = +4 bytes = +1 dword

Start at [D] which is the same as [D+0]... more forward one

D DWORD 0xB0, 0x200, 0x310, 0x400, 0x500, 0x600 
        ^0    ^+1   <--dwords
        ^0    ^+4   <--bytes

Answer: 0x200

What is [D-10]? Not sure

Offsets are always in bytes

A dword contains four bytes

A word contains two bytes

A BYTE 0xB, 0d20, 0d10, 0d13, 0x0C
                        ^-10  ^-9
B WORD 0d30, 0d40, 0d70, 0hB 
       ^-8   ^-6   ^-4   ^-2
D DWORD 0xB0, 0x200, 0x310, 0x400, 0x500, 0x600 
        ^0

Answer: 0d13

Sign up to request clarification or add additional context in comments.

1 Comment

AMAZING!! THANK YOU

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.