A2osX/SYS/KERNEL.S.MATH.txt

122 lines
2.4 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.BUILD
LOMEM $A00
INC 1
AUTO 6
*/--------------------------------------
* # 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
.HS 2C BIT ABS
K.FPwr ldx #ROM.PWR
>STYA FORPNT
phx
jsr MATH.PullFAC
jsr MATH.PullARG
bra MATH.Go
*/--------------------------------------
* # 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)
*\--------------------------------------
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
.1 lda (INDEX),y
sta FAC,x
inx
dey
bpl .1
stz FAC.SIGN
lda #$A0
sta FAC Exp=32
ldx #ROM.LTOF
phx
MATH.Go plx
lda SIGNFLG pPs !!!!
pha
jsr A2osX.ROMCALL
>ROMCALL GETFAC
pla
sta SIGNFLG
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
ldx #1
ldy #3
.1 lda FAC,x
sta (FORPNT),y
inx
dey
bpl .1
clc
rts
*--------------------------------------
MATH.PullFAC >PULLW INDEX
>ROMCALL SETFAC
rts
*--------------------------------------
MATH.PullARG >PULLW INDEX
>ROMCALL SETARG
rts
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.MATH
LOAD /A2OSX.SRC/SYS/KERNEL.S
ASM