Hi there. I do not understand the following line of code.
program_counter = (memory[0xFFFD] << 8) | memory[0xFFFC];
The array memory represents the memory space of our processor. The starting address for
a 6502 program is stored at location $FFFC and $FFFD in memory. The 6502 stores
addresses in low byte/hi byte format, so $FFFD contains the upper 8 bits of the
address and $FFFC the lower 8 bits. This line assembles the 2 bytes into a 16-
I am aware of bit manipulation in C, so I understand what the line of code "does", so to speak, but I'm not sure what it is we are achieving by doing this.
Using the following binary number as an example: 0111001101100001
Are we saying that memory[0xFFFD] holds 0000000001110011, and memory[0xFFFC] holds 0000000001100001?
Because then (memory[0xFFFD] << 8) | memory[0xFFFC] == 0111001101100001.
But the author doesn't make this clear so I'm not sure. Thanks for any clarification.
Edit: The author says "This line assembles the 2 bytes into a 16-bit address.", so $FFFD and $FFFC only hold a byte each. Then surely (memory[0xFFFD] << 8) will simple equal 00000000?