6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Apr 19, 2024 8:44 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sat Feb 19, 2011 4:28 am 
Offline

Joined: Tue Dec 25, 2007 4:57 am
Posts: 109
As I said earlier in the previous thread, I questioned if program counter goes to arithmetic logic unit to do increment. They answered no because program counter register has its own increment.

And I have another question. It is the branch relative. Do a byte as branch relative is loaded into data bus from memory location before it is transferred to arithmetic logic unit to do addition?

I wonder if branch relative goes to ALU’s input B register and program counter’s low byte goes to ALU’s input A register through special bus. After addition is performed, the modified program counter’s low byte is transferred back to the program counter’s low byte register from ALU’s output register.

The process will be repeated if page boundary is crossed. The ALU’s input B register is discarded. The program counter’s high byte is transferred to ALU’s input A register. The carry increments or decrements the program counter’s high byte. After addition is performed, the modified program counter’s high byte is transferred back to the program counter’s high byte register from ALU’s output register.

Am I correct?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Feb 19, 2011 12:11 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10789
Location: England
yes, the ALU is used.

you can track what happens using visual6502, with an URL like this which will result in a table like this:

Code:
cyc   ab   db   rw  Fetch   pc   a    x    y    s    p        alua  alub alu cout  sb  idb  adl  adh
0   0000   90   1   BCC   0000   aa   00   00   fd   nv‑BdIZc   ff   00   00   0   ff   00   00   00
0   0000   90   1   BCC   0000   aa   00   00   fd   nv‑BdIZc   ff   00   ff   0   ff   ff   01   00
1   0001   3f   1         0001   aa   00   00   fd   nv‑BdIZc   ff   ff   ff   0   ff   ff   01   00
1   0001   3f   1         0001   aa   00   00   fd   nv‑BdIZc   ff   ff   fe   1   ff   ff   02   00
2   0002   ea   1         0002   aa   00   00   fd   nv‑BdIZc   3f   02   fe   1   3f   3f   02   00
2   0002   ea   1         0002   aa   00   00   fd   nv‑BdIZc   3f   02   41   0   00   ff   41   00
3   0041   ea   1   NOP   0041   aa   00   00   fd   nv‑BdIZc   00   00   41   0   00   ff   41   00
3   0041   ea   1   NOP   0041   aa   00   00   fd   nv‑BdIZc   00   00   01   0   01   01   42   00
4   0042   ea   1         0042   aa   00   00   fd   nv‑BdIZc   01   01   01   0   01   01   42   00
4   0042   ea   1         0042   aa   00   00   fd   nv‑BdIZc   01   01   02   0   ff   ff   42   00


For the case of a page crossing, yes the ALU carry out will tell the sequencer to take an extra cycle. (Of course, the 6502's C flag isn't used or changed)

So, here's an extended test which results in this:


Code:
cycle  ab    db  rw  Fetch  pc    a   x   y   s         p  State  alua  alub  alu alucout sb      idb  adl  adh
0      0000  90  1   BCC  0000   aa  00  00  fd  nv-BdIZc  T1     ff     00    00    0    ff       00  00   00
0      0000  90  1   BCC  0000   aa  00  00  fd  nv-BdIZc  T1     ff     00    ff    0    ff       ff  01   00
1      0001  7f  1   -    0001   aa  00  00  fd  nv-BdIZc  T2     ff     ff    ff    0    ff       ff  01   00
1      0001  7f  1   -    0001   aa  00  00  fd  nv-BdIZc  T2     ff     ff    fe    1    ff       ff  02   00
2      0002  ea  1   -    0002   aa  00  00  fd  nv-BdIZc  T3     7f     02    fe    1    7f       7f  02   00
2      0002  ea  1   -    0002   aa  00  00  fd  nv-BdIZc  T3     7f     02    81    0    00       ff  81   00
3      0081  f0  1   BEQ  0081   aa  00  00  fd  nv-BdIZc  -      00     00    81    0    00       ff  81   00
3      0081  f0  1   BEQ  0081   aa  00  00  fd  nv-BdIZc  -      00     00    01    0    01       01  82   00
4      0082  7f  1   -    0082   aa  00  00  fd  nv-BdIZc  T2     01     01    01    0    01       01  82   00
4      0082  7f  1   -    0082   aa  00  00  fd  nv-BdIZc  T2     01     01    02    0    ff       ff  83   00
5      0083  00  1   -    0083   aa  00  00  fd  nv-BdIZc  T3     7f     83    02    0    7f       7f  83   00
5      0083  00  1   -    0083   aa  00  00  fd  nv-BdIZc  T3     7f     83    02    1    00       ff  02   00
6      0002  ea  1   -    0002   aa  00  00  fd  nv-BdIZc  T0     00     00    02    1    00       ff  02   00
6      0002  ea  1   -    0002   aa  00  00  fd  nv-BdIZc  T0     00     00    01    0    01       ff  02   01
7      0102  ea  1   NOP  0102   aa  00  00  fd  nv-BdIZc  T1     01     ea    01    0    01       ea  02   01
7      0102  ea  1   NOP  0102   aa  00  00  fd  nv-BdIZc  T1     01     ea    eb    0    eb       eb  03   01
8      0103  ea  1   -    0103   aa  00  00  fd  nv-BdIZc  T0+T2  eb     eb    eb    0    eb       eb  03   01
8      0103  ea  1   -    0103   aa  00  00  fd  nv-BdIZc  T0+T2  eb     eb    d6    1    ff       ff  03   01
9      0103  ea  1   NOP  0103   aa  00  00  fd  nv-BdIZc  T1     ff     ff    d6    1    ff       ff  03   01
9      0103  ea  1   NOP  0103   aa  00  00  fd  nv-BdIZc  T1     ff     ff    fe    1    fe       fe  04   01


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 4 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: