mirror of
https://github.com/nathanriggs/AppleIIAsm-Collection.git
synced 2024-11-27 12:49:27 +00:00
110 lines
2.2 KiB
Plaintext
110 lines
2.2 KiB
Plaintext
*
|
|
*``````````````````````````````*
|
|
* MULT8 : 8BIT MULTIPLY (16BR) *
|
|
*- -*
|
|
* MULTIPLY TWO 8BIT NUMBERS TO *
|
|
* GET 16BIT RESULT. NUMBERS *
|
|
* MUST BE UNSIGNED. *
|
|
* *
|
|
* ORIGINAL AUTHOR IS WHITE *
|
|
* FLAME, AS SHARED ON *
|
|
* CODEBASE64. I HAVE MADE SOME *
|
|
* MINOR ALTERATIONS, BUT NOT *
|
|
* NEARLY ENOUGH TO CALL IT MY *
|
|
* OWN. *
|
|
*- -*
|
|
* CLOBBERS: *
|
|
* *
|
|
* FLAGS: ????---- REG: AXYM *
|
|
*- -*
|
|
* CYCLES: ??? *
|
|
* SIZE: *
|
|
*- -*
|
|
* USAGE: *
|
|
* *
|
|
* LDA #100 *
|
|
* PHA *
|
|
* PDA #200 *
|
|
* PHA *
|
|
* JSR MUL8 *
|
|
*- -*
|
|
* ENTRY *
|
|
* *
|
|
* LOW BYTE OF RETURN ADDRESS *
|
|
* HIGH BYTE OF RETURN ADDRESS *
|
|
* SECOND NUM TO BE MULTIPLIED *
|
|
* FIRST NUM TO BE MULTIPLIED *
|
|
*- -*
|
|
* EXIT *
|
|
* *
|
|
* .Y = LOW BYTE OF PRODUCT *
|
|
* .X = HI BYTE OF PRODUCT *
|
|
* .A = PRODUCT LENGTH (2) *
|
|
* *
|
|
* [RETURN] = PRODUCT *
|
|
* [RETLEN] = 2 (PRODUCT LEN) *
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
*
|
|
MULT8
|
|
*
|
|
** GET RETURN ADDRESS
|
|
*
|
|
PLA
|
|
STA RETADR
|
|
PLA
|
|
STA RETADR+1
|
|
*
|
|
** GET PARAMETERS
|
|
*
|
|
PLA
|
|
STA :MUL1
|
|
PLA
|
|
STA :MUL2
|
|
*
|
|
** INIT
|
|
*
|
|
LDA #$00
|
|
TAY
|
|
TAX
|
|
STY :MUL1H
|
|
BEQ :GOLOOP
|
|
*
|
|
:DOADD
|
|
CLC
|
|
ADC :MUL1
|
|
TAY
|
|
*
|
|
TXA
|
|
ADC :MUL1H
|
|
TAX
|
|
TYA
|
|
*
|
|
:LP
|
|
ASL :MUL1
|
|
ROL :MUL1H
|
|
:GOLOOP
|
|
LSR :MUL2
|
|
BCS :DOADD
|
|
BNE :LP
|
|
*
|
|
** RESTORE RETURN ADDRESS
|
|
*
|
|
LDA RETADR+1
|
|
PHA
|
|
LDA RETADR
|
|
PHA
|
|
*
|
|
STY RETURN
|
|
STX RETURN+1
|
|
LDA #2
|
|
STA RETLEN
|
|
*
|
|
RTS
|
|
*
|
|
** DATA
|
|
*
|
|
:MUL1 DS 1
|
|
:MUL2 DS 1
|
|
:MUL1H DS 1
|
|
*
|