Page 2 of 5

SweetCX16

Posted: Tue Jan 04, 2022 2:53 pm
by rje

My attempt to modify your source for cc65.

Yes, I know I should FORK your repo and push an update to it and do a merge request... blah blah blah.   My brain is reeling from even considering trying this out in the first place.  Excuses excuses.

I've probably broken it too.  I'll load it and try to poke at it (no pun intended) with the debugger and see what I can try to do.

 

 

SweetCX16.s

SWEETCX16.PRG
build

SweetCX16

Posted: Tue Jan 04, 2022 5:33 pm
by rje

Okay I will start with a SET.  It looks like R1 is safe for this, so I can do SET R1, and let's see, let's give it the value $1541.

I'll use your binary, which loads to $4000, and I'll make sure to load in the data before I load the binary too.

And I'll put the "program" in $0700.

I think that would look something like this:

$0700: $11    ; SET R1

$0701: $41

$0702: $15

$0703: $00    ; RTN

$0704: $02    ; 6502 BRK

Then I poke $00 $07 into R15:



$0020: $00

$0021: $07



Then sys $4000.

Then peek $02 and $03 and hope that $41 and $15 are there?

 

 

 
Screen Shot 2022-01-04 at 12.42.01 PM.png

SweetCX16

Posted: Tue Jan 04, 2022 6:42 pm
by rje

But something goes wrong, and I don't know what it is ?

 

 
Screen Shot 2022-01-04 at 12.43.52 PM.png

SweetCX16

Posted: Tue Jan 04, 2022 11:17 pm
by BruceMcF


On 1/4/2022 at 12:40 AM, rje said:




SweetCX16.asm line 72 should be $0400, not $04000, yes?



Yes. That looks like a regression. Back then, I was primarily developing in VICE emulating a 65C02 in a C64, so the $CC00 branch saw more testing.


SweetCX16

Posted: Tue Jan 04, 2022 11:24 pm
by rje

And I am woefully inadequate at testing ML.  Hopefully working on SweeterX16 will improve my meager skills there.

 

 


SweetCX16

Posted: Fri Jan 07, 2022 1:06 am
by rje

I see exactly where I went wrong.  The start address should be loaded into the accumulator, shouldn't it?

Duh!  My brain.

 


SweetCX16

Posted: Fri Jan 07, 2022 2:20 am
by rje

So I was looking at the opcode set for SWEET16, and reading the descriptions, and thinking about SUB versus CPR.

SUB does a twos-complement add.  CPR does a binary subtract.  The code in fact overlaps significantly:

***

SUB:    LDY  $0             ;RESULT TO R0

CPR:    SEC                 ;NOTE Y REG = 13*2 FOR CPR

        LDA  R0L

        SBC  R0L,X

        STA  R0L,Y          ;R0-RX TO RY

        LDA  R0H

        SBC  R0H,X

SUB2:   STA  R0H,Y

        TYA                 ;LAST RESULT REG*2

        ADC  $0             ;CARRY TO LSB

        STA  R14H

        RTS

***

 

So my question is this:  maybe I can free up an opcode slot by not having SUB?  Especially if CPR puts its result in R13, and is therefore accessible as a difference value.

Haven't thought it through fully, but it seems that the two values are related enough.  Of course perhaps Woz did this because there wasn't another op that he wanted badly enough to get rid of SUB?

 


SweetCX16

Posted: Sat Jan 08, 2022 7:24 am
by Ed Minchau


On 1/6/2022 at 7:20 PM, rje said:




So I was looking at the opcode set for SWEET16, and reading the descriptions, and thinking about SUB versus CPR.



SUB does a twos-complement add.  CPR does a binary subtract.  The code in fact overlaps significantly:



***



SUB:    LDY  $0             ;RESULT TO R0

CPR:    SEC                 ;NOTE Y REG = 13*2 FOR CPR

        LDA  R0L

        SBC  R0L,X

        STA  R0L,Y          ;R0-RX TO RY

        LDA  R0H

        SBC  R0H,X

SUB2:   STA  R0H,Y

        TYA                 ;LAST RESULT REG*2

        ADC  $0             ;CARRY TO LSB

        STA  R14H

        RTS



***



 



So my question is this:  maybe I can free up an opcode slot by not having SUB?  Especially if CPR puts its result in R13, and is therefore accessible as a difference value.



Haven't thought it through fully, but it seems that the two values are related enough.  Of course perhaps Woz did this because there wasn't another op that he wanted badly enough to get rid of SUB?



 



No, there's a transcription error there.  SUB: LDX $0

SUB is used if you want to subtract the register pointed to by Y from R0.  CPR can be used to subtract a register pointed to by Y from a register pointed to by X.  One would be using R0 as the minuend often enough that it's worthwhile to keep those two bytes there.

 


SweetCX16

Posted: Sun Jan 09, 2022 1:19 am
by rje


On 1/8/2022 at 1:24 AM, Ed Minchau said:




No, there's a transcription error there.  SUB: LDX $0



Wait wait, this is an error?  This is the "source" of the source.  It's wrong?

http://www.6502.org/source/interpreters/sweet16.htm#Sweet_Sixteen_Source_sheldon

Ahhh, it IS a transcription error!

The original was LDY #$0.  Wow!

And here's Woz' article in Byte magazine... the source of that page on 6502.org.  The LDY $#0 is on page 152, about halfway down. 

https://archive.org/details/BYTE_Vol_02-11_1977-11_Sweet_16/page/n153/mode/1up

 

This listing has that line correct.  But, I suppose I have to check the remaining lines for errors!

http://www.easy68k.com/paulrsm/6502/SW16RB.TXT


SweetCX16

Posted: Sun Jan 09, 2022 4:56 am
by Ed Minchau


On 1/8/2022 at 6:19 PM, rje said:




Wait wait, this is an error?  This is the "source" of the source.  It's wrong?



http://www.6502.org/source/interpreters/sweet16.htm#Sweet_Sixteen_Source_sheldon



Ahhh, it IS a transcription error!



The original was LDY #$0.  Wow!



And here's Woz' article in Byte magazine... the source of that page on 6502.org.  The LDY $#0 is on page 152, about halfway down. 



https://archive.org/details/BYTE_Vol_02-11_1977-11_Sweet_16/page/n153/mode/1up



 



This listing has that line correct.  But, I suppose I have to check the remaining lines for errors!



http://www.easy68k.com/paulrsm/6502/SW16RB.TXT



Well now I don't know.  I was looking at the Sweet16.s linked on Tuesday.  Guess I'm going to have to look through everything now too.