assemblyindexingaddressing6502

6502 assembly and representation of addresses


I am trying to understand this kind of addressing mode in assembly 6502.

for instance we have in program this kind of instructions:

we know that ''text'' label is under $2000-high byte is 20, low byte is 00 in accumulator we have number 30. Now the first question is: What happened when I type STA $80. Does it mean that the whole address where we store accumulator is 0080? Now let say we put under $80 00 number and under $81 number 20. Y is zero. Now why when I use this:

sta ($80),y 

I am getting address 2000? How is that happening? Under 0080 we have only 00(byte) not the whole address(2 bytes) 2000. I know that ($80) means that we go to the addresses pointed by $80. But we stored there only 00 not the whole address 2000. I would be grateful for any help.


Solution

  • On 6502 addresses are 16 bit. The STA $80 example used zero page addressing, which automatically implies the top 8 bits are zero, thus the full address being $0080. The indirect addressing fetches the top 8 bits from the next memory cell, since each cell is 1 byte and you need 2 bytes for the address.