6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 6:05 am

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Sat Jan 09, 2021 9:46 am 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 746
Location: Germany
Hi Everyone, i haven't been very active for some time due to RL stuff.
but i have still been slowly working on things.

last time i made a 65C02 from scratch in a Logic Simulator called Logisim, to better understand the hardware and potentially improve it.
but people pointed out that a lot of the improvements i wanted to add where already a thing in the 65816 and 65CE02... so that kinda killed that whole thing.

now i'm trying to do the same thing, but use the 65CE02 as the Base to improve upon.
I won't go into detail about what i want to add here, since i want to finish the whole CPU first before making a detailed thread about it.

my problem right now is that there are some things about the CPU that i have problems finding detailed information about...

for example, the ASW and ROW instructions.
in the Datasheet and on Wikipedia, ASW stands for "Arithmetic Shift left Word" while ROW stands for "ROtate left Word".
but there are other sites like commodore.ca and zimmers.net that say that ROW is "ROtate right Word".

so which one is correct? i would personally trust the offical Datasheet and Wikipedia more. but you can never be sure, and it doesn't hurt to ask.
(commodore.ca also seems to get the Addressing Mode (or AM) of INW and DEW wrong, it shows them as using the Absolute AM, but in the Datasheet they use the Base Page AM)

another thing that confuses me is the (D, SP), Y or "Stack Vector Indirect Indexed" AM.
more specifically does it behave differently depending on the mode that the SP is in?

for example, "LDA (0, SP), Y" (with Y = 0x00, SPH = 0x01, and SPL = 0xFF), loads the 2 bytes from 0x01FF and 0x01FF + 1.
with the 8 bit SP i would imagine that this would confine the data being loaded to the Page specified by SPH. so the 2 bytes are loaded from 0x01FF and 0x0100.
but with the 16 bit SP there is no reason to confine the AM to the current Page, as the Stack itself isn't either. so it would load the 2 bytes from 0x01FF and 0x0200.
Also i'm assuming that D is sign extended for the 16 bit SP, so that it reach both forwards and backwards from the SP. it doesn't matter for the 8 bit SP as it wraps around the Page anyways.

other than that i should be able to get the rest of the features working without issues. though if i still got any issues or questions i'll just ask them here in this thread.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 11, 2021 2:47 am 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
Proxy, I can offer you some thoughts, but most of them are only my own inferences.

Quote:
for example, the ASW and ROW instructions.
in the Datasheet and on Wikipedia, ASW stands for "Arithmetic Shift left Word" while ROW stands for "ROtate left Word".
but there are other sites like commodore.ca and zimmers.net that say that ROW is "ROtate right Word".

so which one is correct? i would personally trust the offical Datasheet and Wikipedia more. but you can never be sure, and it doesn't hurt to ask.
No opinion on this, I'm afraid. Indeed, the mystery only deepens when we notice that ASW ($CB) and ROW ($EB) seem to have different address modes. The datasheet's opcode matrix shows byte- and cycle-counts that tend to indicate Absolute and Base-Page, respectively.

Quote:
(commodore.ca also seems to get the Addressing Mode (or AM) of INW and DEW wrong, it shows them as using the Absolute AM, but in the Datasheet they use the Base Page AM)
Again based on the opcode matrix, INW ($E3) and DEW ($C3) show byte- and cycle-counts that tend to indicate Base-Page address mode. This matches the text, so the datasheet is at least self-consistent, which perhaps boosts its credibility.

Quote:
another thing that confuses me is the (D, SP), Y [...]
with the 8 bit SP i would imagine that this would confine the data being loaded to the Page specified by SPH. so the 2 bytes are loaded from 0x01FF and 0x0100.
Yes, 0x01FF and 0x0100 is what I would expect, too. They probably did whatever was easiest -- and that would be to let things wrap within the page.

Quote:
Also i'm assuming that D is sign extended for the 16 bit SP, so that it reach both forwards and backwards from the SP. it doesn't matter for the 8 bit SP as it wraps around the Page anyways.
Doubtful, IMO. That's because the region "under" the stack pointer is unusable due to the risk of getting trashed by interrupt activity. So, I expect that D is zero extended, not sign extended.

Hope this helps! I have a 65CE02, but I'm not set up for running experiments ATM.

-- Jeff

_________________
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: Mon Jan 11, 2021 9:13 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Just to note that Pavel Zima has been reverse engineering this chip, so might already have some answers.
Notes on reverse-engineering the 65ce02


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 11, 2021 5:26 pm 
Offline

Joined: Fri Apr 06, 2018 4:20 pm
Posts: 94
You could always ask the designer of the 4502/4510:

https://www.linkedin.com/in/victor-f-andrade-814822b/

He probably doesn't remember, but you never know :-)

Per the 4502 documentation another route to determine for sure would be to track down one of the cross assemblers and documentation and see what the instruction is documented as:

Code:
Several 4502 assembler systems are available:

       VAX, Amiga, and PC based BSO-compatible cross assemblers.

       PC based custom cross assembler by Memocom, compatible
       with Memocom 4502 emulator and Mem-ulator systems.

       C128-based BSO compatible cross assembler by Commodore.


Of course the hardest, but most definitive route would be to source an Amiga 2322 serial card, pop the 4502 out, breadboard it and try the instruction out yourself.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 11, 2021 8:08 pm 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 746
Location: Germany
The Datasheet for the C65 was more helpful than the actual CPU Datasheet, thanks for that BigEd!

Rotate Left Word seems to be right as even the C65 Datasheet says it. still weird that there are only Left Rotate/Shift instructions for words, do they just have more uses than Right Shifts/Rotates?

anyways, looking at both the 65CE02 and C65 Datasheets i see what you mean Dr Jefyll, the bytes for ROW don't match up with ASW even though they are supposed to use the same addressing mode. but what is especially confusing is that it's consistent throughout both documents. hmm not sure what to make of that.

the C65 Datasheet also mentions some stuff about the Stack Indexed AM, like Dr Jefyll suspected the "D" Value is not signed extended, though it says that the value is added to "the Stack Pointer (Word)" implying that even in the 8 bit SP Mode it would cross page boundaries? that just doesn't seem correct to me.
for now i'm going to leave it like i have it right now, it crosses the page when in 16 bit Mode, and otherwise wraps around.

and rpiguy2, if i had a 4502 i would probably just put it in a frame and hang it on my wall and not potentially damage it by trying to use it.

also i downloaded the C65 datasheet and made the text selectable, for potential future use. currently i only have it on my DropBox, but someone could upload it to archive.6502.org like done with the 65CE02 Datasheet.
https://www.dropbox.com/s/ptdnigg8548tmwr/C65%20System%20Specifications%20Preliminary%201991.pdf


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 11, 2021 8:53 pm 
Offline
User avatar

Joined: Mon May 12, 2014 6:18 pm
Posts: 365
rpiguy2 wrote:
Of course the hardest, but most definitive route would be to source an Amiga 2322 serial card, pop the 4502 out, breadboard it and try the instruction out yourself.
Small correction but make sure you search for 2232 not 2322 if you're like me and have an eBay search set for it :) They come up for sale now and then, though I've never been brave enough to take apart working retro hardware just for the chip. It would be cool if there were a non destructive way to play with one...

One thing you may already know is that SBC in decimal mode is supposedly bugged.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 11, 2021 9:33 pm 
Offline

Joined: Fri Apr 06, 2018 4:20 pm
Posts: 94
Druzyek wrote:
rpiguy2 wrote:
Of course the hardest, but most definitive route would be to source an Amiga 2322 serial card, pop the 4502 out, breadboard it and try the instruction out yourself.
Small correction but make sure you search for 2232 not 2322 if you're like me and have an eBay search set for it :) They come up for sale now and then, though I've never been brave enough to take apart working retro hardware just for the chip. It would be cool if there were a non destructive way to play with one...

One thing you may already know is that SBC in decimal mode is supposedly bugged.


Yes sorry it is 2232! I had the opportunity to pick one up years ago at a VCF show and passed on it and now I regret it. It was a later revision with a PLCC 4502 rather than DIP.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 11, 2021 10:16 pm 
Offline
User avatar

Joined: Sat Dec 01, 2018 1:53 pm
Posts: 730
Location: Tokyo, Japan
Proxy wrote:
currently i only have it on my DropBox, but someone could upload it to archive.6502.org like done with the 65CE02 Datasheet.
https://www.dropbox.com/s/ptdnigg8548tmwr/C65%20System%20Specifications%20Preliminary%201991.pdf

For what it's worth, the site seems to be in a Git repo on GitHub, so anybody with an account there should be able to add it to the repo and send a PR: https://github.com/6502org/6502.org

_________________
Curt J. Sampson - github.com/0cjs


Top
 Profile  
Reply with quote  
PostPosted: Sat Jun 05, 2021 10:27 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
(Note: I've just found some notes I'd made back in 2014, which for some reason I didn't post... this seems as good a thread as any. Please excuse that the content doesn't exactly follow on from the conversation here, but I think it's strongly related.)

I found a 1991 document ("System Specification for C65") describing a 4502 CPU core which might be the same one seen as the 65CE02 MPU. Is that the case?

The interesting thing about this 4502 is that it had an extension mode where the stack pointer is 16 bits. I hadn't seen that statement made about the 65CE02 - but now I see that's in the datasheet! (It also has PHZ/PLZ opcodes for the Z register.)

Quote:
The stack pointer has been expanded to 16 bits, but can be used in two different modes. It can be used as a full 16-bit (word) stack pointer, or as an 8-bit (byte) pointer whose stack page is programmable. On reset, the byte mode is selected with page 1 set as the stack page. This is done to make it fully 65CO2 compatible.


Quote:
TSY Transfer Stack Pointer High byte to Y register
and set "byte" stack-pointer mode
TYS Transfer Y register to Stack Pointer High byte
and set "word" stack-pointer mode


Quote:
The 4502 has the following 8 user registers:

A accumulator
X index-X
Y index-Y
Z index-Z

B Base-page
P Processor status
SP Stack pointer
PC Program counter


From the C65 doc:
Quote:
Microcontroller: 4510 (65CE02, 2x6526, 6511 UART, Mapper,
Fast serial)


From Michael's doc, and for interest:
Code:
   The following chart shows a part of the 65xx CPU evolution timeline:

           NEC      MOS   WDC
     
   1975             6502
                      \
                       \
                        \
   1981[7]              65C02
                        /  |
                       /   |
   ????        ?GTE65SC02? |
   1984[7]         / |   65816
                  /  |    /?
   1986     HuC6280  |   /?
   1990            65CE02

   Annotations:
    65C02:   referred to as "Rockwell" in [1] (Rockwell was a popular
             licensee of the 65C02)
    65CE02:  the C64 preliminary documentation has been written in January 1991


(There are some physical 65CE02s around, but I believe it was never sold as a component. It can be found in the Amiga 2232 serial card)

References:
65CE02 datasheet (preliminary) from 1988
65CE02 opcodes by Graham of oxyron, 2009
Commodore Semiconductor Group CSG65CE02 Technical Reference by Michael Steil
Quote:
The CSG65CE02 is a CPU core developed by Commodore Semiconductor Group
(formerly known as Commodore MOS) that has been used in the CSG4510
micro controller (that combined a CPU and several I/O components) in
the Commodore C64DX/C65. Although the Commodore C64DX/C65 has never been
released, several hundred test/demo machines appeared on the market in 1994.


System Specification for C65 by Fred Bowen, 1991
(Also found in a flat file here.)

Via two contemporary threads on the LLVMdev mailing list where Edwin Amsler is embarking on a 6502 target:
http://lists.cs.uiuc.edu/pipermail/llvm ... html#74472
http://lists.cs.uiuc.edu/pipermail/llvm ... html#74523
(LLVM being a modern open-source framework for C compilers, among other things.)


Top
 Profile  
Reply with quote  
PostPosted: Sat Jun 05, 2021 6:31 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
The 65CE02 data sheet is on this site too, at http://6502.org/documents/datasheets/mo ... 02_mpu.pdf .

_________________
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: Sat Jun 05, 2021 8:37 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8514
Location: Midwestern USA
Dr Jefyll wrote:
I have a 65CE02, but I'm not set up for running experiments ATM.

Guard that thing with your life! A genuine 65CE02 is rarer than an honest politician. Like taking a 1950s-era Corvette out for a drive on a busy highway during rush hour, I'd be afraid to even power that thing. :D

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


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

All times are UTC


Who is online

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