mirror of
https://github.com/nathanriggs/AppleIIAsm-Collection.git
synced 2024-12-03 03:52:16 +00:00
1b182844cc
- fixed a plethora of bugs - overhauled demo - integrated shared required library and macros - began early planning of floating-point routines and macros - created minified, no-comment versions of every routine
160 lines
2.8 KiB
Plaintext
160 lines
2.8 KiB
Plaintext
*
|
|
UDIVD16
|
|
LDA #0
|
|
BEQ UDIVMD
|
|
UREMD16
|
|
LDA #2
|
|
UDIVMD
|
|
STA _RSLTI
|
|
PLA
|
|
STA RETADR
|
|
PLA
|
|
STA RETADR+1
|
|
PLA
|
|
STA _DVSOR
|
|
PLA
|
|
STA _DVSOR+1
|
|
PLA
|
|
STA _DVEND
|
|
PLA
|
|
STA _DVEND+1
|
|
JSR UDIV
|
|
BCC DIVOK
|
|
DIVERR JMP EREXIT
|
|
DIVOK JMP OKEXIT
|
|
SDIVD16
|
|
LDA #0
|
|
BEQ SDIVMD
|
|
SREMD16
|
|
LDA #2
|
|
BNE SDIVMD
|
|
SDIVMD
|
|
STA _RSLTI
|
|
PLA
|
|
STA RETADR
|
|
PLA
|
|
STA RETADR+1
|
|
PLA
|
|
STA _DVSOR
|
|
PLA
|
|
STA _DVSOR+1
|
|
PLA
|
|
STA _DVEND
|
|
PLA
|
|
STA _DVEND+1
|
|
LDA _DVEND+1
|
|
EOR _DVSOR+1
|
|
STA _SQUOT
|
|
LDA _DVEND+1
|
|
STA _SREMD
|
|
LDA _DVSOR+1
|
|
BPL CHKDE
|
|
LDA #0
|
|
SEC
|
|
SBC _DVSOR
|
|
STA _DVSOR
|
|
LDA #0
|
|
SBC _DVSOR+1
|
|
STA _DVSOR+1
|
|
CHKDE
|
|
LDA _DVEND+1
|
|
BPL DODIV
|
|
LDA #0
|
|
SEC
|
|
SBC _DVEND
|
|
STA _DVEND
|
|
LDA #0
|
|
SBC _DVEND+1
|
|
STA _DVEND+1
|
|
DODIV
|
|
JSR UDIV
|
|
BCS EREXIT
|
|
LDA _SQUOT
|
|
BPL DOREM
|
|
LDA #0
|
|
SEC
|
|
SBC _DVEND
|
|
STA _DVEND
|
|
LDA #0
|
|
SBC _DVEND+1
|
|
STA _DVEND+1
|
|
DOREM
|
|
LDA _SREMD
|
|
BPL OKEXIT
|
|
LDA #0
|
|
SEC
|
|
SBC _DVEND+2
|
|
STA _DVEND+2
|
|
LDA #0
|
|
SBC _DVEND+3
|
|
STA _DVEND+3
|
|
JMP OKEXIT
|
|
EREXIT
|
|
LDA #0
|
|
STA _DVEND
|
|
STA _DVEND+1
|
|
STA _DVEND+2
|
|
STA _DVEND+3
|
|
STA RETURN
|
|
STA RETURN+1
|
|
LDA #2
|
|
STA RETLEN
|
|
SEC
|
|
BCS DVEXIT
|
|
OKEXIT
|
|
CLC
|
|
DVEXIT
|
|
LDX _RSLTI
|
|
LDA _DVEND,X
|
|
TAY
|
|
LDA _DVEND+1,X
|
|
TAX
|
|
STY RETURN
|
|
STX RETURN+1
|
|
LDA #2
|
|
STA RETLEN
|
|
LDA RETADR+1
|
|
PHA
|
|
LDA RETADR
|
|
PHA
|
|
*
|
|
RTS
|
|
UDIV
|
|
LDA #0
|
|
STA _DVEND+2
|
|
STA _DVEND+3
|
|
LDA _DVSOR
|
|
ORA _DVSOR+1
|
|
BNE OKUDIV
|
|
SEC
|
|
RTS
|
|
OKUDIV
|
|
LDX #16
|
|
DIVLP
|
|
ROL _DVEND
|
|
ROL _DVEND+1
|
|
ROL _DVEND+2
|
|
ROL _DVEND+3
|
|
CHKLT
|
|
SEC
|
|
LDA _DVEND+2
|
|
SBC _DVSOR
|
|
TAY
|
|
LDA _DVEND+3
|
|
SBC _DVSOR+1
|
|
BCC DECCNT
|
|
STY _DVEND+2
|
|
STA _DVEND+3
|
|
DECCNT
|
|
DEX
|
|
BNE DIVLP
|
|
ROL _DVEND
|
|
ROL _DVEND+1
|
|
CLC
|
|
RTS
|
|
_DVSOR DS 2
|
|
_DVEND DS 4
|
|
_SQUOT DS 1
|
|
_SREMD DS 1
|
|
_RSLTI DS 1
|