A2osX/SYS/KERNEL.S.MATH.txt

120 lines
2.4 KiB
Plaintext
Raw Normal View History

2017-12-22 21:24:30 +00:00
NEW
PREFIX /A2OSX.BUILD
2017-12-22 21:24:30 +00:00
AUTO 4,1
*/--------------------------------------
2017-10-27 14:56:46 +00:00
* # FAdd,FSub,FMult,FDiv,FPwr
* Return X+Y, X-Y, X*Y, X/Y, X^Y
* ## In:
* PUSHW = X (*Float)
* PUSHW = Y (*Float)
* Y,A = Dest (*Float)
*\--------------------------------------
K.FAdd ldx #ROM.FADD
.HS 2C BIT ABS
K.FSub ldx #ROM.FSUB
.HS 2C BIT ABS
K.FMult ldx #ROM.FMULT
.HS 2C BIT ABS
K.FDiv ldx #ROM.FDIV
2017-10-27 14:56:46 +00:00
.HS 2C BIT ABS
K.FPwr ldx #ROM.PWR
>STYA FORPNT
phx
jsr MATH.PullFAC
jsr MATH.PullARG
2017-10-27 14:56:46 +00:00
bra MATH.Go
*/--------------------------------------
2017-10-27 14:56:46 +00:00
* # Log,Sqr,Exp,Cos,Sin,Tan,ATan
* Return Log(x), Sqr(x), E^X, Cos(x), Sin(X), Tan(x), ATan(x)
* ## In:
* PUSHW = X (*Float)
* Y,A = Dest (*Float)
*\--------------------------------------
2017-10-27 14:56:46 +00:00
K.Log ldx #ROM.LOG
.HS 2C BIT ABS
K.Sqr ldx #ROM.SQR
.HS 2C BIT ABS
K.Exp ldx #ROM.EXP
.HS 2C BIT ABS
K.Cos ldx #ROM.COS
.HS 2C BIT ABS
K.Sin ldx #ROM.SIN
.HS 2C BIT ABS
K.Tan ldx #ROM.TAN
.HS 2C BIT ABS
K.ATan ldx #ROM.ATAN
>STYA FORPNT
phx
jsr MATH.PullFAC
bra MATH.Go
*/--------------------------------------
* # Float
* Return return 'floated' long
* ## In:
* PUSHW = X (*long)
* Y,A = Dest (*float)
*\--------------------------------------
K.Float >STYA FORPNT
>PULLW INDEX
ldx #1
ldy #3
2017-10-27 14:56:46 +00:00
.1 lda (INDEX),y
sta FAC,x
inx
dey
bpl .1
stz FAC.SIGN
lda #$A0
sta FAC Exp=32
ldx #ROM.LTOF
phx
2017-10-27 14:56:46 +00:00
MATH.Go plx
lda SIGNFLG pPs !!!!
pha
2017-10-27 14:56:46 +00:00
jsr A2osX.ROMCALL
>ROMCALL GETFAC
pla
sta SIGNFLG
2017-10-27 14:56:46 +00:00
clc
rts
*/--------------------------------------
* # LRIntF
* Return Float rounded into a long
* ## In:
* PUSHW = X (*Float)
* Y,A = Dest (*long)
*\--------------------------------------
K.LRIntF >STYA FORPNT
jsr MATH.PullFAC
ldx #ROM.QINT
jsr A2osX.ROMCALL
2017-10-27 14:56:46 +00:00
ldx #1
ldy #3
.1 lda FAC,x
sta (FORPNT),y
inx
dey
bpl .1
clc
rts
2017-10-27 14:56:46 +00:00
*--------------------------------------
MATH.PullFAC >PULLW INDEX
>ROMCALL SETFAC
rts
*--------------------------------------
2017-10-27 14:56:46 +00:00
MATH.PullARG >PULLW INDEX
>ROMCALL SETARG
rts
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.MATH
LOAD /A2OSX.SRC/SYS/KERNEL.S
ASM