6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Jun 23, 2024 3:44 am

All times are UTC




Post new topic Reply to topic  [ 84 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
PostPosted: Thu Sep 10, 2020 9:10 am 
Offline

Joined: Tue Jul 24, 2012 2:27 am
Posts: 672
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.[/color]


And even if you're exclusively using Y indexing, that means you'll always be using X for a loop counter.

_________________
WFDis Interactive 6502 Disassembler
AcheronVM: A Reconfigurable 16-bit Virtual CPU for the 6502 Microprocessor


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 11, 2020 3:34 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8229
Location: Midwestern USA
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.

Not to mention using (<dp>,X) for selecting UART channels to process. :D

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


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 11, 2020 8:29 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 867

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?


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 12, 2020 1:55 am 
Offline

Joined: Tue May 05, 2009 2:49 pm
Posts: 109
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?

Also a good choice and somewhat more neutral.

Jim


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 12, 2020 2:32 pm 
Offline
User avatar

Joined: Thu May 14, 2015 9:20 pm
Posts: 155
Location: UK
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


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 12, 2020 4:33 pm 
Offline

Joined: Wed Jan 08, 2014 3:31 pm
Posts: 578
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.

A +1 to (ZP,X) as well. Last year I wrote a toy compiler for a Scheme like language, and I used that for reference arguments.

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:
; 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


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 12, 2020 7:04 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8229
Location: Midwestern USA
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!


Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 15, 2020 9:32 pm 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 694
Location: North Tejas
I have been playing with code generation on different processors.

This line of code

Code:
    W0 := S1;


sign extends a byte into two.

For the 6502:

Code:
                          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


For the 6800:

Code:
                          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


For the 8080:

Code:
                          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


For the 9900:

Code:
                          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


For the 68000:

Code:
                                  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


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:

Code:
    movsx   AX,[S1]
    mov     [W0],AX


For the AVR:

Code:
                          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


And finally, for the 6809:

Code:
                                  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


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...


Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 15, 2020 11:39 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1938
Location: Sacramento, CA, USA
BillG wrote:
For the 6502:

Code:
                          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

Same size, but one cycle faster for negative numbers:
Code:
ext8to16:
    lda  #$7f
    cmp  S1
    sbc  #$7f
    ldx  S1
;
    stx  W0
    sta  W0+1

_________________
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: Wed Sep 16, 2020 4:36 am 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 694
Location: North Tejas
barrym95838 wrote:
Same size, but one cycle faster for negative numbers:
Code:
ext8to16:
    lda  #$7f    ; 2 cycles
    cmp  S1      ; 3 cycles
    sbc  #$7f    ; 2 cycles
    ldx  S1      ; 3 cycles
;
    stx  W0
    sta  W0+1


YOU ARE WRONG!!!

The savings are 2 or 3 cycles! I think you did not count that tya below...

Thank you!


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 16, 2020 6:06 am 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 694
Location: North Tejas
That technique saves one cycle on the 6800, but make the code larger.

Optimizing for size:

Code:
                          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


Optimizing for speed:

Code:
                          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


With that one post, you just earned a mention in two more of my compilers. Congratulations!


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 16, 2020 6:19 am 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 694
Location: North Tejas
Saved another cycle and byte...

Code:
                          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


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 16, 2020 6:51 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10834
Location: England
(BillG, I'm not sure if you intended these last few posts to be on this thread...)


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 16, 2020 12:25 pm 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 694
Location: North Tejas
BigEd wrote:
(BillG, I'm not sure if you intended these last few posts to be on this thread...)


100% intended.

This thread is largely about comparing the 6502 to other processors; showing that the one detested by the OP is competitive is on topic.


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 16, 2020 12:53 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10834
Location: England
Oh right. "Detested" would be a mischaracterisation, I'm sure.


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

All times are UTC


Who is online

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