A new article about 6502
-
White Flame
- Posts: 704
- Joined: 24 Jul 2012
Re: A new article about 6502
GARTHWILSON wrote:
and the (ZP,X) is tremendously valuable in dealing with a virtual stack where some of the cells on the stack are addresses and X is used as the virtual-stack pointer. I definitely use X more than Y. Even for hardware-stack addressing, there's the TSX and TXS, but no equivalent for Y.
- BigDumbDinosaur
- Posts: 9427
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: A new article about 6502
GARTHWILSON wrote:
and the (ZP,X) is tremendously valuable in dealing with a virtual stack where some of the cells on the stack are addresses and X is used as the virtual-stack pointer.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: A new article about 6502
brain wrote:
tiny is better. But, it's still an awfully loaded term. Minimal, or nominal, or half hearted I think would be better (and more nuanced). tiny and microscopic are boring words.
Incremental?
Re: A new article about 6502
JimBoyd wrote:
brain wrote:
tiny is better. But, it's still an awfully loaded term. Minimal, or nominal, or half hearted I think would be better (and more nuanced). tiny and microscopic are boring words.
Incremental?
Jim
Re: A new article about 6502
I’ve not read the linked to article. But one thing that is more important than features alone, especially in the 1970s and 1980s, was getting the price right (as in low) with just enough features so that it sells.
This was when complex highly integrated circuits were expensive. Especially microprocessors and RAM chips.
And microprocessors designed for use in embedded systems (which was the original market for the NMOS 6502, and also for the Z80) did not need anything that would require any extra cost.
Despite not being designed for use in home computer systems let alone business systems, the 6502 and the Z80 ended up in business computers, educational computers and home computers as well as arcade machines. But also in their original market: embedded systems.
Why, because they were low cost solutions.
Now, looking back (in hindsight), it’s easy to say that there should have been improved versions made. But at the time, when the fabs were having trouble keeping up with production, that’s not really thought about.
Similarly, computer manufacturers are not going to spend too much time and money designing a new computer whilst they are selling their best selling models by the truck load. Hence low or no demand for anything better in terms of the microprocessor.
And then technology moves on and someone else is now working on 16 or 32 bit microprocessors (look up the dates for the 68000 and the 8086 and then look at when the first 16/32 bit computers were first sold). At the same time, most of the computers that these chips (6502, Z80) are being used in, are undergoing cost reduction measures by the manufacturers so that the older model of computers can stay price competitive. Not a good market for a new more expensive eight bit microprocessor... so even less call for a more expensive eight bit souped up microprocessor.
As it happens, because both the 6502 and the Z80 got CMOS versions, they both live on. Because they can be used in low power devices.
Of course, if a significantly faster and/or significantly more capable eight microprocessor that was backwards compatible had been made at low cost back in the mid 1980s, people may well have wanted it in their computer systems.
The bit about the Acorn BBC Micro (also known as the model B). Acorn did design and manufacturer an export version for sale in the U.S.A. As far as I know, they were not blocked or locked out as such. In their home market (the U.K.) these machines were already in the expensive segment of the home computer market. Lower cost Commodore 64 and Sinclair ZX Spectrum computers outsold the Acorn models by a considerable margin, and don’t forget there were many other home computer manufacturers at the time as well, some of which were also undercutting the cost of a BBC Model B machine.
The U.S.A. model included as standard, what were optional features (see here) on the models sold in the U.K., plus all the extra screening added to the cost of each machine. So my feeling is that they priced themselves out of the market. They were never going to really compete with the C64 for a home computer. And if you wanted a more business like computer, then a business would be more likely to either buy and use a CP/M machine or a IBM PC.
The only lock or block really, was the interference suppression requirements (screening and testing) that were required before it was legal to sell systems in the U.S.A.
This was also part of the reason that other U.K. home computer manufacturers had difficulty trying to enter the U.S.A. market.
Interestingly enough, Acorn did push 6502 system functionality more than most home computers in that it’s ‘main’ 6502 normally runs at 2MHz when accessing ROM or RAM. The optional second processor expansion runs even faster at 3MHz. Later on the (internal) second processor board for the Master 128 (the machine is then known as the ‘Master Turbo’) runs at 4MHz. And the Master series machines use a CMOS 65C12 and use the extra instructions to improve the OS code.
By the time of their last eight bit machine (the Master Compact), the OS and BASIC had been improved significantly, in part due to using the 65C12 (and also by general code improvements). See the section under “Performance” in this review (yes, it’s obviously biased). However by now, eight bit machine sales were falling, as most people wanted the new 16/32 bit machines...
Mark
This was when complex highly integrated circuits were expensive. Especially microprocessors and RAM chips.
And microprocessors designed for use in embedded systems (which was the original market for the NMOS 6502, and also for the Z80) did not need anything that would require any extra cost.
Despite not being designed for use in home computer systems let alone business systems, the 6502 and the Z80 ended up in business computers, educational computers and home computers as well as arcade machines. But also in their original market: embedded systems.
Why, because they were low cost solutions.
Now, looking back (in hindsight), it’s easy to say that there should have been improved versions made. But at the time, when the fabs were having trouble keeping up with production, that’s not really thought about.
Similarly, computer manufacturers are not going to spend too much time and money designing a new computer whilst they are selling their best selling models by the truck load. Hence low or no demand for anything better in terms of the microprocessor.
And then technology moves on and someone else is now working on 16 or 32 bit microprocessors (look up the dates for the 68000 and the 8086 and then look at when the first 16/32 bit computers were first sold). At the same time, most of the computers that these chips (6502, Z80) are being used in, are undergoing cost reduction measures by the manufacturers so that the older model of computers can stay price competitive. Not a good market for a new more expensive eight bit microprocessor... so even less call for a more expensive eight bit souped up microprocessor.
As it happens, because both the 6502 and the Z80 got CMOS versions, they both live on. Because they can be used in low power devices.
Of course, if a significantly faster and/or significantly more capable eight microprocessor that was backwards compatible had been made at low cost back in the mid 1980s, people may well have wanted it in their computer systems.
The bit about the Acorn BBC Micro (also known as the model B). Acorn did design and manufacturer an export version for sale in the U.S.A. As far as I know, they were not blocked or locked out as such. In their home market (the U.K.) these machines were already in the expensive segment of the home computer market. Lower cost Commodore 64 and Sinclair ZX Spectrum computers outsold the Acorn models by a considerable margin, and don’t forget there were many other home computer manufacturers at the time as well, some of which were also undercutting the cost of a BBC Model B machine.
The U.S.A. model included as standard, what were optional features (see here) on the models sold in the U.K., plus all the extra screening added to the cost of each machine. So my feeling is that they priced themselves out of the market. They were never going to really compete with the C64 for a home computer. And if you wanted a more business like computer, then a business would be more likely to either buy and use a CP/M machine or a IBM PC.
The only lock or block really, was the interference suppression requirements (screening and testing) that were required before it was legal to sell systems in the U.S.A.
This was also part of the reason that other U.K. home computer manufacturers had difficulty trying to enter the U.S.A. market.
Interestingly enough, Acorn did push 6502 system functionality more than most home computers in that it’s ‘main’ 6502 normally runs at 2MHz when accessing ROM or RAM. The optional second processor expansion runs even faster at 3MHz. Later on the (internal) second processor board for the Master 128 (the machine is then known as the ‘Master Turbo’) runs at 4MHz. And the Master series machines use a CMOS 65C12 and use the extra instructions to improve the OS code.
By the time of their last eight bit machine (the Master Compact), the OS and BASIC had been improved significantly, in part due to using the 65C12 (and also by general code improvements). See the section under “Performance” in this review (yes, it’s obviously biased). However by now, eight bit machine sales were falling, as most people wanted the new 16/32 bit machines...
Mark
Re: A new article about 6502
GARTHWILSON wrote:
and the (ZP,X) is tremendously valuable in dealing with a virtual stack where some of the cells on the stack are addresses and X is used as the virtual-stack pointer. I definitely use X more than Y. Even for hardware-stack addressing, there's the TSX and TXS, but no equivalent for Y.
Looking at one of my common macros modules. I use ",x" 68 times and ",y" 4 times. So I'm really partial to it. But I stole my 6502 assembler style from Forth, so no shock there.
Pairing X and Y together can be really powerful. Such as copying a data stack cell to a location via a pointer. There you use the Y rather than alter the pointers contents.
Code: Select all
; Nondestructively saves the word at TOS using indirect y addressing.
.macro peekIndY
lda TOS_LSB,x
sta (_1),y
iny
lda TOS_MSB,x
sta (_1),y
.macend
- BigDumbDinosaur
- Posts: 9427
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: A new article about 6502
After reading the linked article in its entirely, and at the risk of offending the author, I must ask what was the point of writing it? The article is overflowing with opinion and starved for facts. In fact, there is so much factual inaccuracy present another entire article would have to be written to rebut the multitude of errors and outright false statements.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: A new article about 6502
I have been playing with code generation on different processors.
This line of code
sign extends a byte into two.
For the 6502:
For the 6800:
For the 8080:
For the 9900:
For the 68000:
That almost feels like cheating.
It is interesting that the last four examples have each been ten bytes long.
Real cheating would be the 80386:
For the AVR:
And finally, for the 6809:
which brings up one of my favorite programming jokes:
The Motorola 6809, where SEX is sometimes followed by STD.
Thank you very much. Drive safely...
This line of code
Code: Select all
W0 := S1;
For the 6502:
Code: Select all
00037 ; 1 L v S1
0029 A0 00 [2] 00038 ldy #0
002B A6 16 [3] 00039 ldx S1
002D 10 01 (0030) [2/3] 00040 bpl 2f
002F 88 [2] 00041 dey
0030 00042 2:
0030 98 [2] 00043 tya
00044 ; 0 := v W0 -> 1
0031 86 0D [3] 00045 stx W0
0033 85 0E [3] 00046 sta W0+1
Code: Select all
00037 * 1 L v S1
0029 4F [2] 00038 clra
002A D6 16 [3] 00039 ldab S1
002C 2A 01 (002F) [4] 00040 bpl 2f
002E 4A [2] 00041 deca
002F 00042 2:
00043 * 0 := v W0 -> 1
002F 97 0D [4] 00044 staa W0
0031 D7 0E [4] 00045 stab W0+1
Code: Select all
00037 ; 1 L v S0
0100 3A 0015 [13] 00038 lda S0
0103 6F [5] 00039 mov L,A
0104 17 [4] 00040 ral
0105 9F [4] 00041 sbb A
0106 67 [5] 00042 mov H,A
00043 ; 0 := v W0 -> 1
0107 22 000D [16] 00044 shld W0
Code: Select all
00043 * 1 L v S1
0052 D020 0037 00044 movb @S1,R0
0056 0880 00045 sra R0,8
00046 * 0 := v W0 -> 1
0058 C800 002E 00047 mov R0,@W0
Code: Select all
00009 ; 1 L v S1
00000400 1038 0421 00010 move.b S1,D0
00000404 4880 00011 ext.w D0
00012 ; 0 := v W0 -> 1
00000406 31C0 0418 00013 move.w D0,W0
It is interesting that the last four examples have each been ten bytes long.
Real cheating would be the 80386:
Code: Select all
movsx AX,[S1]
mov [W0],AX
Code: Select all
00011 ; 1 L v S1
000060 9160 0116 [2] 00012 lds R22,S1
000062 2F76 [1] 00013 mov R23,R22
000063 0F77 [1] 00014 lsl R23
000064 0B77 [1] 00015 sbc R23,R23
00016 ; 0 := v W0 -> 1
000065 9360 010D [2] 00017 sts W0,R22
000067 9370 010E [2] 00018 sts W0+1,R23
Code: Select all
00037 * 1 L v S1
0029 D6 16 [4] 00038 ldb S1
002B 1D [2] 00039 sex
00040 * 0 := v W0 -> 1
002C DD 0D [5] 00041 std W0
The Motorola 6809, where SEX is sometimes followed by STD.
Thank you very much. Drive safely...
- barrym95838
- Posts: 2056
- Joined: 30 Jun 2013
- Location: Sacramento, CA, USA
Re: A new article about 6502
BillG wrote:
For the 6502:
Code: Select all
00037 ; 1 L v S1
0029 A0 00 [2] 00038 ldy #0
002B A6 16 [3] 00039 ldx S1
002D 10 01 (0030) [2/3] 00040 bpl 2f
002F 88 [2] 00041 dey
0030 00042 2:
0030 98 [2] 00043 tya
00044 ; 0 := v W0 -> 1
0031 86 0D [3] 00045 stx W0
0033 85 0E [3] 00046 sta W0+1
Code: Select all
ext8to16:
lda #$7f
cmp S1
sbc #$7f
ldx S1
;
stx W0
sta W0+1Got 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)
Mike B. (about me) (learning how to github)
Re: A new article about 6502
barrym95838 wrote:
Same size, but one cycle faster for negative numbers:
Code: Select all
ext8to16:
lda #$7f ; 2 cycles
cmp S1 ; 3 cycles
sbc #$7f ; 2 cycles
ldx S1 ; 3 cycles
;
stx W0
sta W0+1The savings are 2 or 3 cycles! I think you did not count that tya below...
Thank you!
Re: A new article about 6502
That technique saves one cycle on the 6800, but make the code larger.
Optimizing for size:
Optimizing for speed:
With that one post, you just earned a mention in two more of my compilers. Congratulations!
Optimizing for size:
Code: Select all
00037 * 1 L v S1
0029 4F [2] 00038 clra
002A D6 16 [3] 00039 ldab S1
002C 2A 01 (002F) [4] 00040 bpl 2f
002E 4A [2] 00041 deca
002F 00042 2:
00043 * 0 := v W0 -> 1
002F 97 0D [4] 00044 staa W0
0031 D7 0E [4] 00045 stab W0+1
Code: Select all
00037 * 1 L v S1
0029 D6 16 [3] 00038 ldab S1
002B 86 7F [2] 00039 ldaa #$7F ; Thanks Mike B!
002D 91 16 [3] 00040 cmpa S1
002F 82 7F [2] 00041 sbca #$7F
00042 * 0 := v W0 -> 1
0031 97 0D [4] 00043 staa W0
0033 D7 0E [4] 00044 stab W0+1
Re: A new article about 6502
Saved another cycle and byte...
Code: Select all
00037 * 1 L v S1
0029 D6 16 [3] 00038 ldab S1
002B 86 7F [2] 00039 ldaa #$7F ; Thanks Mike B!
002D 11 [2] 00040 cba
002E 82 7F [2] 00041 sbca #$7F
00042 * 0 := v W0 -> 1
0030 97 0D [4] 00043 staa W0
0032 D7 0E [4] 00044 stab W0+1
Re: A new article about 6502
(BillG, I'm not sure if you intended these last few posts to be on this thread...)
Re: A new article about 6502
BigEd wrote:
(BillG, I'm not sure if you intended these last few posts to be on this thread...)
This thread is largely about comparing the 6502 to other processors; showing that the one detested by the OP is competitive is on topic.
Re: A new article about 6502
Oh right. "Detested" would be a mischaracterisation, I'm sure.