AppleIIAsm-Collection/disks/disk3_math/T.SUBT16
nathanriggs 16c1731e54 Strings 0.2.0 update
- bugfixes
- implemented required library
- commenting updates
- .min of every routine
2018-12-22 20:35:05 -05:00

103 lines
2.4 KiB
Plaintext

*
*``````````````````````````````*
* SUBT16 :: SUBTRACT WORDS *
*- -*
* SUBTRACT ONE 16BIT NUMBER *
* FROM ANOTHER, RETURNING THE *
* RESULT IN .Y (LOW), .X (HI). *
* SIGNED OR UNSIGNED. *
*- -*
* CLOBBERS: *
* *
* FLAGS: ????---- REG: AXYM *
*- -*
* CYCLES: ??? *
* SIZE: *
*- -*
* USAGE: *
* *
* LDA #>1000 ; MINUEND *
* PHA *
* LDA #<1000 *
* PHA *
* LDA #>500 ; SUBTRAHEND *
* PHA *
* LDA #<500 *
* PHA *
* JSR SUBT16 *
*- -*
* ENTRY *
* *
* TOP OF STACK *
* *
* LOW BYTE OF RETURN ADDRESS *
* HI BYTE OF RETURN ADDRESS *
* LOW BYTE OF SUBTRAHEND *
* HIGH BYTE OF SUBTRAHEND *
* LOW BYTE OF MINUEND *
* HIGH BYTE OF MINUEND *
*- -*
* EXIT *
* *
* TOP OF STACK *
* *
* LOW BYTE OF RETURN ADDRESS *
* HI BYTE OF RETURN ADDRESS *
* *
* .Y = RESULT LOW BYTE *
* .X = RESULT HIGH BYTE *
* .A = LOW BYTE OF RET ADDR *
* *
* [RETURN] = RESULT (2 BYTES) *
* [RETLEN] = 2 (RESULT LENGTH) *
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
SUBT16
*
** GET RETURN ADDRESS
*
PLA
STA RETADR
PLA
STA RETADR+1
*
** GET PARAMETERS
*
PLA
STA :SUBT
PLA
STA :SUBT+1 ; SUBTRAHEND
PLA
STA :MINU
PLA
STA :MINU+1 ; MINUEND
*
** MINUEND - SUBTRAHEND
*
LDA :MINU
SEC
SBC :SUBT
TAY ; LOW BYTE
STY RETURN
LDA :MINU+1
SBC :SUBT+1
TAX ; HIGH BYTE
STX RETURN+1
LDA #2
STA RETLEN
*
** RESTORE RETURN ADDRESS
*
LDA RETADR+1
PHA
LDA RETADR
PHA
*
RTS
*
** DATA
*
:MINU DS 2
:SUBT DS 2
*