assembly6502

6502 assembly JMP


If I use this opcode

JMP
Jump to New Location

(PC+1) -> PCL
(PC+2) -> PCH
N   Z   C   I   D   V
-   -   -   -   -   -
addressing  assembler   opc bytes   cycles
absolute    JMP oper    4C  3   3  

and give it a hex value of say 0x0604 will it jump to that location execute what's there and then continue until it gets back to the JMP statement, or will it execute whats at 0x0604 and then do the next instruction after the JMP


Solution

  • A JMP $0604 instruction will change the program counter to the value $0604 and then start executing the instructions starting at address $0604. It will not return back to the instruction after the JMP. To accomplish that you need to change the JMP to a JSR, and make sure the subroutine code at $604 has an RTS instruction to return from the subroutine.