6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Sep 20, 2024 7:24 am

All times are UTC




Post new topic Reply to topic  [ 138 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 10  Next
Author Message
PostPosted: Fri Aug 04, 2017 6:34 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
I agree - the 6502 choice is the clever choice! It makes good sense from an implementation perspective, although sometimes people complain about the SEC and the not-borrow.


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 04, 2017 6:43 am 
Offline

Joined: Fri Jul 21, 2017 8:16 pm
Posts: 59
"BCC, or "branch on carry clear," means "branch if less than" if it's after a subtraction."
Thank you! Oh! So the XORing of the carry with Sub was unnecessary. Good to know! So I will simply letch the carry signal into the status register - and my code has to analyse what it means in case of subtraction or addition.


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 04, 2017 6:56 am 
Offline

Joined: Fri Jul 21, 2017 8:16 pm
Posts: 59
I want to enhance my current breadboard computer to become a 65C02 (I know that this could take ages or will never be successful. But I need a target. And I will learn a lot)
This is why I asked for the microcode. In my breadboard computer I used an EEPROM for the control Logic.
(see screenshot) And I wonder if this is the same in the 65C02.


Attachments:
screenshot controllogic.jpeg
screenshot controllogic.jpeg [ 373.87 KiB | Viewed 1373 times ]
Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 04, 2017 7:06 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
I think we know from die photos that the 65C02 structure and floorplan is very like the 6502: a large regular first-stage decode (often called a PLA, sometimes called a ROM) followed by a less regular second stage decode (often called random logic)

See here for example (blog post with video within) which we discussed here:
"65C02: Tear down, A look at the CMOS version of the 6502"

But I don't believe anyone has extracted the structure of a 65c02 in the way that visual6502 has done for the 6502.


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 04, 2017 7:37 am 
Offline

Joined: Fri Jul 21, 2017 8:16 pm
Posts: 59
Hi! Thanks! I am just printing out the patent he's referring to.
Exactly was I was looking for! 8)

Patents cited on die:

http://www.google.ca/patents/US4800487
http://www.google.ca/patents/US4652992
http://www.google.ca/patents/US4876639
http://www.google.ca/patents/US4652992


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 04, 2017 7:38 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Good thinking!


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 04, 2017 7:41 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Perhaps a typo - you missed this one:
https://www.google.com/patents/US4876639
Edit oops, meant this one:
https://www.google.com/patents/US4739475

Note that two of the four patents are for the '816.


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 04, 2017 9:01 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8510
Location: Southern California
GARTHWILSON wrote:
nei02 wrote:
I want to implement a BCC and BCS.
I assume that this is equal to a "less than" .

BCC, or "branch on carry clear," means "branch if less than" if it's after a subtraction.

I should have been more clear and complete. "Carry clear" means there was a borrow because the number you started with was less than the number you subtracted. You normally start the subtraction with the carry flag set. If the number you're starting with is less than the number you're subtracting, there has to be a borrow, and the borrowed bit came from the carry flag, which is now clear. It can also means the result of the subtraction is less than 0. It works the same way for compare instructions (although you don't have to set the carry flag before a compare instruction); for example, if you start with 7 in A, and do a CMP #9, 7 is less than 9, so the carry flag ends up clear, meaning there was a borrow. Here's an example for subtracting $361 from a 2-byte (ie, 16-bit) variable, and putting the result in the same variable:
Code:
    SEC                ; Set carry flag to start.  (This may be unwanted or unneeded
                       ; in a few situations.)
    LDA  VarLowByte    ; Get the low byte of your two-byte (ie, 16-bit) variable,
    SBC  #$61          ; subtract the low byte of your two-byte constant, and
    STA  VarLowByte    ; put the result back in the variable.
                       ; Now leave C alone.  The resulting C value from above gets
                       ; used in the SBC below.  If C=clear, the resulting high byte
                       ; below will be 1 less than it otherwise would have been.
    LDA  VarHighByte   ; Now get the high byte of your two-byte variable,
    SBC  #3            ; subtract the high byte of your two-byte constant, and
    STA  VarHighByte   ; put the result back in the variable.  At the end, C=clear
                       ; means the variable was less than $361 before you started.

If you wanted to only subtract 2, you can do that to the low byte and the use BCS to branch around the decrementing of the high byte, like this:
Code:
    SEC                ; Set carry flag to start (although this will be unwanted or unnecessary in some situations).
    LDA  VarLowByte    ; Get the low byte of your 2-byte variable.
    SBC  #2            ; Subtract 2,
    STA  VarLowByte    ; and put it back.
    BCS  1$            ; If the low byte started with at least 2, there was no need to borrow, so skip the DEC instruction.
    DEC  VarHighByte   ; Else, decrement the high byte to reflect that there was a borrow from it.
1$: <continue>

This is all described very clearly in the manual "Programming the 65816 including the 6502, 65C02, and 65802" by David Eyes and Ron Liechty. This is a .pdf file of what is definitely the best 65xx programming manual available, and a must-have for every 65xx programmer! It starts with the basics, followed by architecture, the CMOS 65c02's many improvements over the original NMOS 6502 including added instructions and addressing modes and fixing the NMOS's bugs and quirks, and then the natural progression to the 65816; a thorough tutorial, writing applications, then very detailed and diagrammed information on all 34 addressing modes, at least a page of very detailed description for each instruction, with info on every addressing mode available for that instruction, then instruction lists, tables, and groups, of all 255 active op codes (of the '816), plus more. 469 pages.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 04, 2017 7:53 pm 
Offline

Joined: Fri Jul 21, 2017 8:16 pm
Posts: 59
Thank you. I just print out the last pages of the 6502 manual. This information is missing in the 65C02 manual.
And I will start to print the first 40 pages of the programmers guide. Thanks for all the tipps.


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 05, 2017 6:39 pm 
Offline

Joined: Fri Jul 21, 2017 8:16 pm
Posts: 59
Hi,

I dont have a 10pF to connect the crystal to the 65c51. :shock:
Can I take another value?


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 05, 2017 6:51 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
No harm in trying different values -- anything under 50 pF, say. Or it might work with no cap at all. But if you run into quirky behavior then try to get a cap that's at least close to spec. Have fun! :)

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 05, 2017 7:13 pm 
Offline

Joined: Fri Jul 21, 2017 8:16 pm
Posts: 59
Thanks!
Currently I have a 100nF connected.
I get only dots ........... :oops:

I adapted a little program to write Hello to the ACIA in a loop:

========================
.alias ACIA $4080
.alias ACIA_DATA ACIA+0
.alias ACIA_STAT ACIA+1
.alias ACIA_COMM ACIA+2
.alias ACIA_CTRL ACIA+3

RESET: LDX #$FF
TXS
LDA #$00
LDX #$00
LDY #$00
STX ACIA_STAT
LDA ACIA_DATA
LDA #%00011110
STA ACIA_CTRL
LDA #%00001011
STA ACIA_COMM

START: LDY #$0

OUTPUT: LDA Hello,y
STA ACIA_DATA
CPY #5
INY
BNE OUTPUT
BEQ START

hello: .byte "HELLO", 0
========================

single stepping looks good.

I have certainly forgotten to connect some pins of the ACIA. Or the address decoding is not correct.
So I will have fun debugging! :-D


Terminal configuration: Cool Term - 9600 8-N-1


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 05, 2017 7:30 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
nei02 wrote:
Currently I have a 100nF connected.
nF? :shock: Or is that a typo?

nei02 wrote:
I get only dots ........... :oops:
Could be improper initialization (the software). Or maybe the crystal oscillator is off-frequency -- or not running at all. Better if we can narrow things down. Can you 'scope what the oscillator pins are doing? Or at least tell us the DC levels (as measured with a DMM, for instance)?

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 05, 2017 9:05 pm 
Offline

Joined: Fri Jul 21, 2017 8:16 pm
Posts: 59
Hello,
I have no Oscilloscope. Do I need one?
The Voltage at pins 6,7 is 2,65 Volts


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 05, 2017 9:17 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
nei02 wrote:
The Voltage at pins 6,7 is 2,65 Volts
IOW about 1/2 of the supply voltage (+5). And that is as it should be. (I'm looking for signs of trouble.) So, the oscillator is probably running.

But we're not sure if it's producing the correct frequency. A 'scope would reveal that. And maybe your DMM can. Does it have a frequency range? One with sufficient range to measure the oscillator frequency?

Please answer the question about nF versus pF.

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 138 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 10  Next

All times are UTC


Who is online

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