mirror of
https://github.com/nathanriggs/AppleIIAsm-Collection.git
synced 2024-11-24 07:31:09 +00:00
82d0e74c1a
some minor bugfixes, directory shuffling, added demo and utility disks
101 lines
2.4 KiB
Plaintext
101 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
|