mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-26 13:49:18 +00:00
148 lines
2.8 KiB
Plaintext
148 lines
2.8 KiB
Plaintext
NEW
|
||
PREFIX /A2OSX.BUILD
|
||
AUTO 4,1
|
||
*/--------------------------------------
|
||
* # FAdd,FSub,FMult,FDiv,FPwr
|
||
* Return X+Y, X-Y, X*Y, X/Y, X^Y
|
||
* ## ASM
|
||
* **In:**
|
||
* `>PUSHF X (float)`
|
||
* `>PUSHF Y (float)`
|
||
* `>SYSCALL fadd`
|
||
* `>SYSCALL fsub`
|
||
* `>SYSCALL fmult`
|
||
* `>SYSCALL fdiv`
|
||
* `>SYSCALL fpwr`
|
||
* **Out:**
|
||
* On stack (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
|
||
|
||
phx
|
||
jsr MATH.PullFAC
|
||
jsr MATH.PullARG
|
||
|
||
plx
|
||
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)
|
||
* ## C
|
||
* `float log ( float x);`
|
||
* `float sqr ( float x);`
|
||
* `float exp ( float x);`
|
||
* `float cos ( float x);`
|
||
* `float sin ( float x);`
|
||
* `float tan ( float x);`
|
||
* `float atan ( float x);`
|
||
* ## ASM
|
||
* **In:**
|
||
* `>PUSHF x (Float)`
|
||
* `>SYSCALL log`
|
||
* **Out:**
|
||
* On stack (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
|
||
|
||
phx
|
||
jsr MATH.PullFAC
|
||
|
||
plx
|
||
bra MATH.Go
|
||
*/--------------------------------------
|
||
* # float
|
||
* Return 'floated' long
|
||
* ## C
|
||
* `float f = (float)12345678;
|
||
* ## ASM
|
||
* **In:**
|
||
* `>PUSHL X` (long)
|
||
* **Out:**
|
||
* On stack (float)
|
||
*\--------------------------------------
|
||
K.Float >PULLW FAC+1
|
||
>PULLW FAC+3
|
||
|
||
stz FAC.SIGN
|
||
lda #$A0
|
||
sta FAC Exp=32
|
||
|
||
ldx #ROM.LTOF
|
||
|
||
MATH.Go jsr GP.ROMCALL
|
||
|
||
lda pStack
|
||
sec
|
||
sbc #5
|
||
sta pStack
|
||
sta FORPNT
|
||
lda pStack+1
|
||
sta FORPNT+1
|
||
|
||
ldx #ROM.GETFAC
|
||
jsr GP.ROMCALL
|
||
|
||
clc
|
||
rts
|
||
*/--------------------------------------
|
||
* # lrintf
|
||
* Return float rounded into a long
|
||
* ## C
|
||
* `long int lrintf (float x);`
|
||
* ## ASM
|
||
* **In:**
|
||
* `>PUSHF x`
|
||
* `>SYSCALL lrintf`
|
||
* **Out:**
|
||
* On stack (long)
|
||
*\--------------------------------------
|
||
K.lrintf jsr MATH.PullFAC
|
||
|
||
ldx #ROM.QINT
|
||
jsr GP.ROMCALL
|
||
|
||
>PUSHW FAC+1
|
||
>PUSHW FAC+3
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
MATH.PullARG ldx #ROM.SETARG
|
||
.HS 2C BIT ABS
|
||
MATH.PullFAC ldx #ROM.SETFAC
|
||
|
||
>LDYA pStack
|
||
>STYA INDEX
|
||
jsr GP.ROMCALL
|
||
|
||
lda pStack
|
||
clc
|
||
adc #5
|
||
sta pStack
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/SYS/KERNEL.S.MATH
|
||
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
||
ASM
|