mirror of
https://github.com/A2osX/A2osX.git
synced 2024-08-14 13:29:02 +00:00
155 lines
2.9 KiB
Plaintext
155 lines
2.9 KiB
Plaintext
NEW
|
||
PREFIX
|
||
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`
|
||
* ## RETURN VALUE
|
||
* 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`
|
||
* ## RETURN VALUE
|
||
* 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)
|
||
* ## RETURN VALUE
|
||
* On stack (float)
|
||
*\--------------------------------------
|
||
K.Float ldx #4
|
||
|
||
.1 >PULLB FAC,x Reverse Order
|
||
dex
|
||
bne .1
|
||
|
||
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`
|
||
* ## RETURN VALUE
|
||
* On stack (long)
|
||
*\--------------------------------------
|
||
K.lrintf jsr MATH.PullFAC
|
||
|
||
ldx #ROM.QINT
|
||
jsr GP.ROMCALL
|
||
|
||
ldx #0
|
||
|
||
.1 >PUSHB FAC+1,x
|
||
inx
|
||
cpx #4
|
||
bne .1
|
||
|
||
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 USR/SRC/SYS/KERNEL.S.MATH
|
||
LOAD USR/SRC/SYS/KERNEL.S
|
||
ASM
|