@@ -130,6 +130,29 @@ long __fastcall__ ria_call_long (unsigned char op);
130130#define RIA_OP_GETLABEL 0x2D
131131#define RIA_OP_GETFREE 0x2E
132132
133+ /* Math coprocessor opcodes */
134+ #define RIA_OP_MTH_MUL8 0x30
135+ #define RIA_OP_MTH_MUL16 0x31
136+ #define RIA_OP_MTH_MULS16 0x32
137+ #define RIA_OP_MTH_DIV16 0x33
138+ #define RIA_OP_MTH_SQRT32 0x34
139+ #define RIA_OP_MTH_FADD 0x38
140+ #define RIA_OP_MTH_FSUB 0x39
141+ #define RIA_OP_MTH_FMUL 0x3A
142+ #define RIA_OP_MTH_FDIV 0x3B
143+ #define RIA_OP_MTH_FSQRT 0x3C
144+ #define RIA_OP_MTH_FSIN 0x3D
145+ #define RIA_OP_MTH_FCOS 0x3E
146+ #define RIA_OP_MTH_FATAN2 0x3F
147+ #define RIA_OP_MTH_FPOW 0x40
148+ #define RIA_OP_MTH_FLOG 0x41
149+ #define RIA_OP_MTH_FEXP 0x42
150+ #define RIA_OP_MTH_FTOI 0x43
151+ #define RIA_OP_MTH_ITOF 0x44
152+ #define RIA_OP_MTH_DADD 0x48
153+ #define RIA_OP_MTH_DMUL 0x49
154+ #define RIA_OP_MTH_DDIV 0x4A
155+
133156/* RIA attribute IDs */
134157
135158#define RIA_ATTR_ERRNO_OPT 0x00
@@ -185,6 +208,39 @@ int __fastcall__ f_setlabel (const char* name);
185208int __fastcall__ f_getlabel (const char * path , char * label );
186209int __fastcall__ f_getfree (const char * name , unsigned long * free , unsigned long * total );
187210
211+ /* Math coprocessor API */
212+
213+ /* IEEE 754 single-precision float represented as raw 32-bit pattern */
214+ typedef unsigned long fp32_t ;
215+
216+ /* Integer math */
217+ unsigned int __fastcall__ mth_mul8 (unsigned char a , unsigned char b );
218+ unsigned long __fastcall__ mth_mul16 (unsigned int a , unsigned int b );
219+ long __fastcall__ mth_muls16 (int a , int b );
220+ unsigned long __fastcall__ mth_div16 (unsigned long dividend , unsigned int divisor );
221+ unsigned int __fastcall__ mth_sqrt32 (unsigned long n );
222+
223+ /* Float32 conversions */
224+ fp32_t __fastcall__ mth_itof (long i );
225+ long __fastcall__ mth_ftoi (fp32_t x );
226+
227+ /* Float32 arithmetic */
228+ fp32_t __fastcall__ mth_addf (fp32_t a , fp32_t b );
229+ fp32_t __fastcall__ mth_subf (fp32_t a , fp32_t b );
230+ fp32_t __fastcall__ mth_mulf (fp32_t a , fp32_t b );
231+ fp32_t __fastcall__ mth_divf (fp32_t a , fp32_t b );
232+
233+ /* Float32 unary */
234+ fp32_t __fastcall__ mth_sqrtf (fp32_t x );
235+ fp32_t __fastcall__ mth_sinf (fp32_t x );
236+ fp32_t __fastcall__ mth_cosf (fp32_t x );
237+ fp32_t __fastcall__ mth_logf (fp32_t x );
238+ fp32_t __fastcall__ mth_expf (fp32_t x );
239+
240+ /* Float32 binary transcendental */
241+ fp32_t __fastcall__ mth_atan2f (fp32_t y , fp32_t x );
242+ fp32_t __fastcall__ mth_powf (fp32_t base , fp32_t exp );
243+
188244/* XREG location helpers */
189245
190246#define xreg_ria_keyboard (...) xreg(0, 0, 0, __VA_ARGS__)
0 commit comments