6

Given is the snap shot of memory of a byte-addressable computer. What would be loaded into register $16 after execution of instruction lw $16, 24($17) if machine is big endian and when Little Endian. Register $17 contains 200.

enter image description here

Now according to me, four bytes would be copied from the memory (224-227) irrespective of Little Endian or Big Endian,then if the machine is Big Endian then they will be copied to the register as they are.

If the machine is Little Endian then will be reversed and then copied to the register.

Please guide me if I am wrong with the concept.

Bart Kiers
  • 166,582
  • 36
  • 299
  • 288

1 Answers1

7

You're right.

More technically, in big-endian mode, the most significant byte is the one with the lowest address, and least significant byte is the one with the highest address. In little-endian mode, the most significant byte is the one with the highest address, while the least significant byte is the one with the lowest address.

So the contents of $16 register would be

If big-endian -> BADADBBD If little-endian -> BDDBDABA

m0skit0
  • 25,268
  • 11
  • 79
  • 127
  • Yes I really confused byte order in memory and bit patterns in registers which are not related. The bit patterns in registers for the same number will be the same in both architectures. – Vladimir F Героям слава Nov 08 '11 at 13:35
  • No, byte order in memory and registers is the same. – m0skit0 Oct 19 '12 at 11:22
  • 1
    Just to clarify, in either case, the four bytes from `224` to `227` would be loaded in `$16`; if the architecture is little-endian to begin with, the numbering of OP's memory diagram would have been reversed, therefore giving us `BDDBDABA` instead of `BADADBBD` – Yibo Yang Sep 29 '15 at 16:15