2017-12-22 21:24:30 +00:00
|
|
|
|
NEW
|
2019-05-25 19:24:07 +00:00
|
|
|
|
AUTO 3,1
|
2017-10-26 16:01:54 +00:00
|
|
|
|
*/--------------------------------------
|
2017-10-27 14:56:46 +00:00
|
|
|
|
* # FAdd,FSub,FMult,FDiv,FPwr
|
|
|
|
|
* Return X+Y, X-Y, X*Y, X/Y, X^Y
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* `>PUSHF X (float)`
|
|
|
|
|
* `>PUSHF Y (float)`
|
|
|
|
|
* `>SYSCALL fadd`
|
|
|
|
|
* `>SYSCALL fsub`
|
|
|
|
|
* `>SYSCALL fmult`
|
|
|
|
|
* `>SYSCALL fdiv`
|
|
|
|
|
* `>SYSCALL fpwr`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* On stack (float)
|
2017-10-26 16:01:54 +00:00
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.FAdd ldx #ROM.FADD
|
|
|
|
|
.HS 2C BIT ABS
|
|
|
|
|
K.FSub ldx #ROM.FSUB
|
2017-10-27 06:36:46 +00:00
|
|
|
|
.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
|
2018-06-14 15:31:36 +00:00
|
|
|
|
|
2017-10-26 16:01:54 +00:00
|
|
|
|
phx
|
|
|
|
|
jsr MATH.PullFAC
|
|
|
|
|
jsr MATH.PullARG
|
2018-06-14 15:31:36 +00:00
|
|
|
|
|
|
|
|
|
plx
|
2019-03-02 20:47:58 +00:00
|
|
|
|
jmp GP.RomCallPushFAC
|
2017-10-27 06:36:46 +00:00
|
|
|
|
*/--------------------------------------
|
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)
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* ## 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
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* `>PUSHF x (Float)`
|
|
|
|
|
* `>SYSCALL log`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-06-13 15:18:08 +00:00
|
|
|
|
* On stack (Float)
|
2017-10-27 06:36:46 +00:00
|
|
|
|
*\--------------------------------------
|
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
|
2018-06-14 15:31:36 +00:00
|
|
|
|
|
2017-10-27 14:56:46 +00:00
|
|
|
|
phx
|
|
|
|
|
jsr MATH.PullFAC
|
2018-06-14 15:31:36 +00:00
|
|
|
|
|
|
|
|
|
plx
|
2019-03-02 20:47:58 +00:00
|
|
|
|
jmp GP.RomCallPushFAC
|
2017-10-31 15:25:16 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* # float
|
2018-06-13 15:18:08 +00:00
|
|
|
|
* Return 'floated' long
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* ## C
|
|
|
|
|
* `float f = (float)12345678;
|
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* `>PUSHL X` (long)
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* On stack (float)
|
2017-10-31 15:25:16 +00:00
|
|
|
|
*\--------------------------------------
|
2018-08-24 14:54:02 +00:00
|
|
|
|
K.Float ldx #4
|
|
|
|
|
|
|
|
|
|
.1 >PULLB FAC,x Reverse Order
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
|
|
|
|
|
2017-10-31 15:25:16 +00:00
|
|
|
|
stz FAC.SIGN
|
|
|
|
|
lda #$A0
|
|
|
|
|
sta FAC Exp=32
|
|
|
|
|
|
|
|
|
|
ldx #ROM.LTOF
|
|
|
|
|
|
2019-03-02 20:47:58 +00:00
|
|
|
|
jmp GP.RomCallPushFAC
|
2017-10-30 16:11:07 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* # lrintf
|
|
|
|
|
* Return float rounded into a long
|
|
|
|
|
* ## C
|
|
|
|
|
* `long int lrintf (float x);`
|
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* `>PUSHF x`
|
|
|
|
|
* `>SYSCALL lrintf`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-06-13 15:18:08 +00:00
|
|
|
|
* On stack (long)
|
2017-10-30 16:11:07 +00:00
|
|
|
|
*\--------------------------------------
|
2018-06-18 15:48:00 +00:00
|
|
|
|
K.lrintf jsr MATH.PullFAC
|
2018-06-13 15:18:08 +00:00
|
|
|
|
|
2017-10-30 16:11:07 +00:00
|
|
|
|
ldx #ROM.QINT
|
2018-06-13 15:18:08 +00:00
|
|
|
|
jsr GP.ROMCALL
|
2017-10-27 14:56:46 +00:00
|
|
|
|
|
2018-08-24 14:54:02 +00:00
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.1 >PUSHB FAC+1,x
|
|
|
|
|
inx
|
|
|
|
|
cpx #4
|
|
|
|
|
bne .1
|
2018-06-22 14:59:24 +00:00
|
|
|
|
|
2017-10-30 16:11:07 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2017-10-27 14:56:46 +00:00
|
|
|
|
*--------------------------------------
|
2018-06-13 15:18:08 +00:00
|
|
|
|
MATH.PullARG ldx #ROM.SETARG
|
|
|
|
|
.HS 2C BIT ABS
|
|
|
|
|
MATH.PullFAC ldx #ROM.SETFAC
|
|
|
|
|
|
|
|
|
|
>LDYA pStack
|
|
|
|
|
jsr GP.ROMCALL
|
|
|
|
|
|
|
|
|
|
lda pStack
|
|
|
|
|
clc
|
|
|
|
|
adc #5
|
|
|
|
|
sta pStack
|
2017-10-27 14:56:46 +00:00
|
|
|
|
rts
|
2017-10-26 16:01:54 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2018-11-17 17:17:13 +00:00
|
|
|
|
SAVE USR/SRC/SYS/KERNEL.S.MATH
|
|
|
|
|
LOAD USR/SRC/SYS/KERNEL.S
|
2017-10-26 16:01:54 +00:00
|
|
|
|
ASM
|