From 8bit breadboard to 6502

Building your first 6502-based project? We'll help you get started here.
Post Reply
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: From 8bit breadboard to 6502

Post by BigEd »

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.
nei02
Posts: 59
Joined: 21 Jul 2017

Re: From 8bit breadboard to 6502

Post by nei02 »

"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.
nei02
Posts: 59
Joined: 21 Jul 2017

Re: From 8bit breadboard to 6502

Post by nei02 »

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
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: From 8bit breadboard to 6502

Post by BigEd »

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.
nei02
Posts: 59
Joined: 21 Jul 2017

Re: From 8bit breadboard to 6502

Post by nei02 »

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
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: From 8bit breadboard to 6502

Post by BigEd »

Good thinking!
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: From 8bit breadboard to 6502

Post by BigEd »

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.
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: From 8bit breadboard to 6502

Post by GARTHWILSON »

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: Select all

    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: Select all

    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?
nei02
Posts: 59
Joined: 21 Jul 2017

Re: From 8bit breadboard to 6502

Post by nei02 »

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.
nei02
Posts: 59
Joined: 21 Jul 2017

Re: From 8bit breadboard to 6502

Post by nei02 »

Hi,

I dont have a 10pF to connect the crystal to the 65c51. :shock:
Can I take another value?
User avatar
Dr Jefyll
Posts: 3526
Joined: 11 Dec 2009
Location: Ontario, Canada
Contact:

Re: From 8bit breadboard to 6502

Post by Dr Jefyll »

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
nei02
Posts: 59
Joined: 21 Jul 2017

Re: From 8bit breadboard to 6502

Post by nei02 »

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
User avatar
Dr Jefyll
Posts: 3526
Joined: 11 Dec 2009
Location: Ontario, Canada
Contact:

Re: From 8bit breadboard to 6502

Post by Dr Jefyll »

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
nei02
Posts: 59
Joined: 21 Jul 2017

Re: From 8bit breadboard to 6502

Post by nei02 »

Hello,
I have no Oscilloscope. Do I need one?
The Voltage at pins 6,7 is 2,65 Volts
User avatar
Dr Jefyll
Posts: 3526
Joined: 11 Dec 2009
Location: Ontario, Canada
Contact:

Re: From 8bit breadboard to 6502

Post by Dr Jefyll »

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
Post Reply