6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue Jun 04, 2024 1:40 pm

All times are UTC




Post new topic Reply to topic  [ 91 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7  Next
Author Message
PostPosted: Thu Jun 01, 2023 2:44 am 
Offline
User avatar

Joined: Sat Dec 01, 2018 1:53 pm
Posts: 727
Location: Tokyo, Japan
BigDumbDinosaur wrote:
I don’t find all topics here to be of interest, but I do read just about everything that is posted, even stuff about Forth. :D There is always a possibility that I will read something that will be useful to me at some point.

Which is fair enough. But this seems to guarantee you will be reading topics on which you're not interested. Everybody understands that not everybody finds every topic interesting already, so your contribution to particular topics that you don't find them interesting seems to me redundant, at best. What is the point of posting such statements? How is it useful to anybody else?

In this particular case you did bring up a good point that often the people involved with asking the sorts of questions heading this thread are inexperienced and it isn't obvious to them why some ideas that seem good to them weren't implemented. But that's the exact point of these discussions: to raise these questions and educate people on what they're missing about the 6502 design.

If you have good arguments to make about that (and mind you, I, and probably others, do seem to agree that that argument is generally correct), you should make them. Or, if these arguments have been made before, you should feel free to point them out.

But simply to say that you don't find a particular topic interesting doesn't seem to do any good for anybody but, perhaps, you. One can go back through previous topics on the forum and pretty easily find out what BDD is and is not interested in; repeating it again and again is just...repetitive. If you're truly interested in not "[wasting] forum server storage capacity and bandwidth," perhaps you might start there where you can do something yourself to avoid increasing that even more.

TLDR: If you have something to contribute that helps the discussion, do so. If you don't, contributing "I'm not interested in this" doesn't seem helpful in any way. It would be worth considering, after you've written a post and before clicking the "Submit" button, what parts of it aren't contributing to the discussion and remove them. If that leaves nothing left to post, so much the better for server capacity and storage space and, more importantly, the amount of time other people spend reading and responding to posts.

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


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 01, 2023 3:53 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8198
Location: Midwestern USA
wayfarer wrote:
I get a lot out of different discussions, as someone who knows almost nothing about 6502 assembly, I learned that the stack works entirely differently than expected and if it performs as you seem to say it does the relocatable stack on the 65816 is terribly powerful for data transfer.

It goes beyond that.

One of the most useful programming idioms with the 65C816 is pointing direct page at the stack, viz:

Code:
         phd                   ;preserve DP
         rep #%00110000        ;16-bit registers
         sec
         tsc                   ;SP ——> .C
         sbc !#6               ;reserve 3 words on stack
         tcs                   ;.C ——> SP
         inc A                 ;SP + 1
         tcd                   ;.C ——> DP...
;
;         —————————————————————————————————————————
;         Now direct page is actually on the stack,
;         starting at SP + 1.  Instead of using
;         stack-relative addressing, we can use
;         faster & more convenient direct page
;         addressing.
;         —————————————————————————————————————————
;
         lda $00               ;this is actually loading from SP + 1
         ldx $02               ;this is actually loading from SP + 3
         ldy $04               ;this is actually loading from SP + 5

         ... do some processing ...

         clc
         tsc                   ;SP ——> .C
         adc !#6               ;dispose of workspace
         tcs                   ;.C ——> SP
         pld                   ;restore DP

         ... program continues ...

In the above code, which I would typically use in a subroutine that needs some temporary workspace, I “steal” six bytes from the stack. Upon exit, the stolen stack space is returned and the caller is none the wiser. I’ve got this sort of thing all over the place in my programs.

Being able to treat stack space as direct page opens the door to far more addressing modes than available with stack-relative addressing, and in fact is one of the primary reasons the 816 is a much better compiler target than the 65C02 (more address space helps as well). Programming techniques that are only implemented with great difficulty with the 65C02 become very practical with the 816. For example, it is possible to use words or double words pushed to the stack as pointers, using (<dp>) or [<dp>] addressing modes. Worth reading is Garth’s write-up on his site about synthesizing 65C816-specific stack instructions on the 65C02—it’s very instructive to see how much hoop-jumping is involved, and why we promote the use of the 816 in new designs.

Idioms such as the above code fragment, along with such things as generating run-time relative addresses (the PER instruction), are why I have often said getting the most out of the 816 requires treating it as a different beast than its eight-bit cousins.

Quote:
this is a great topic to better understand why the 6502 is what it is.

Every MPU has its backstory. The 6502 was born from the desire by Chuck Peddle to make an MPU that didn’t cost an arm-and-leg. He and his team took an existing design, the MC6800, kept the features thought to be desirable, excised the ones that weren't, added some new ones, and came up with what turned out to be a world-beater. Motorola could have accomplished the same thing, but had too much corporate inertia to react to changing market conditions, and lacked executives with vision.

I’ve never had much interest in what goes on inside most chips, aside from how the outputs behave as a result of driving the inputs. Digging into the intricacies of the 6502 internal circuits is something I’d do only if my objective were to design and produce an improved version...which leads to what I think is an important point.

Almost all people who drive automobiles have absolutely no understanding of what goes on inside an automatic transmission. They wouldn’t know a planet carrier or sprag clutch if one hit them in the forehead. Despite that, almost anyone can drive a car...with varying degrees of skill. :D It’s the same with MPUs. You don’t need to know anything about what is going on inside the 6502 to be able to write programs. It wasn't until fairly recently that I gained any knowledge about how MPUs internally operate.

I’ve been writing 6502 assembly language since the mid-1970s and cannot ever recall where knowing what those transistors are up to would have been helpful in developing software. What mattered was how the system reacted to the instructions I gave it. So I seldom bother my head about hardware internals...another way of saying I really don’t care. My main hardware interest is how to design a circuit that produces desired results. I leave the chip intricacies to the folks who make a living from etching silicon.

Ultimately, you will learn far more about using and programming the 6502 by studying others’ homebrew computer circuits and the code they’ve written to make them run, as well as by writing and testing your own programs.

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


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 01, 2023 7:47 pm 
Offline
User avatar

Joined: Sat Dec 01, 2018 1:53 pm
Posts: 727
Location: Tokyo, Japan
BigDumbDinosaur wrote:
One of the most useful programming idioms with the 65C816 is pointing direct page at the stack, viz:

Code:
         lda $00               ;this is actually loading from SP + 1

Sure, by why not just, LDA SP,1 instead, just like you'd do on the 6809, six years before the 65816 came out? Then you don't have to worry about setting the direct page, and you also have one less byte to read from memory.

Quote:
Every MPU has its backstory. The 6502 was born from the desire by Chuck Peddle to make an MPU that didn’t cost an arm-and-leg. He and his team took an existing design, the MC6800, kept the features thought to be desirable, excised the ones that weren't, added some new ones, and came up with what turned out to be a world-beater. Motorola could have accomplished the same thing, but had too much corporate inertia to react to changing market conditions, and lacked executives with vision.

So totally failing to make inroads into the huge automotive MCU market that Motorola did so well in is a "world-beater"? The 6502 certainly did much better in the much smaller personal computer market, but even Commodore managed to sell only a few tens of millions of units there throughout more than a decade.

It's fair to say that Motorola totally missed the boat in 8-bit personal computer processors between about '74 and the mid-80s, but then again, MOS and WDC did the same in the 16-bit market from '81 to '91. And Motorola's reluctance is not just obtuseness on the part of management: while the 6502 was selling a hundred thousand or more CPUs per year, Motorola did happen to be a bit busy selling nearly the same number of MCUs every month during that time.

Heck, even Commodore themselves, despite owning MOS, gave up on the 6502 family and switched to 68000 for the Amiga in 1985.

Quote:
Ultimately, you will learn far more about using and programming the 6502 by studying others’ homebrew computer circuits and the code they’ve written to make them run, as well as by writing and testing your own programs.

True, but you will learn that only about using and programming that CPU, and not why the in most ways technically better (in the late '70s, anyway) 65xx and its progeny was, in terms of units shipped, utterly eclipsed by the 68xx series from the start.

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


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 01, 2023 7:59 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8453
Location: Southern California
There's been too much activity here for me to have time to answer everything; but Curt, the 65c02 seems to have gone into millions of cars, at the heart of ASICs, licensed by WDC.  I don't think it missed the automotive market at all.

_________________
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: Thu Jun 01, 2023 8:12 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8198
Location: Midwestern USA
cjs wrote:
BigDumbDinosaur wrote:
One of the most useful programming idioms with the 65C816 is pointing direct page at the stack, viz:

Code:
         lda $00               ;this is actually loading from SP + 1

Sure, by why not just, LDA SP,1 instead, just like you'd do on the 6809, six years before the 65816 came out?

And your point is...what? My example was meant to highlight a feature if the 65C816. How did the 6809 get into the discussion?

Quote:
Then you don't have to worry about setting the direct page, and you also have one less byte to read from memory.

I think you missed something from my example. Once I’ve pointed direct page to the stack, I can use stack RAM to set up pointers and then do something like LDA [$00],Y, which conceptually is LDA [(SP+1)],Y. Of course, such an addressing mode doesn’t exist, but the 816 makes it seem like it does.

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


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 01, 2023 11:07 pm 
Offline
Site Admin
User avatar

Joined: Fri Aug 30, 2002 1:08 am
Posts: 280
Location: Northern California
GARTHWILSON wrote:
There's been too much activity here for me to have time to answer everything; but Curt, the 65c02 seems to have gone into millions of cars, at the heart of ASICs, licensed by WDC. I don't think it missed the automotive market at all.

As Garth already mentioned, I found one in my own car. I believe the same chip was used in a lot of Volkswagen instrument clusters for several years. I just stumbled on it when I decapped the chip, so there could be more hiding in other cars.

BigDumbDinosaur wrote:
And your point is...what? My example was meant to highlight a feature if the 65C816. How did the 6809 get into the discussion?

This thread started as and still is about what could have been done differently with the 6502. In the context of this thread, I read your post as "this addressing mode of the 65C816 is useful" and Curt's post as "this addressing mode of the 6809 is another good one".

Related to Motorola, I've thought several times that it would be handy if the 6502 had a 16-bit index register like on the 6800. Since the original 6502 team came from that project, they may have considered it. Even though I occasionally think it would be nice to have additional features, I like programming the original 6502 and I think the team made great decisions for the time.

_________________
- Mike Naberezny (mike@naberezny.com) http://6502.org


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 02, 2023 5:34 am 
Offline
User avatar

Joined: Sat Dec 01, 2018 1:53 pm
Posts: 727
Location: Tokyo, Japan
First, I'd like to remind everybody that not doing as well as competitors in a particular market does not make a processor bad. There are a lot of other things beyond the processor itself that influence who buys what, and in fact in the MCU market a CPU's architecture is often pretty low on the list of things that customers consider when choosing which one to buy. (And even in the PC market from the '90s onward: how seriously did you consider a RISC-V for your next desktop machine, and how many Mac users considered switching away at any of the numerous CPU changes that Apple made?)

So please try not to get upset about areas where the 6502 was not a huge winner. It's not about the 6502 itself, in most cases.

GARTHWILSON wrote:
....the 65c02 seems to have gone into millions of cars, at the heart of ASICs, licensed by WDC.  I don't think it missed the automotive market at all.

"Millions" is not a lot, in the automotive industry: in 1985 Delco Electronics was buying more than a million Motorola MPUs every two weeks (see below). To get a sense of the scale of this compared to what we're used to talking about in this forum, in about six months in 1985, Motorola sold more MCUs to one company than the total number of 6502 computers Commodore sold throughout its lifetime.

From all the data I have, the 6502 did "miss" the auto market compared to the 6800, at least for the first decade or more. This is borne out not only by the discussions below, but also the MOS catalogues: you'll note the lack of MCUs (which were the biggest seller into automotive and other embedded applications) whereas the 6801, 6805, 68HC05, and 68HC11 are front and centre not just in Motorola's MCU catalogues, but even in their CPU catalogues.

(And note also that, at least to my understanding, by the '90s or '2000s, the 8051 family had pulled well past the 6800 family for total sales, which would put the 6502 in third place, at best.)

Have a read of Motorola 6800 oral history panel : development and promotion to get a sense of how important the auto and other embedded markets were to Motorola. From that it appears that Motorola had GM (at that time the largest auto manufacturer in the world) and many of GM's suppliers basically locked up from '74 to at least the late '70s, and probably a good chunk of the Japanese market too (early on Hitachi pushed hard to become a second source for the 6800), though I don't know how much of the Japanese market went with Z80 instead (which had both NEC and Sharp second sourcing it, albeit not starting until several years after the 6800 got into that market). Not only did 6502 miss GM, it wasn't anywhere in Japan at all until the mid-80s when it was finally selected for the Famicom (ironically, because it was essentially unknown in Japan, even to microcomputer and embedded engineers, and so Nintendo thought that would help reduce piracy or something like that). The article also discusses pagers and cellphone products as being huge markets.

Here's a key bit, from page 23:
Quote:
LaVell: And then they worked on this implementation of this, what ultimately turned out to be the 68HC05, which is a low-power variation of the 05. And that was designed into pagers. They shipped that in December of 1979, and the production rate went to the millions. I tell ya, we were shipping a lot of pagers. And the cellular phone guys picked that up. So these were all internal products. But they jumped up in the multi-millions very quickly. So you link the automotive stuff together with that, and I was talking to Walt Davis last night, and we were trying to find some articles, published articles on the volumes of the 6800 family variants. And the published data is around eight to nine billion units that have been shipped in total. It depends on how you group things together. Walt thought he had seen some numbers in the 12 billion range. But there have been quite a few units shipped.

Laws: Extraordinary numbers. A long way from the initial forecast of 18,000 units, I think we started the conversation, what in 1970?

Bennett: In 1985, I think about that timeframe, Delco Electronics alone was using 105,000 microprocessors per day.

Bennett: That was like 25,000 of the engine control systems, and the rest were these smaller, 6805-type products that the automobile people wanted as individual controllers. They don’t want things lumped together, and stuff going to them. So, they’ll design this little thing, and maybe the part’s only 20 percent efficient, but that’s the way they want it.

Laws: Average car today has how many controllers, 40, 50, 60 probably?

Bennett: Probably at least. But no, it -- once we got in there with that Seville, it showed them that that product would work, and they understood what the architecture of the chips were. We pretty [much] in my mind we had the next generation pretty much locked up. Because I had the key people at GM helping me.

They later go on to mention that Bill Mensch was talking at the time (2008 or so) that about five billion 6502 devices had shipped. (And keep in mind that Mensch had a financial interest in having a good figure there, whereas the folks doing the 6800 family calculations above no longer did.) So overall a good runner up, at 50-60% of the 68xx family figures, but still well behind. (And, as I mentioned above, I think that the 8051 family was even bigger yet.)

(There's also some other interesting stuff about the team that moved from Motorola to MOS in that document as well.)

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


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 02, 2023 7:00 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8453
Location: Southern California
I don't think anyone is saying that the 6502 ever had a large percentage of the automotive microprocessor/microcontroller market, but rather that apparently a very sizeable percentage of the many billions of oh-twos made were indeed for the automotive market, certainly way, way more than what went into home computers.

_________________
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 Jun 02, 2023 7:47 am 
Offline
User avatar

Joined: Sat Dec 01, 2018 1:53 pm
Posts: 727
Location: Tokyo, Japan
Mike Naberezny wrote:
Related to Motorola, I've thought several times that it would be handy if the 6502 had a 16-bit index register like on the 6800. Since the original 6502 team came from that project, they may have considered it.

There is no doubt in my mind that they deliberately decided to do that differently from the 6800. There are plenty of things they took wholesale from the 6800 (the bus protocol, for example), and pretty much everything they did differently seems to have a pretty clear advantage, if you look for it.

The index register design in the 6800 and the 6502 is an interesting topic, with many subtleties. A sixteen-bit index register is handy, but start doing any significant amount of programming on the 6800 and the problems, more to do with their implementation than their design, become quite apparent, at least when you're programming a general purpose computer rather than a microcontroller for an embedded system.

In particular, with just one index register, in general purpose programming you're doing a lot of loads and stores of that register. It's made worse by not having PSHX or PULX on the 6800/6802/6805 (it was added to the 6801/6803, 6809 and 68HC11), so you always have to have a location available for this, which can get tricky with re-entrant code.

Further there's a performance issue that's not a problem with the architecture but the implementation: when indexing through that register you must always supply a constant 8-bit offset. LDAA (X) can in theory be a very fast two-cycle operation: instruction read followed by read at X. But between having to read another byte for the offset, add it to X, and not short-cutting the add when there's no carry, it ends up always being 5 cycles instead. (No-offset addressing was added to the 6805, 6809 and 68HC11.) INX also always requires 4 cycles, though in theory a increment when there's no carry could be done in two (or perhaps even one) cycles. This entirely unnecessary inefficiency in the implementation will have implications for the 6502's competitiveness, as we will see below.

The 6800 designers, with their focus on constant-offset indexed accesses, clearly had "fixed structure access" on the brain. This is convenient at times: point X at a structure and you can easily grab whichever bytes from it you need without any math. I've not found this to be hugely significant in the programs I've written, though. Perhaps it's used a lot more in microcontroller applications, since they didn't even chose to add a no-offset index mode when making additions to the instruction set for the 6801. (And they made some pretty expensive ones, such as adding a multiply instruction, which apparently GM really, really wanted for some reason.)

The obvious fix for many of the 6800 load/store issues is to add a second index register, which is exactly what happened with the 68HC11 and 6809. (The 6809 actually has a third index register, the "user stack," as well, and indexing from the stack, and addressing modes out the wazoo such that there are basically no issues at all with addressing anything however you like without going to any extra effort.) That they didn't add this to the 6801, despite other expensive changes (see "multiply," above) also might point to the single-index-register problem not being so much of a problem in MCU code.

Now the 6502 has two index registers, which you might think of as the solution to the 6800's "one index register" problem, but that's actually not it at all. The 6502's solution works just as well with a single "index" register (which, since it adds an offset, might more properly be termed an "offset" register when comparing it to the 6800's X or 8080's HL registers) because the actual index that would be stored in a register in the 6800 or 8080 is stored in memory instead. Consider that in your programming it's almost certain that you do a lot of LDA ($02),Y / STA ($04),Y but very little similar stuff where one operation involves the Y register and the other involves the X register.

Effectively what the 6502 does here is substitute a zero-page memory location for the 6800's X register, and remove the constant offset, adding instead a variable offset from the Y register. This is rather inefficient, taking 5 or 6 cycles to load through the index, but if you remember what I said above about the 6800's inefficient implementation, you'll see that this is perfectly competitive with the 6800. It's interesting to wonder if MOS would still have taken this approach if the 6800 had had a two-cycle load through the index register, as I reckon it easily could have.

The 6502 does lose when you need to increment the 16-bit index, taking at least seven cycles for INC $02 / BCC when there's no carry (and much more when there is), but this is also mitigated with the offset in Y, which can be incremented in two cycles, saving you from incrementing not just your source pointer but also your destination pointer when doing a copy. This does make for extra work when you need to be able to copy more than 256 bytes, but there are plenty of situations where you don't, and even when you do it still works out faster (though using more code space) overall, even when compared to a theoretical two-index-register copy on a 6800. Even in practice, on the 68HC11 which as two index registers and less cycle inefficiency, it's still 14 cycles for LDAA 0,X (4) / STAA 0,Y (4) / INX (3) / INY (3), as opposed to 12-14 on the 6502.

But you'll note that there's something missing above, which is the loop's branch instruction. That brings us to yet another bit of 6502 cleverness for short (≤256 byte) copies: you can work towards zero rather than away from it (copying backwards from the top or copying forwards by setting your index to 256 bytes before the end of your copy range) and that means you don't need a compare instruction before the branch to detect the end: you simply DEC or INC and BNE to stop when it hits zero. With the 6800 family you need either to do a 16-bit compare of an index register or, more often, keep a separate count (usually in accumulator B) that you decrement (which also avoids the compare, but that's now a third thing to decrement, except on the 6809 where the index registers can auto-increment or -decrement).

In all of this we've been using only one index register on the 6502. So why did Peddle & Co., who were clearly very concerned about saving transistors and die space wherever possible, have two?

One argument might be that they have different addressing modes: indexed indirect (LDA ($02,X)) versus indirect indexed (LDA ($02),Y). But on second glance that looks as easily implemented with one register instead of two: the instruction bit you decode for the addressing mode need not also specify one of two registers, rather than specifying one of two modes for a single register. (And this, by the way, is probably why the modes are fixed for each register: being able to specify the addressing mode separately from the register to use would require another bit in the instruction and more decoding. We've already seen in previous messages that they were willing to give up BRA and BSR to avoid this.)

But this brings us to another feature of the 6800 that the 6502 decided to drop: having two accumulators, A and B. Or did they? As it turns out, on the 6800 the B accumulator is mostly (at least in my experience) used for counts, where you load it with your count, decrement it as you go through your loop, and exit the loop when it hits zero, for quick temporary storage of values in A, and for passing parameters to subroutines. As it turns out, the X and Y registers in the 6502 also work great for this, and when you're doing indexing you're usually using only one, leaving the other free for these purposes. And I'd be willing to bet that, as well as being more efficient for instruction decoding, re-using existing chip structures for Y for X as well is more efficient than adding another somewhat different B register.

Note that the speed and instruction decoding issues come up again when doing the obvious "add a second index register" modification, too, which may be why Motorola delayed so long in doing that. The 68HC11 IX register works just as it does in the 6800 (but faster); using the IY register requires a prefix byte due to lack of space in the opcode set.

There's surely more along these lines, but this should give you an idea of how intertwined all these considerations are, and how a good deal of cleverness can give you most of the same thing at considerably less cost, especially when your competitor has made a few key mistakes that make their design needlessly less efficient.

And these are the sorts of things I keep in mind when I ask myself, "What would I change about the original 6502 design?" It turns out that, when you really dig into it, there's often a lot less than you'd think.


[quote=BigDumbDinosaur]And your point is...what? My example was meant to highlight a feature if the 65C816. How did the 6809 get into the discussion?[/quote]
Looking at later improvements to CPU family architectures, such as the 6800 family (particularly the 6801, 68HC11 and, because it's a related architecture even if not binary compatible, 6809) can often give insight into the long-term potential of particular architectural designs. So, for example:

Quote:
I think you missed something from my example. Once I’ve pointed direct page to the stack, I can use stack RAM to set up pointers and then do something like LDA [$00],Y, which conceptually is LDA [(SP+1)],Y.

No, I did not miss that. My point is that while you get cute little things like this with the 6502 architecture, you're getting it not because it's particularly useful but because it just sort of falls out of the core design where pointers are stored in RAM, rather than index registers, and the index registers are used for offsets. I'd argue that while this was great in 1975 and for up to a decade thereafter, it soon showed its age and infelicity as CPUs grew to have more registers and more addressing modes at low cost. I'd argue that this is one of the reasons that the 6502 architecture, at least in PCs, just sort of faded away through the '80s, rather than continuing to compete with, e.g., the 8086 design from 1978 or the 68000 design from 1979. Adding 24-bit addressing alone was not enough: the core architecture just doesn't work so well when it becomes cheaper to make considerably larger CPUs.

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


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 02, 2023 8:02 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8453
Location: Southern California
cjs wrote:
GARTHWILSON wrote:
I have no experience with the 6809; but according to this post and this one, the 6809 had really no execution speed advantage over the 6502—and that's at a given clock rate; but the '02 went to much, much faster clock rates.

If you read slightly further down that first thread, you'll notice that the issue in the post you reference was ported 6800 code not using the auto-increment addressing mode. The second one comes right out and says, "The results show that 6809 at 1.78 MHz matches 6502 at 2 MHz. The second accumulator gives a big advantage to 6809." And that's for math-heavy code that does not play to the 6809's strengths.

2MHz/1.78MHz means the 6809 was only 12% faster.  As I said, that's not significant.  50% faster would be significant enough that the user will probably notice it, but it's definitely not monumental.

Quote:
By the early '80s Motorola (and Hitachi) really had no reason to continue 6809 development when they already had the 6811 for the low-end and the 68000 for the high end.

The 68HC11 was a nice microcontroller family, and in fact I wanted to use it for a product in 1994, but I found that the automotive market had them all locked up on allocation so we wouldn't be able to get any, except maybe a sample or two, definitely not production quantities.  We ended up going back to a 65c02, 65c22, SRAM, EPROM, serial EEPROM, and a few support parts.  It took a little more room, but the overall cost was similar to what the desired version of the 'HC11 would have cost us.

As for the 68000, I have no use for it myself, for my uses on the workbench where interrupt performance is one of the major criteria.  The '02 absolutely blows the doors off the 68K in interrupt performance.  Comparing maximum interrupt latencies, the '02 is more than an order of magnitude faster.  I understand the Hitachi 6309 was quite an improvement over the 6809, although the 6309's rated clock speed never got over 3.5MHz either.

Quote:
I disagree with this, though perhaps I'm taking a slightly more literal approach to the question than you are. The more I learn about the 6502, the more impressed I am with its design, and I see very little that could be done unarguably better if you look at all the conditions under which they were working, including things like considering the effect of die size on yield and so on.

I, too, think the designers did an excellent job considering the constraints and the technology of the day.  (And I certainly couldn't have contributed anything myself, as my electronics interest did not even include computers yet at the time.)


BigDumbDinosaur wrote:
Worth reading is Garth’s write-up on his site about synthesizing 65C816-specific stack instructions on the 65C02—it’s very instructive to see how much hoop-jumping is involved, and why we promote the use of the 816 in new designs.

It's at http://wilsonminesco.com/stacks/816newinst.html .

As for the usefulness of 6502.org, I do refer to 6502.org as kind of the hub of all things 65xx.  If we were all really looking for absolute maximum performance, we'd be into the 64-bit multi-GHz processors.  I like to make the comparison though of the Reno Air races (which unfortunately will end this year, because of accidents).  In the Formula 1 division, aircraft are all powered by a Continental O-200 engine (the same 100 hp engine used in a Cessna 150), and exceed 250 mph on the 3.12-mile race course, more than half the speed of the Unlimited class where they have thousands of horsepower (and cost far more).

_________________
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 Jun 02, 2023 8:19 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8453
Location: Southern California
cjs wrote:
Quote:
I think you missed something from my example. Once I’ve pointed direct page to the stack, I can use stack RAM to set up pointers and then do something like LDA [$00],Y, which conceptually is LDA [(SP+1)],Y.

No, I did not miss that. My point is that while you get cute little things like this with the 6502 architecture, you're getting it not because it's particularly useful but because it just sort of falls out of the core design where pointers are stored in RAM, rather than index registers, and the index registers are used for offsets.

Don't forget the value of stack frames, even rather large ones, holding far more variables than you ever could in registers, and that the '816 has a 16-bit stack pointer, and you could have multiple kilobytes of stack frames, and address them with all the same addressing modes afforded in ZP (or, for the '816, direct page).

_________________
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 Jun 02, 2023 10:07 am 
Offline
User avatar

Joined: Sat Dec 01, 2018 1:53 pm
Posts: 727
Location: Tokyo, Japan
GARTHWILSON wrote:
Don't forget the value of stack frames, even rather large ones, holding far more variables than you ever could in registers, and that the '816 has a 16-bit stack pointer, and you could have multiple kilobytes of stack frames, and address them with all the same addressing modes afforded in ZP (or, for the '816, direct page).

Nope, not forgetting that at all. But don't forget that the only reason that the 6502 and 65816 have all these (moderately expensive) addressing modes through ZP is because the 6502 has no 16-bit index registers. That turned out to be great for the 6502 in 1977, in part because of unnecessary inefficiencies in the 6800 (no two-cycle indirect loads through X because they forced you to use a constant offset byte of 0 in those frequent cases where you just wanted to load whatever X was pointing at), but started to create inefficiencies of its own in the early '80s as other processors started adding things like the ability to directly access variables in the stack without having to go through your single direct page or do other tricks.

There's always something you can find that one processor will do better than another, but "hey, I found a cool trick" is not really the best way to compare processors. You want to look at how easy and fast it is to do common things for particular applications, and on that score the 65816 doesn't really keep up with 16-bit machines in the '80s, and is not significantly better enough than 8-bit machines that it could, e.g., be an obvious win against the 68HC11 and the like.

The 6502 is not the only CPU family that faded away as computers grew larger and faster because of indexing through memory; a few minis and mainframes did as well. And that's hardly unique; as computers continued to grow larger and faster, even the 68000 faded away because the architecture, while it looked great in the early '80s, turned out not to be so great as CPU speeds outstripped memory speeds.

The only major CPU architecture I know of that survived into subsequent stages of speed and size was x86, and that was mainly because Intel was willing to spend a ridiculous amount of time and effort working around the problems their architecture created for efficiency as the world changed, such as by using register renaming, breaking ops down into micro-ops to run on a completely different hidden architecture, and so on.

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


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 13, 2023 2:04 pm 
Offline

Joined: Sun Sep 03, 2023 3:40 pm
Posts: 33
sark02 wrote:
    1. ADD/SUB without carry.


After reading the whole thread I don’t see anyone pointing this out, so maybe I’m missing something; but …

Don’t we already have this with EOR?

Are there add without carry/subtract without carry ops with truth tables that aren’t an exclusive or?


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 13, 2023 2:11 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10822
Location: England
Ah, perhaps you're thinking of bit-to-next-bit carry, whereas the ADD/SUB comment is thinking of byte-to-next-byte carry, with carry in and carry out. Particularly, some micros have a form with no carry in, as well as a form with the carry in: ADC vs ADD, and SBC vs SUB.


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 13, 2023 2:25 pm 
Offline

Joined: Sun Sep 03, 2023 3:40 pm
Posts: 33
As soon as I read your comment I stopped thinking about xor in a mathematical field/group sense and started thinking about x86 code where you ADD-then-ADC or SUB-then-SBB instead of SEC-SBC-SBC etc.

I think I tunnel visioned in on xor as an add/subtract in that sense.

I am going to posit to myself that I’d have figured it out after this next cup of coffee, true or not ;)


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

All times are UTC


Who is online

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