AppleIIAsm-Collection/disks/disk3_math8_math16/T.MATH8.MUL8
nathanriggs 875dd80998 stdio 0.2.0 updates
- fixed a bunch of bugs
- separated common and stdio libraries
- commenting upgrades
- created min versions of each library
2018-12-14 21:23:32 -05:00

101 lines
2.1 KiB
Plaintext

*
*``````````````````````````````*
* MUL8 :: 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 = HIGH BYTE OF PRODUCT *
* X = LOW BYTE OF PRODUCT *
* A = LOW BYTE OF PRODUCT *
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
MUL8
*
** GET RETURN ADDRESS
*
PLA
STA :RETADR
PLA
STA :RETADR+1
*
** GET PARAMETERS
*
PLA
STA :MUL1
PLA
STA :MUL2
*
** INIT
*
LDA #$00
TAX
STX :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
*
RTS
*
** DATA
*
:MUL1 DS 1
:MUL2 DS 1
:RETADR DS 2
:MUL1H DS 1