6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 16, 2024 10:38 am

All times are UTC




Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
PostPosted: Fri Aug 17, 2018 7:02 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
This is slightly OT, as it's not my own idea. But in the realm of enhancements which *did* get implemented, I think the T Flag (a new bit in the Processor status register, included in the Hudson Soft HuC6280 and certain other CPU's) is worth remarking. From this post in the thread 65x02 variants:
Quote:
When the T flag is set, the accumulator is replaced with a zero page memory location indexed by the X register. The operation defined by the instruction is performed using the memory location as one operand, and the effective address as the other. The result is stored in the memory location, leaving the accumulator undisturbed.

_________________
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: Fri Aug 17, 2018 7:05 pm 
Offline

Joined: Wed Oct 06, 2010 9:05 am
Posts: 95
Location: Palma, Spain
I thought the 65CE02 completed the opcode set in a very elegant way, by adding a Z index register, a movable base page, a 16-bit wide SP, and other niceties such as relative and indirect JSR, an ASR operation and the new stack addressing mode. Not sure if it was maybe a little complex to have been possible in the early 80s though. It's certainly a shame it never took off.

As for how I wouldn't extend it, it eludes me to this day why TSB and TRB were considered worth adding. I assume the designers had some very specific use-case in mind, but I've only ever found use for TSB (as a marginally quicker way of doing LDA/ORA/STA) and even then its lack of addressing modes make it relatively useless.


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 17, 2018 7:42 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
RichTW wrote:
I thought the 65CE02 completed the opcode set in a very elegant way, by adding a Z index register, a movable base page, a 16-bit wide SP, and other niceties such as relative and indirect JSR, an ASR operation and the new stack addressing mode. Not sure if it was maybe a little complex to have been possible in the early 80s though. It's certainly a shame it never took off.

Yes, what a shame. I wonder how many were made. I have a couple of them here. Again though, the '816 has most of that, and more.

Quote:
As for how I wouldn't extend it, it eludes me to this day why TSB and TRB were considered worth adding. I assume the designers had some very specific use-case in mind, but I've only ever found use for TSB (as a marginally quicker way of doing LDA/ORA/STA) and even then its lack of addressing modes make it relatively useless.

Here's one of my uses of TSB & TRB, in a subroutine to bit-bang a byte on SPI:
Code:
SEND_BYT:
    PHA                       ; The input number will get shifted and rotated while on the stack.
        CLK_DN                ; (CLK_DN leaves A=1)
        TSX
        INA                   ; Turns the 1 above into the 2 needed for the mask for TSB/TRB below.
        SEC                   ; Set a "9th bit" which is only used to know when to quit looping.
        ROL  101,X
        BEGIN
            IF_CARRY_SET
               TSB  VIA3PB
            ELSE
               TRB  VIA3PB
            END_IF
            CLK_HI_PULSE
            ASL  101,X
        UNTIL_ZERO
    PLA
    RTS
 ;------------------

Macros used above are:
Code:
CLK_DN: MACRO                 ; NOTE!  Accum is not preserved!
        LDA  #1
        TRB  VIA3PB
        ENDM
 ;------------------

CLK_HI_PULSE: MACRO           ; NOTE!  Clock must already be known to be low!
         INC  VIA3PB
         DEC  VIA3PB
         ENDM
 ;------------------

(plus the program flow control structure macros which are pretty obvious).

I might prefer if BBS, BBR, SMB, and RMB were absolute rather than ZP, since they have by far their greatest usefulness in I/O, which is almost never in ZP. I take it Rockwell added them for their microcontrollers which had limited memory and putting I/O in ZP made their I/O-intensive programs shorter since ZP addressing saves a byte each time.

_________________
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 17, 2018 7:47 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
Oh yeah, the 'ce02 was very cool IMO! I'm disappointed that I forgot about it. When I think of TSB and TRB, I automatically think of semaphores.

_________________
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 17, 2018 9:17 pm 
Offline

Joined: Tue Nov 10, 2015 5:46 am
Posts: 230
Location: Kent, UK
I do like the 10-bit or 12-bit word suggestion. It would have been a bold departure from the norm and would have raised some eyebrows for sure. 10 bits with a 20-bit address bus would have required 6 more pins - blowing out of the 40-pin package. I wonder if it would have been possible, at the time, to have a 10-bit +RAS+CAS bus instead... I guess that's only good for DRAMs and not for I/O devices... But maybe some games would have been possible there.

A nice bit of out-of-box (byte?) thinking!


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 17, 2018 9:52 pm 
Offline
User avatar

Joined: Tue Oct 25, 2016 8:56 pm
Posts: 362
In addition to thread- and/or interrupt-safe semaphores, you could also use TSB/TRB to check interrupt (and similar) flags in an I/O register at the same time as clearing them.

_________________
Want to design a PCB for your project? I strongly recommend KiCad. Its free, its multiplatform, and its easy to learn!
Also, I maintain KiCad libraries of Retro Computing and Arduino components you might find useful.


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 18, 2018 2:54 am 
Offline
User avatar

Joined: Wed Mar 01, 2017 8:54 pm
Posts: 660
Location: North-Germany
As Garth already posted this sort of question and the following "discussion" had happened frequently - everytime with much emotion as we're all in love with this little beast and its limitations and we all dream of Sweet16 or more :D

Acting a little bit as an Advocatus Diaboli :twisted: I take your introduction a bit more literally:
Alarm Siren wrote:
For the purposes of this discussion, imagine you are in circa 1980, and that the 65C02, 65816, and all the other subsequent extensions are variants do not exist. The 6502 has been a smashing success, but its time to give it a backwards-compatible upgrade. How would you upgrade it? What modes, instructions, extra pins, etc would you give it? 16 bit? 32 bit? hybrid? Stack? Movable direct page? more registers? Why?

Well I could remember that time but I took a look into some old Byte magazines to recall the RAM situation and the prices of the CPU and I/O circuitry. In 1980 a 6502 costs about 6..10$, a 6502A twice as much, Z80A in between, MC6809 <40$. Static RAM was 1Kx4 (5$) and 16Kx1 dynamic RAMs becomes payable (8 pcs. 50$). Beside the MC6809 the MC68000, the Z8000, and the i8086/88 appears in the advertising (seldom as chips, usually on cards or as a system) - any of them really expensive.

Now, if you emphase the backwards-compatibility then this could only mean the upgrade requires to be transparent under all circumstances - even for the usage of unimplemented opcodes. Then things becomes very difficult, as any improvement within the CPU architecture could change the behaviour of these "illegal" opcodes. Is it acceptable to repair the JMP [indirect] bug? That repair could cause incompatibilities!

Staying compatible means leaving all bugs untouched. Then only the twelve so-called "KIL" instructions are free as they most likely never used intentionally. Further there are a few more NOPs ($1A, $3A, $5A, $7A, $DA, $FA) that may be usable as well. This would allow to implement 18 new opcodes. Some welcomed extensions like PHX, PLX, PHY, PLY, SWP (nibble swap), INC A, and DEC A were possible. A further addressing mode like (ZP) without index would eat up 8 opcodes (ADC/AND/CMP/EOR/LDA/ORA/SBC/STA) leaving no room for goodies like BRA/LBRA, BSR/LBSR :( Kicking SWP (sorry, Daryl) would allow the latter four but nothing else.

Of course, dropping INC/DEC A would allow to implement two different prebytes to extend the opcode map ad infinitum :wink:

But implementing these additions without affecting the original behaviour appears to me as a very costly adventure. It would probably require much more silicon to implement that around (outside) the core than to enhance the core with the risk of altering the behaviour of some "illegal" opcodes. Beside the NRE costs - assuming it would increase the chip size somewhere between 50..100% this would double the market price - for gaining what benfit in terms of speed?

A different approach could be just to use one "KIL" opc to implement a "BOOST" function: turning on the 65org16. Then 8 bits becomes 16 bits everywhere. (=> a "page" is then 65K x 16bit, an absolute address covers 2^32 16bit "bytes", ...). Perhaps it would be possible to rearrange the core in a way that all these upper 8 bits are ignored/untouched unless boosted, this may roughly double the required transistors. Again the chip could perhaps require not more than twice the area.

The 16 additional address lines plus 8 additional data lines would just fit into a 64 pin package - :shock:
or you may use 1 of the 3 "NC" pins to multiplex the address bus and another "NC" pin to select high or low byte access as a secondary multiplexing for the data. (This would cost an additional cycle - :evil: ).

Would anyone in 1980 buy such a CPU paying twice or more money for just staying compatible and then having to double all RAM/ROM (and perhaps I/O) to use the booster - meaning new hardware, not something to plug in? In the dawn of the new 16bit CPUs mentioned above I have my doubts.


my 2 cents


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 18, 2018 9:30 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10980
Location: England
I'd have to take a different line on the opcodes - the point of a spec is to say what happens. Things outside the spec are not normally part of a backward compatibility claim. So, all those unspecified opcodes are certainly up for grabs. This is why no-one who used them should have any expectation of portability or future support.

The only good reason to soften this line is when some economically important use is made of undocumented behaviour - it may be time to make it part of the spec. Suppose for example VisiCalc used one or two of the undocumented opcodes - that would be important.

It's worth noting though that there are different levels of claim for backward compatibility. There's pin-compatible, binary-compatible, and source-code compatible, at least. And even with pin-compatible, it could be totally compatible or mostly compatible.

So we do have some wiggle room.


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 18, 2018 11:22 am 
Offline
User avatar

Joined: Tue Oct 25, 2016 8:56 pm
Posts: 362
Whilst I totally see your point GaBuZoMeu, and it is an interesting discussion, I have to agree with BigEd that behaviour outside of the official specification, or unintentional bugs that cause deviation from that specification, are outside what I would call necessary for "backward-compatibility". Yes, sometimes a widely used but officially undefined behaviour is backported into a specification (I'm looking at you, C/C++) but I consider that an exception rather than the norm.

---

There's certainly been many interesting suggestions in this thread. I like the 10-bit bytes idea, though I'm not sure that it would have been practical in terms of memory ICs, even in 1980. I do like some features of both the 65CE02 and the 6809, but I also dislike each of them for one reason or another. :?

---

I was thinking about this myself a few months ago (april) and this is what I came up with:
Attachment:
File comment: Opcode Map
opcode map.png
opcode map.png [ 57.13 KiB | Viewed 3629 times ]


Green is all the original 6502 instructions (the backwards compatibility part), Yellow are 65C02, blue 65C816 and Orange are instructions of my own design.

There are two new registers: B, a secondary accumulator, and W, the Working Page pointer (equivalent to the Direct Page register in 65816). All zero-page instructions are replaced with equivalent instructions indexed by W. Instructions for B are added, including XBA, all the RMW instructions and some LD/ST instructions. No, B is not as flexible as A, but its not really meant to be - it is secondary afterall. JMP and JSR using (#, S) address mode added to support passing function pointers on the stack.
The P register has two new flags at bits 4 and 5: U and E respectively. If bit E is clear (which is the default on reset) then incompatible extensions are switched off - BRK shares its vector with IRQ, and the U bit behaves as the B bit does in 6502, and the SO pin messes with V. If bit E is set then BRK has its own vector, and the U flag mirrors value input on the SO pin. There are two new branch instructions, BUC and BUS, for the U flag.
Unfortunately I cannot remember what PLG, PHG and PEC where supposed to do.
The chip would be pin-compatible with the 65C02.

_________________
Want to design a PCB for your project? I strongly recommend KiCad. Its free, its multiplatform, and its easy to learn!
Also, I maintain KiCad libraries of Retro Computing and Arduino components you might find useful.


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 18, 2018 11:32 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10980
Location: England
Alarm Siren wrote:
Unfortunately I cannot remember what PLG, PHG and PEC where supposed to do.

There's a challenge then!

I would guess that PLG and PHG need to push and pull some state: how about General state: they could push and pull A, B, X, Y, W, maybe P. For some kind of task switch, perhaps.

Whereas PEC looks like it should be a bit like PEA, PEI, PER which Bruce describes thus:
Quote:
PEA, PEI, and PER all push a 16-bit value onto the stack. In fact, they could be thought of as the different addressing modes of the same instruction, since the operation is otherwise the same


So, PEC needs to push something 16-bit flavoured. How about the concatenation of A and B?

I'm sure other guesses can be made, and I'd be interested to see them...


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 18, 2018 4:52 pm 
Offline

Joined: Fri Apr 06, 2018 4:20 pm
Posts: 94
sark02 wrote:
I do like the 10-bit or 12-bit word suggestion. It would have been a bold departure from the norm and would have raised some eyebrows for sure. 10 bits with a 20-bit address bus would have required 6 more pins - blowing out of the 40-pin package. I wonder if it would have been possible, at the time, to have a 10-bit +RAS+CAS bus instead... I guess that's only good for DRAMs and not for I/O devices... But maybe some games would have been possible there.

A nice bit of out-of-box (byte?) thinking!


6 more pins is perfectly doable, the 6510 added a 6 pin port to the 6502 and still shipped in a 40 pin package, just depends on what you can live without.

30 pins for address and data, plus PWR, GRD, Clk still leaves 7 pins for RDY, NMI, etc.


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 18, 2018 6:39 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
rpiguy2 wrote:
30 pins for address and data, plus PWR, GRD, Clk still leaves 7 pins for RDY, NMI, etc.

WDC's W65C02S
  • still leaves pins 35 as "NC" (is it used for testing?)
  • still has SO\ which nobody but Dr Jefyll is using (but he uses it very effectively!)
  • Φ1 and Φ2 out, which WDC no longer tests or recommends using
  • takes away the pin-1 ground for a VP\ (vector-pull not) output
  • uses pin 36 for a BE (bus-enable) input
  • uses pin 5 for a ML\ (memory-lock not) output

It would be nice to have the 816's VDA and VPA in place of the 6502's SYNC output which is on pin 7. This add another pin (VDA & VPA, as opposed to only SYNC).

If we make these adjustments, we have:
  • Φ2 in
  • R/W
  • VDA
  • VPA
  • IRQ\
  • NMI\
  • RST\
  • ML\
  • BE
  • VP\
  • SO\ (??)
  • GND (There ought to be two of these, one in the middle of each row of pins.)
  • VDD (There ought to be two of these, one next to each ground pin above.)

If there are 30 address and data lines, the above makes for 45 pins. We could forgo one of the VDD's and fit it all in a 44-pin DIP.

_________________
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 Aug 18, 2018 6:51 pm 
Offline
User avatar

Joined: Tue Oct 25, 2016 8:56 pm
Posts: 362
BigEd wrote:
I would guess that PLG and PHG need to push and pull some state: how about General state: they could push and pull A, B, X, Y, W, maybe P. For some kind of task switch, perhaps.

As good a guess as any, but I honestly have no idea! Certainly a useful instruction to decrease interrupt latency even further.

BigEd wrote:
Whereas PEC looks like it should be a bit like PEA, PEI, PER which Bruce describes thus:
Quote:
PEA, PEI, and PER all push a 16-bit value onto the stack. In fact, they could be thought of as the different addressing modes of the same instruction, since the operation is otherwise the same


So, PEC needs to push something 16-bit flavoured. How about the concatenation of A and B?

I'm sure other guesses can be made, and I'd be interested to see them...

I think it might have been an 8-bit version of PEA, a Push Constant if you will.

_________________
Want to design a PCB for your project? I strongly recommend KiCad. Its free, its multiplatform, and its easy to learn!
Also, I maintain KiCad libraries of Retro Computing and Arduino components you might find useful.


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 18, 2018 7:02 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10980
Location: England
I'd be tempted not to have all of VPA, VDA, VP. I might for example have a SYNC pin which outputs two bits of state, one in each phase. That might allow for signalling vector pull, fetch, normal access, dummy access, for example.


Top
 Profile  
Reply with quote  
PostPosted: Sun Aug 19, 2018 6:09 pm 
Offline

Joined: Tue Nov 10, 2015 5:46 am
Posts: 230
Location: Kent, UK
You could appropriate the following 6 pins from the original 6502 for D8-D9/A16-A19:
  • 3 no-connects
  • PHI1_OUT and PHI2_OUT
  • The 2nd VSS
You lose the 65C02 pins: VBP (previously VSS), /ML (previously PHI1_OUT), and BE (previously N.C), but these didn't exist in 1980, so they would not have been missed.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC


Who is online

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