assemblydisassemblyhexdumpeeprom6502

Why does first address equal 0000 when .org 8000 in assembly?


I watched Ben Eater's video about building a computer based on 6502 chip and I'm stuck in part 3 (Assembly language VS Machine code). He is programming 32k EEPROM and he programmed by assembly to blink LED. This is assembler he used http://sun.hasenbraten.de/vasm/ Here his code:

enter image description here

But I have a question about org directive, this is what I understand org tell assembler what address to start right? In picture org equals $8000 so I think first address instruction should be 8000 but when he output file it equal 0000.

Why is the first instruction's address not 8000?

enter image description here


Solution

  • It's a flat binary with no metadata, and hexdump is showing you file offsets anyway, not looking for metadata to figure out load addresses.

    If you use xxd to do the hex dumping, it has a -o option that lets you specify an offset to add to the file position. xxd -g 1 -o 0x8000 a.out should start at 00008000 and generally resemble hexdump -C (1-byte groups, -groupsize 1)

    Disassemblers for flat binaries typically have similar options, to disassemble as if the image was loaded / mapped to a certain base address in memory.