6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Apr 27, 2024 9:43 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Nov 22, 2023 3:02 pm 
Offline

Joined: Thu Oct 26, 2023 5:39 pm
Posts: 5
I was reading the JMP instruction of 6502 at https://www.masswerk.at/6502/6502_instruction_set.html#CMP

It states the folllowing:
Quote:
JMP: Jump to New Location

(PC+1) -> PCL
(PC+2) -> PCH

I understand that the JMP instruction will change the Program Counter to the address given by the operand of the JMP instruction, after which it starts executing instructions starting from this new location. But I don't understand what does (PC+1) -> PCL and (PC+2) -> PCH mean exactly?


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 22, 2023 3:12 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1399
Location: Scotland
randomkiwi wrote:
I was reading the JMP instruction of 6502 at https://www.masswerk.at/6502/6502_instruction_set.html#CMP

It states the folllowing:
Quote:
JMP: Jump to New Location

(PC+1) -> PCL
(PC+2) -> PCH

I understand that the JMP instruction will change the Program Counter to the address given by the operand of the JMP instruction, after which it starts executing instructions starting from this new location. But I don't understand what does (PC+1) -> PCL and (PC+2) -> PCH mean exactly?


Generally, ()'s round something means an indirection, so (PC+1) means the byte at the location PC+1 and not the value of PC+1.

So the CPU is decoding the JMP instruction at PC, the CPU fetches the byte at PC+1 and stores it into PCL, (The low byte of the 16-bit program counter) fetches the next byte and stores in into PCH (high byte) then fetches the next instruction at the new PC.

You may next wonder how it can fetch the high byte after it's modified the low byte of the PC... How deep do you want to go?

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: