6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Mon May 06, 2024 7:14 am

All times are UTC




Post new topic Reply to topic  [ 69 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
PostPosted: Sun May 06, 2012 8:04 pm 
Offline

Joined: Mon Apr 16, 2012 8:45 pm
Posts: 60
I just looked over the instruction set for 8051 and lo and behold, it too has a DJNZ instruction. The 8051 arrived well after the 6502, I wonder why it became so popular while the 6502 is now relegated to special purpose application. I would have thought that a processor acceptable for pacemakers would also be acceptable elsewhere.


Top
 Profile  
Reply with quote  
PostPosted: Sun May 06, 2012 8:24 pm 
Offline

Joined: Mon Apr 16, 2012 8:45 pm
Posts: 60
BigEd wrote:
Final point: beware of wish-list features which trim one or two bytes or clock cycles. These thoughts probably come from experience with 1MHz or 2MHz systems with 64k memory. If a project is delivering a CPU which runs at 25MHz with a 32bit address space, the baseline performance should already be a lot higher and the memory pressure a lot lower. Time might be better spent on increasing clock speed, or making a smarter SDRAM interface which will speed up all programs, instead of adding or tweaking a few special-case instructions. (Of course, some instructions are worth the effort, and others are not.)

Well, it is a question of application and target audience.

My personal view, based on having programmed a lot of low level code for a lot of different architectures, is that the 6502 is a supremely pleasant processor to program in assembly code. Code density is impressive and I remember on project I did with a colleague, implementing a complete Huffman compressor in about 700 bytes code (that is bytes, not KB). A view on Opencores show a lot or re-implementations but actual use in end user products is less visible. At the same time ARM, Atmel, PIC and others are doing a roaring business.

I think there is a place for 6502 though a few improvements would be in place such as various extension to the instruction set suggested. An updated SWEET16 implementation would extend into 16 bit space where ARM enters using the Thumb profiles.

Another possibility is more fundamental hardware changes such as making $0000 - $03FF 2-port memory which should shave off a lot of cycles for zero page access and stack use. This should still remain transparent to the programmer. Shadow registers for fast interrupts is another possibility, as is a fast bank for interrupt code (say, at $C000 - $FFFF). Perhaps a nice development board is all it takes to bring the 6502 back into the limelight.


Top
 Profile  
Reply with quote  
PostPosted: Sun May 06, 2012 8:29 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10798
Location: England
Hmm, what's your 2-port memory idea?


Top
 Profile  
Reply with quote  
PostPosted: Sun May 06, 2012 11:50 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8432
Location: Southern California
Alienthe wrote:
I just looked over the instruction set for 8051 and lo and behold, it too has a DJNZ instruction. The 8051 arrived well after the 6502, I wonder why it became so popular while the 6502 is now relegated to special purpose application. I would have thought that a processor acceptable for pacemakers would also be acceptable elsewhere.
and
Quote:
At the same time ARM, Atmel, PIC and others are doing a roaring business.

With the 6502 being made in hundreds of millions of units per year, I'd have to say pacemakers are a very small part of that pie.  A DJNZ instruction would not make a significant improvement in my 6502 programs' overall performance.  These others are complete microcontrollers, and I wish very much there were a good line of 6502-based microcontrollers.  Their greater visibility and popularity is not due to a better microprocessor though, as evidenced by the 8051's 52 clocks' interrupt latency which is put to shame by the 6502, and the PIC16's underperforming processor core.  For some reason though, Bill Mensch has not chosen to follow that business model.  He does have the 65265 and 65134 microcontrollers, but their ROM cannot be programmed by the customer.  It can only be mask-programmed which means that unless the situation changes, our small company and thousands of other like it will never be using a 65xxx microcontroller.  Connecting your own ROM on them externally not only adds to the cost and board space, but eats up a lot of the pins that would otherwise have been used for I/O and made the part so attractive.  They do have lots of interrupt vectors, reducing or eliminating the polling needed to determine the source of the interrupt; but it's not a big deal if you poll in order of urgency of the source, and poll only the few sources that are enabled.

I definitely find the idea of dual-port memory for stack and ZP to be attractive though!  It could be on-chip, requiring few or no additional pins.  I do want it accessible as normal memory for the programmer though, unlike the miserable situation with the stack on the PICs.

Although we will all take all the performance we can get in a 65-family processor, we also recognize that performance is not everything, otherwise we'd all be using nothing but the most powerful multi-GHz, multi-core, 64-bit processors available.  I like your remark about the 6502 being a supremely pleasant processor to program in assembly code, and the code density being impressive.  I still use my 1986 Hewlett-Packard HP-41cx calculator every day, not just as a calculator but an alarm clock, daytimer, and other things.  I just saw a comparison of the N-Queens benchmark results that put the HP-41 about 10,000 times as slow as the 6502—yet I still have uses for it.  My HP-71 hand-held computer is far more capable and very roughly around 10x as fast, but it doesn't fit the need as a calculator very well, and I seldom use the 71.

_________________
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: Mon May 07, 2012 8:53 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10798
Location: England
Oh, I see/remember: by dual-port memory is meant that the core has several paths to memory so fewer cycles would be needed to execute complex instructions. Transparent to the programmer, indeed, but a major difference in the core. All you need to do is become or recruit an HDL designer and your wish will be granted!

(The reason WDC only offer mask ROMs will be one of manufacturing process: mask ROM is cheap and easy to make, same process as normal, whereas reprogrammable technologies are another thing altogether.)

Cheers
Ed


Top
 Profile  
Reply with quote  
PostPosted: Mon May 07, 2012 9:50 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8432
Location: Southern California
BigEd wrote:
Oh, I see/remember: by dual-port memory is meant that the core has several paths to memory so fewer cycles would be needed to execute complex instructions.

Actually, it might not particularly even need to be dual-core.  If only pages 0 & 1 were on their own bus, stack pushes and pulls could happen while the next op code is being fetched which will not be in those two pages anyway, and similar reads and writes could happen in ZP.

Quote:
(The reason WDC only offer mask ROMs will be one of manufacturing process: mask ROM is cheap and easy to make, same process as normal, whereas reprogrammable technologies are another thing altogether.)

I figured it was something like that, but it puts it out of the question for niche markets where a microcontroller is a small part of a product that sells under a thousand units in the sales life of the product.

_________________
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: Mon May 07, 2012 11:00 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10798
Location: England
It's not so much the connectivity of the memory as the change to the bus structure of the core and the implied change to the sequencing which means rework (or a new core) - a few words of English might mean a whole heap of HDL. A picture is always a help. To my way of thinking, implementation is the bottleneck, not ideas. Those few ideas which bring a big gain at low cost are very worthwhile, but even then, only if there's someone to make them real.

(For a thousand units or so, don't FPGAs fit in? I suppose skillset might be as much a problem as economics. For the major manufacturer, an ARM-based SoC running at 168MHz programmed in C might be cheaper to make and support, and sell in higher volume and give just as good a power/cost/performance solution as the 8-bit SoC you wish you could buy.)


Top
 Profile  
Reply with quote  
PostPosted: Mon May 07, 2012 5:18 pm 
Offline

Joined: Mon Apr 16, 2012 8:45 pm
Posts: 60
GARTHWILSON wrote:
With the 6502 being made in hundreds of millions of units per year, I'd have to say pacemakers are a very small part of that pie.

Awesome. I had no idea the 6502 was that popular. I was told ARM volume was counted in billions, seeing 6502 hot on the heels like that is quite the surprise to me. Can you say more about where these go?

Quote:
A DJNZ instruction would not make a significant improvement in my 6502 programs' overall performance. These others are complete microcontrollers, and I wish very much there were a good line of 6502-based microcrocontrollers. Their greater visibility and popularity is not due to a better microprocessor though, as evidenced by the 8051's 52 clocks' interrupt latency which is put to shame by the 6502, and the PIC16's underperforming processor core. For some reason though, Bill Mensch has not chosen to follow that business model. He does have the 65265 and 65134 microcontrollers, but their ROM cannot be programmed by the customer. It can only be mask-programmed which means that unless the situation changes, our small company and thousands of other like it will never be using a 65xxx microcontroller. Connecting your own ROM on them externally not only adds to the cost and board space, but eats up a lot of the pins that would otherwise have been used for I/O and made the part so attractive. They do have lots of interrupt vectors, reducing or eliminating the polling needed to determine the source of the interrupt; but it's not a big deal if you poll in order of urgency of the source, and poll only the few sources that are enabled.

I never expected a single instruction to propel the 6502 to the forefront of the big volume league. As you mention above and as we remember from Z80, performance or convenience is low down on the list of what clinches the deal. Still, to get into the current mindshare a little activity is a lot better than a slumber where little news happened since the 1990's. A little improvement here, a little speed up there, a few new family members over there and trade press coverage changes. The 6502 might be a wonderful gem of a processor but that is little help if it is only known by people who rememebr it back from the 1970's.

Quote:
I definitely find the idea of dual-port memory for stack and ZP to be attractive though! It could be on-chip, requiring few or no additional pins. I do want it accessible as normal memory for the programmer though, unlike the miserable situation with the stack on the PICs.

If we provide a complete 1 KB (range $0000 - $03FFF) we get another 2 pages that can be used for a lot of other tricks and would also be nice for the architectural variations that provide a direct page register.

Quote:
Although we will all take all the performance we can get in a 65-family processor, we also recognize that performance is not everything, otherwise we'd all be using nothing but the most powerful multi-GHz, multi-core, 64-bit processors available. I like your remark about the 6502 being a supremely pleasant processor to program in assembly code, and the code density being impressive. I still use my 1986 Hewlett-Packard HP-41cx calculator every day, not just as a calculator but an alarm clock, daytimer, and other things. I just saw a comparison of the N-Queens benchmark results that put the HP-41 about 10,000 times as slow as the 6502-- yet I still have uses for it. My HP-71 hand-held computer is far more capable and very roughly around 10x as fast, but it doesn't fit the need as a calculator very well, and I seldom use the 71.

I quite agree performance is not all. ARM got a long way by focusing on the MIPS/Watt ratio.Then they extended the architecture all over the place: downward with 16-bit Thumb, upwards to 64-bit architecture, sideways with several rounds of DSP add-ons plus various bits and pieces like Jazelle.

For the 6502 I believe high useful MIPS/MHz, very high code density (further improved by SWEET16) and very low transistor count (and thus consumed chip area) are the main drivers. High reliability and a pleasant programming experience is most likely quite a way down on the list of decision factors. Still, the 6502 has what counts and has it in spades.


Top
 Profile  
Reply with quote  
PostPosted: Mon May 07, 2012 5:24 pm 
Offline

Joined: Mon Apr 16, 2012 8:45 pm
Posts: 60
GARTHWILSON wrote:
BigEd wrote:
Oh, I see/remember: by dual-port memory is meant that the core has several paths to memory so fewer cycles would be needed to execute complex instructions.

Actually, it might not particularly even need to be dual-core. If only pages 0 & 1 were on their own bus, stack pushes and pulls could happen while the next op code is being fetched which will not be in those two pages anyway, and similar reads and writes could happen in ZP.

Exactly. This makes the previously multi push instructions more convenient. Registers can be pushed onto the stack while the CPU works on the next instructions. This would either need careful interlocking of a very careful programmer.

A second use is a stack dup: read top of stack through port 0 and copy this value to the stack using port 1 while next instruction is decoded.


Top
 Profile  
Reply with quote  
PostPosted: Mon May 07, 2012 6:41 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8432
Location: Southern California
Quote:
Awesome. I had no idea the 6502 was that popular. I was told ARM volume was counted in billions, seeing 6502 hot on the heels like that is quite the surprise to me. Can you say more about where these go?

WDC's home page says,
Quote:
The legendary 65xx brand microprocessors with both 8-bit and 8/16-bit ISA’s keep cranking out the unit volumes in ASIC and standard microcontroller forms supplied by WDC and WDC’s licensees. Annual volumes in the hundreds (100’s) of millions of units keep adding in a significant way to the estimated shipped volumes of five (5) to ten (10) billion units. With 200MHz+ 8-bit W65C02S and 100MHz+ 8/16-bit W65C816S processors coming on line in ASIC and FPGA forms, we see these annual volumes continuing for a long, long time.

The 65xx brand is probably the only processor family that has remained loyal to its ISA over the last 33 years. In addition it has served the widest spectrum of electronic markets through those years. For example, it has served and in some cases created markets for the PC, video game, toy, communication, industrial control, automotive, life support embedded in the human body medical devices, outside the body medical systems, engineering education systems, hobby systems, and you name it electronic market segments. I might add the 65xx has served in a highly reliable and successful way!

(I put it here instead of just a link because they keep changing it so you might not see the same thing again for awhile.)  The small number of gates, the small licensing fee, and the easy development appear to be major attractions for the companies that use the 6502.

_________________
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: Tue May 08, 2012 4:09 am 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 387
Location: Minnesota
Quote:
Those few ideas which bring a big gain at low cost are very worthwhile, but even then, only if there's someone to make them real.


Speaking of which, I thought I'd toss out yet another idea: change the pre-indexed, zero-page indirect address mode to pre-indexed, absolute indirect. I don't use (zp,X) very often, and when I do the X-register usually equals zero anyway. If the instruction was instead absolute (like the 65C02's JMP (ab,X) instruction) then I could do things like this:

Code:
TSX
LDA ($0103,X)


Because the instruction would be absolute I could also do:

Code:
LDA ($00FE,X)


to get at things below the initial stack pointer, ie., the stack pointer could be used as real base pointer. At the very least I can see using this address mode more often than the original 6502 version.

Simpler might be just to hard-wire the high byte of "ins (addrlo,X)" to be $01 instead of $00. That wouldn't let you get at anything below the initial stack pointer, but still might make it a bit easier to use the hardware stack to pass subroutine arguments.


Top
 Profile  
Reply with quote  
PostPosted: Tue May 08, 2012 5:01 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8175
Location: Midwestern USA
GARTHWILSON wrote:
The small number of gates, the small licencing fee, and the easy development appear to be major attractions for the companies that use the 6502.

And the 65xx family continues to be a major attraction for homebrew enthusiasts like us. Working with the 65xx family is hard enough to keep you challenged and easy enough to keep you interested. That's a lot more than can be said for most other microprocessors.

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


Top
 Profile  
Reply with quote  
PostPosted: Tue May 08, 2012 5:09 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8175
Location: Midwestern USA
teamtempest wrote:
Speaking of which, I thought I'd toss out yet another idea: change the pre-indexed, zero-page indirect address mode to pre-indexed, absolute indirect. I don't use (zp,X) very often, and when I do the X-register usually equals zero anyway. If the instruction was instead absolute (like the 65C02's JMP (ab,X) instruction) then I could do things like this:

Code:
TSX
LDA ($0103,X)

Because the instruction would be absolute I could also do:

Code:
LDA ($00FE,X)

to get at things below the initial stack pointer, ie., the stack pointer could be used as real base pointer. At the very least I can see using this address mode more often than the original 6502 version.

Simpler might be just to hard-wire the high byte of "ins (addrlo,X)" to be $01 instead of $00. That wouldn't let you get at anything below the initial stack pointer, but still might make it a bit easier to use the hardware stack to pass subroutine arguments.

You can effectively do all that with the 65C816. :D Although it still has (ZP,X) addressing, the use of a 16 bit X-register extends the reach well beyond zero page. However...you can relocate ZP anywhere in the first 64 KB you want it to be.

Also, look at the stack relative instructions the '816 offers. Something like LDA 1,S (get last item pushed) and LDA (1,S),Y (treat last item pushed as an indirect address) gives you a lot of flexibility and you use no RAM other than the stack itself.

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


Top
 Profile  
Reply with quote  
PostPosted: Wed May 09, 2012 3:41 am 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 387
Location: Minnesota
Quote:
Also, look at the stack relative instructions the '816 offers. Something like LDA 1,S (get last item pushed) and LDA (1,S),Y (treat last item pushed as an indirect address) gives you a lot of flexibility and you use no RAM other than the stack itself.


Oh, I know about those, since HXA supports them. Never used them myself because I've never programmed a 65816. I'd prefer to have them - mainly because of how easy it would be to access a pointer passed on the stack - but I was thinking of something that might be fairly simple to do to an existing core.


Top
 Profile  
Reply with quote  
PostPosted: Sat Jun 02, 2012 11:10 pm 
Offline

Joined: Mon Apr 16, 2012 8:45 pm
Posts: 60
I once heard that SWEET16 was inspired by RCA 1602. Both have a few things in common, including
- a register bank of 16 registers (1802 has a few others too)
- each register in the register bank is 16 bit wide
- instructions, on the other hand, are only 8 bit wide

I noticed that the RCA 1802 was followed by the RCA 1805 having an extended instruction set and in this instruction set a DJNZ-like instruction was added. All in all it seems this instruction is more popular than I thought.

The RCA design is quite interesting with a few unusual features such as IO straight into the core of the ISA. Unfortunately it had a separate 8 bit accumulator. I wonder if it had been more efficient with an accumulator pointer (similar to the index register pointer) to freely position the accumulator within the register bank.


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

All times are UTC


Who is online

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