0

I am currently a university student and my professor zoomed in while recording the lecture so I couldn't see what he was writing. I'm not sure how for example a "DWORD 5" would be stored say for example starting at location 2000:

I was thinking

2000: 00000101

2001: 00000000

2002: 00000000

2003: 00000000

but I'm not sure if it could be.

2000: 00000000

2001: 00000000

2002: 00000000

2003: 00000101

I would appreciate it if someone could explain which one is correct.

  • It depends on the architecture you are programming for. On x86, a *little endian* architecture, the former is correct. On *big endian* architectures like M68k, the latter is correct. Some architectures have configurable endianess (e.g. ARM, PPC, MIPS). – fuz Mar 05 '21 at 17:15
  • you can try this yourself with an assembler, e.g. put `dd 5` in a file called `foo.asm` and run `nasm foo.asm -l/dev/stdout` to write a "listing" to stdout, with the bytes hex-dumped in memory order. (And create `foo.bin` which you could also hexdump). – Peter Cordes Mar 06 '21 at 02:54

1 Answers1

2

x86 is little-endian, and "[a] little-endian system, stores the least-significant byte at the smallest address".

So, the first one.

ilkkachu
  • 6,221
  • 16
  • 30