A2osX/SYS/KERNEL.S.NUM.txt

124 lines
1.7 KiB
Plaintext
Raw Normal View History

2019-06-28 15:15:58 +00:00
NEW
AUTO 3,1
*--------------------------------------
ACC32.Sign .EQ FAC
ACC32 .EQ FAC+1
*--------------------------------------
NUM.A2STR10 jsr NUM.A2ACC32
clc
*--------------------------------------
* CS = signed long
* CC = unsigned long
*--------------------------------------
NUM.ACC322STR10 bcc .1
clc
lda ACC32+3
bpl .1
jsr NUM.ACC32NEG
sec
.1 php
ldx #4
.2 stz RESULT,x Clear all 5 bytes
dex
bpl .2
sed switch to BCD mode
ldx #32 let's roll 32 bits
.3 asl ACC32
rol ACC32+1
rol ACC32+2
rol ACC32+3
ldy #4
.4 lda RESULT,y
adc RESULT,y
sta RESULT,y
dey
bpl .4
dex
bne .3
cld
ldy #0
* ldx #0
plp
bcc .5
lda #'-'
sta $102,x
inx
.5 stz $102,x
.50 tya
lsr
tay
lda RESULT,y
bcs .6
lsr
lsr
lsr
lsr
.6 and #$0F
ora #$30
cmp #$30
lda $102,x
sta $102,x
.7 sta $102,x
inx
.8 iny
cpy #10
bne .50
stz $102,x
clc
.99 rts
*--------------------------------------
NUM.A2ACC32 sta ACC32
.HS 2C BIT ABS
NUM.ACC32ZERO stz ACC32
stz ACC32+1
stz ACC32+2
stz ACC32+3
rts
*--------------------------------------
NUM.ACC32NEG sec
ldy #0
ldx #3
.1 lda ACC32,y two's complement of X bytes
eor #$ff
adc #0
sta ACC32,y
iny
dex
bpl .1
rts
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.NUM
LOAD USR/SRC/SYS/KERNEL.S
ASM