AppleIIAsm-Collection/disks/disk3_math8_math16/T.MATH8.DIV8
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

94 lines
2.1 KiB
Plaintext

*
*``````````````````````````````*
* DIV8 :: 8BIT DIVISION (8BR) *
*- -*
* DIVIDE ONE 8BIT NUMBER BY *
* ANOTHER TO GET AN 8BIT *
* RESULT. *
* *
* 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 #200 *
* PHA *
* PDA #10 *
* PHA *
* JSR DIV8 *
*- -*
* 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 *
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
DIV8
*
** GET RETURN ADDRESS
*
PLA
STA :RETADR
PLA
STA :RETADR+1
*
** GET PARAMETERS
*
PLA
STA :DVEND
PLA
STA :DVSOR
*
LDA #$00
LDX #8
ASL :DVSOR
:L1 ROL
CMP :DVEND
BCC :L2
SBC :DVEND
:L2 ROL :DVSOR
DEX
BNE :L1
STA :REM
*
** RESTORE RETURN ADDRESS
*
LDA :RETADR+1
PHA
LDA :RETADR
PHA
*
** LOAD QUOTIENT INTO A, REMAINDER INTO X
*
LDX :REM ; REMAINDER TO X
*
LDA :DVSOR
RTS
*
** DATA
*
:REM DS 1
:DVEND DS 1
:DVSOR DS 1
:RETADR DS 2
*