edit(1):
I was thinking of 8 bit index registers and 8 bit data bus width. Just plain 6502
Code: Select all
PLA
ADC something
Code: Select all
ADC S ; pull data to add from stack
Code: Select all
PLA
ADC something
Code: Select all
ADC S ; pull data to add from stack
Code: Select all
TSX
CLC
LDA 101,X
ADC 103,X
STA 103,X
LDA 102,X
ADC 104,X
STA 104,XCode: Select all
UM_STAR: LDA #0 ; Unsigned, mixed-precision (16-bit by 16-bit input, 32-bit output)
PHA ; multiply. Add a variable byte to the stack, initializing it as 0.
TSX ; Now 101,X holds that new variable, 102,X and 103,X hold the return
LSR $107,X ; address, and 104,X to 107,X holds the inputs and later the outputs.
ROR $106,X
FOR_Y 16, DOWN_TO, 0 ; Loop 16x. The DEY, BNE in NEXT_Y below will drop through on 0.
IF_CARRY_SET
CLC
PHA ; Note that the PHA (and PLA below) doesn't affect the indexing.
LDA $101,X
ADC $104,X
STA $101,X
PLA
ADC $105,X
END_IF
ROR
ROR $101,X
ROR $107,X
ROR $106,X
NEXT_Y
STA $105,X
PLA ; Retrieve the variable byte we added at the top, cleaning up the stack.
STA $104,X ; Again note that the PLA changed S but not X, so the 104 is still 104.
RTS
;------------------
Code: Select all
PushY:
PHX
PHA
LDX BIOS_SwsSP
TYA
STA SWSTACK_BASE, X
INX
STX BIOS_SwsSP
PLA
PLX
RTSCode: Select all
PushY:
PHX
LDX BIOS_SwsSP
STY SWSTACK_BASE, X
INX
STX BIOS_SwsSP
PLX
RTS