Page 5 of 10
Re: From 8bit breadboard to 6502
Posted: Fri Aug 04, 2017 6:34 am
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.
Re: From 8bit breadboard to 6502
Posted: Fri Aug 04, 2017 6:43 am
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.
Re: From 8bit breadboard to 6502
Posted: Fri Aug 04, 2017 6:56 am
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.
Re: From 8bit breadboard to 6502
Posted: Fri Aug 04, 2017 7:06 am
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.
Re: From 8bit breadboard to 6502
Posted: Fri Aug 04, 2017 7:37 am
by nei02
Re: From 8bit breadboard to 6502
Posted: Fri Aug 04, 2017 7:38 am
by BigEd
Good thinking!
Re: From 8bit breadboard to 6502
Posted: Fri Aug 04, 2017 7:41 am
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.
Re: From 8bit breadboard to 6502
Posted: Fri Aug 04, 2017 9:01 am
by GARTHWILSON
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.
Re: From 8bit breadboard to 6502
Posted: Fri Aug 04, 2017 7:53 pm
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.
Re: From 8bit breadboard to 6502
Posted: Sat Aug 05, 2017 6:39 pm
by nei02
Hi,
I dont have a 10pF to connect the crystal to the 65c51.
Can I take another value?
Re: From 8bit breadboard to 6502
Posted: Sat Aug 05, 2017 6:51 pm
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!

Re: From 8bit breadboard to 6502
Posted: Sat Aug 05, 2017 7:13 pm
by nei02
Thanks!
Currently I have a 100nF connected.
I get only dots ...........
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!
Terminal configuration: Cool Term - 9600 8-N-1
Re: From 8bit breadboard to 6502
Posted: Sat Aug 05, 2017 7:30 pm
by Dr Jefyll
Currently I have a 100nF connected.
nF?

Or is that a typo?
I get only dots ...........
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)?
Re: From 8bit breadboard to 6502
Posted: Sat Aug 05, 2017 9:05 pm
by nei02
Hello,
I have no Oscilloscope. Do I need one?
The Voltage at pins 6,7 is 2,65 Volts
Re: From 8bit breadboard to 6502
Posted: Sat Aug 05, 2017 9:17 pm
by Dr Jefyll
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.