6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Sep 22, 2024 8:25 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Thu Jul 31, 2008 7:34 pm 
Offline

Joined: Tue Dec 25, 2007 4:57 am
Posts: 109
I looked at 6502 diagram like datasheet. It does mention that all internal registers are connected to internal data bus and internal address bus. Do it have temporary internal register other than internal data bus?

For example, external address bus is $1000 and external data bus is $4C. The instruction reads "JMP $5F72" 6502 MPU receives $4C and stored in data latch register. It is sent to instruction register while it is in the process to fetch and decode opcode.

Next cycle, external address is $1001 and external data bus is $72. 6502 MPU receives $72 and stored in data latch register. Which register $72 is stored? I suppose to say "Program Counter Low" register or temporary register. "Program Counter Low" and "Program Counter High" are separate registers from "16 bit Program Counter".

Next cycle, external address is $1002 and external data bus is $5F. 6502 MPU receives $5F and stored in data latch register. $72 is copied from temporary register and $5F is copied from data latch register before both $72 and $5F are sent into Program Counter register.

Next cycle, Program Counter register sends $5F72 to the external address bus and external data bus receives next opcode.

Please correct me if I am wrong. Are "internal address bus" and "internal data bus" two separate temporary registers?

Bryan Parkoff


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Aug 02, 2008 5:14 am 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
The block diagram doesn't usually show it, but there are a small number of temporary registers in the microprocessor. I *think* the 6502 can get by with just one temporary, but I am pretty sure the 65816 has at least three.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Sep 13, 2010 3:12 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Armed with the transistor-level simulation, we can begin to answer some questions like this.

For the case of JMP, the first operand passes from the IDL (input data latch) to the ALU. So when the second operand is presented, the ALU output latch (called ADD in Donald Hanson's block diagram) holds the LSB and the IDL holds the MSB of the new PC.

I think these two latches are all of the non-visible byte-sized state in the datapath. There's other hidden state for the pipeline control, and of course the IR (instruction register) is non-visible and byte-sized, but always in use and, as it happens, not physically in the datapath.

In the case of JSR, I was surprised and delighted to find that the stack pointer is used to hold the first operand for 4 cycles, while the SP is passed to the ALU for decrement and the PC is written to the stack. In the cycle that the new SP value is written back to the register, the LSB can be written to PC.

Here are the simulation results:
Code:
A:0001 D:20 RnW:1  PC:0001  SP:fd  Sync:1  IR:ea idl:20 alu:fe TCstate:011111
A:0002 D:72 RnW:1  PC:0002  SP:fd  Sync:0  IR:20 idl:72 alu:fc TCstate:110111
A:01fd D:00 RnW:1  PC:0003  SP:72  Sync:0  IR:20 idl:00 alu:fd TCstate:111011
A:01fd D:00 RnW:0  PC:0003  SP:72  Sync:0  IR:20 idl:00 alu:fc TCstate:111101
A:01fc D:03 RnW:0  PC:0003  SP:72  Sync:0  IR:20 idl:03 alu:fb TCstate:111110
A:0003 D:5f RnW:1  PC:0003  SP:72  Sync:0  IR:20 idl:5f alu:fb TCstate:101111
A:5f72 D:00 RnW:1  PC:5f72  SP:fb  Sync:1  IR:20 idl:00 alu:5f TCstate:011111


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Sep 14, 2010 12:58 am 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
That is just so wrong on so many levels. I love it! :)

That also helps explain why the stack pointer is only 8-bits wide on the original 6502, and appears near the ALU.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Sep 14, 2010 7:02 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
It tickles me that the 6502 internally has the same difficulty with shortage of register space that we have at the machine code level.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Nov 29, 2010 9:52 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
We've just released an updated version of the transistor-level simulator which, amongst other things, allows you to go direct to the tabulated bus activity. It looks a little like this:

Code:
cyc  ab    db  rw  Fetch  pc    a   x   y   s   Execute  State  pd  adl  adh  sb  alu  idl  idb  dor
0    0020  ea  1   NOP    0020  aa  00  00  fd  BRK      T1     ea  21   00   ff  ff   ea   ff   00
1    0021  20  1   x      0021  aa  00  00  fd  NOP      T0+T2  20  21   00   ff  fe   20   ff   ff
2    0021  20  1   JSR    0021  aa  00  00  fd  NOP      T1     20  22   00   fe  fe   20   fe   ff
3    0022  21  1   x      0022  aa  00  00  fd  JSR      T2     21  fd   01   ff  fc   21   ff   fe
4    01fd  00  1   x      0023  aa  00  00  21  JSR      T3     00  fd   ff   ff  fd   00   00   21
5    01fd  00  0   x      0023  aa  00  00  21  JSR      T4     00  fc   ff   ff  fc   00   23   00
6    01fc  23  0   x      0023  aa  00  00  21  JSR      T5     23  23   00   fb  fb   23   ff   23
7    0023  43  1   x      0023  aa  00  00  21  JSR      T0     43  21   ff   fb  fb   43   ff   ff
8    4321  60  1   RTS    4321  aa  00  00  fb  JSR      T1     60  22   43   43  43   60   43   43


(And of course you can tweak these URLs to illustrate or explore other situations.)


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 13 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: