Skip to main content
Became Hot Network Question
grammar, format mnemonics as code; edited tags
Source Link
user3840170
  • 24.9k
  • 4
  • 100
  • 158

Why does the 6502 JSR instruction only increaseincrement the PC withreturn address by 2 bytes?

Currently messing with 6502 assembly on a C64, and I don't understand why the JSRJSR instruction is so weird.

According to the instruction-table table, JSRJSR is a 3-byte instruction and only operates in absolute mode. However, JSRJSR only increasesincrements the PC withby 2 bytes before pushing it on the stack. Which means SPthe return address points to the last byte of the JSRJSR instruction. It seems the RTSRTS pops the valuesvalue from the stack, adds another byte to and increments it again before setting the PC to the corrected value.

My question is: Why? Why not just let JSR increaseJSR increment the PC withby 3 bytes instead of 2, and let RTSRTS just pullpop and jump? This looks like a forfar more logical approach. Any reason for making this so complicated?

Why does the 6502 JSR instruction only increase the PC with 2 bytes?

Currently messing with 6502 assembly on a C64, and I don't understand why the JSR instruction is so weird.

According to the instruction-table, JSR is a 3-byte instruction and only operates in absolute mode. However, JSR only increases the PC with 2 bytes before pushing it on the stack. Which means SP points to the last byte of the JSR instruction. It seems the RTS pops the values from the stack, adds another byte to it before setting the PC to the corrected value.

My question is: Why? Why not just let JSR increase the PC with 3 bytes instead of 2, and let RTS just pull and jump? This looks like a for more logical approach. Any reason for making this so complicated?

Why does the 6502 JSR instruction only increment the return address by 2 bytes?

Currently messing with 6502 assembly on a C64, and I don't understand why the JSR instruction is so weird.

According to the instruction table, JSR is a 3-byte instruction and only operates in absolute mode. However, JSR only increments the PC by 2 before pushing it on the stack. Which means the return address points to the last byte of the JSR instruction. It seems the RTS pops the value from the stack and increments it again before setting the PC to the corrected value.

My question is: Why? Why not just let JSR increment the PC by 3 instead of 2, and let RTS just pop and jump? This looks like a far more logical approach. Any reason for making this so complicated?

Source Link

Why does the 6502 JSR instruction only increase the PC with 2 bytes?

Currently messing with 6502 assembly on a C64, and I don't understand why the JSR instruction is so weird.

According to the instruction-table, JSR is a 3-byte instruction and only operates in absolute mode. However, JSR only increases the PC with 2 bytes before pushing it on the stack. Which means SP points to the last byte of the JSR instruction. It seems the RTS pops the values from the stack, adds another byte to it before setting the PC to the corrected value.

My question is: Why? Why not just let JSR increase the PC with 3 bytes instead of 2, and let RTS just pull and jump? This looks like a for more logical approach. Any reason for making this so complicated?