Ti Constructor
 
Loading...
Searching...
No Matches
floatmath.c File Reference

Use the built in calculator floating point math. More...

Macros

#define PRINT_OP1()
 
floating point stack stuff
#define FPS   0x9824
 
Only odd op push and pops seem to exist
#define PushOP1()   bcall(0x43C9)
 
#define PushOP5()   bcall(0x43C0)
 
#define PushOP3()   bcall(0x43C3)
 
#define PopOP5()   bcall(0x4378)
 
#define PopOP3()   bcall(0x437B)
 
#define PopOP1()   bcall(0x437E)
 
Stores op1 to variable
#define OP1_TO_ANS()   bcall(0x4ABF)
 
#define Store_Theta()   bcall(0x4AC2)
 
#define Store_R()   bcall(0x4AC5)
 
#define Store_Y()   bcall(0x4AC8)
 
#define Store_N()   bcall(0x4ACB)
 
#define Store_T()   bcall(0x4ACE)
 
#define Store_X()   bcall(0x4AD1)
 
Math operations
#define MATH_FLOOR()   bcall(0x405D)
 op1 = floor(op1)
 
#define MATH_CEIL()   bcall(0x489A)
 op1 = ceil(op1)
 
#define TEN_TO_THE_POWER_OF_OP1()   bcall(0x40B7)
 10 ^ (op1) not sure the use of this but its here
 
#define INC_OP1()   bcall(0x4069)
 op1 += 1
 
#define DEC_OP1()   bcall(0x406C)
 op1 -= 1
 
#define NEG_OP1()   bcall(0x408D)
 op1 = -op1
 
#define DOUBLE_OP1()   bcall(0x4066)
 op1 *= 2
 
#define FP_ADD()   bcall(0x4072)
 op1 += op2
 
#define FP_SUB()   bcall(0x406F)
 op1 -= op2
 
#define FP_MULT()   bcall(0x4084)
 op1 *= op2
 
#define FP_DIV()   bcall(0x4099)
 op1 /= op2
 
#define SQUARE_OP1()   bcall(0x4081)
 op1 = op1 * op1
 
#define CUBE_OP1()   bcall(0x407B)
 op1 = op1 * op1 * op1
 
#define SQ_ROOT_OP1()   bcall(0x409C)
 op1 = sqrt( op1 )
 
#define FP_Recip()   bcall(0x4096)
 op1 = 1/op1
 
#define DEG_TO_RAD()   bcall(0x4075)
 op1 = Pi/180 * op1 may be bigger than 2pi
 
SUPER SLOW !!!! DON'T USE UNLESS NECESSARY

around 150,000 to 200,000 cycles, the base clock is 8 mhz and turbo is 16

#define Tan()   bcall(0x40C3)
 op1 = tan(op1)
 
#define Sin()   bcall(0x40BD)
 op1 = Sin( op1 )
 
#define Cos()   bcall(0x40C0)
 op1 = cos( op1 )
 
op(n) load instructions
#define OP3ToOP4()   bcall(0x4114)
 
#define OP1ToOP4()   bcall(0x4117)
 
#define OP2ToOP4()   bcall(0x411A)
 
#define OP4ToOP2()   bcall(0x411D)
 
#define OP1ToOP3()   bcall(0x4123)
 
#define OP5ToOP2()   bcall(0x4126)
 
#define OP5ToOP6()   bcall(0x4129)
 
#define OP5ToOP4()   bcall(0x412C)
 
#define OP1ToOP2()   bcall(0x412F)
 
#define OP6ToOP2()   bcall(0x4132)
 
#define OP6ToOP1()   bcall(0x4135)
 
#define OP4ToOP1()   bcall(0x4138)
 
#define OP5ToOP1()   bcall(0x413B)
 
#define OP3ToOP1()   bcall(0x413E)
 
#define OP6ToOP5()   bcall(0x4141)
 
#define OP4ToOP5()   bcall(0x4144)
 
#define OP3ToOP5()   bcall(0x4147)
 
#define OP2ToOP5()   bcall(0x414A)
 
#define OP2ToOP6()   bcall(0x414D)
 
#define OP1ToOP6()   bcall(0x4150)
 
#define OP1ToOP5()   bcall(0x4153)
 
#define OP2ToOP1()   bcall(0x4156)
 
#define OP2ToOP3()   bcall(0x416E);
 
#define OP4ToOP3()   bcall(0x4171);
 
#define OP5ToOP3()   bcall(0x4174);
 
#define OP4ToOP6()   bcall(0x4177);
 
Easy default values sets and op value to a whole number
#define OP4Set1()   bcall(0x4186)
 
#define OP3Set1()   bcall(0x4189)
 
#define OP2Set8()   bcall(0x418C)
 
#define OP2Set5()   bcall(0x418F)
 
#define OP2SetA()   bcall(0x4192)
 
#define OP2Set4()   bcall(0x4195)
 
#define OP2Set3()   bcall(0x4198)
 
#define OP1Set1()   bcall(0x419B)
 
#define OP1Set4()   bcall(0x419E)
 
#define OP1Set3()   bcall(0x41A1)
 
#define OP3Set2()   bcall(0x41A4)
 
#define OP1Set2()   bcall(0x41A7)
 
#define OP2Set2()   bcall(0x41AA)
 
#define OP2Set1()   bcall(0x41AD)
 
#define OP5Set0()   bcall(0x41B3)
 
#define OP4Set0()   bcall(0x41B6)
 
#define OP3Set0()   bcall(0x41B9)
 
#define OP2Set0()   bcall(0x41BC)
 
#define OP1Set0()   bcall(0x41BF)
 

Functions

int OPT1_TO_INT ()
 returns int of op1 "Converts a floating-point number in OP1 to a two-byte hexadecimal number in DE."
 
void MoveToOp1 (unsigned int v)
 Sets op1 to the value at a ram locations.
 
void MoveOp1To (unsigned int v)
 moves op1 to a ram location
 
void charToOp1 (char x)
 Set op1 equal to a char.
 
void intToOp1 (int x)
 set the value of an int to op1
 

Detailed Description

Use the built in calculator floating point math.

This library interfaces with the full normal calc float rutines. This is highly accurate but not very flexible with asm programs Also everything here is realitivly slow compared to intiger or fixed point math. And keep in mind that a bcall might modify registers, meaning that any bcall can corrupt any C variable See: https://taricorp.gitlab.io/83pa28d/lesson/week3/day18/index.html

Optional #defines

Macro Definition Documentation

◆ PRINT_OP1

#define PRINT_OP1 ( )
Value:
#asm \
ld a, 6 #endasm\
bcall(_DispOP1A)

Function Documentation

◆ charToOp1()

void charToOp1 ( char x)

Set op1 equal to a char.

Parameters
[x]number to be set

credit to Xeda112358 whose routine I modifed from https://www.cemetech.net/forum/viewtopic.php?t=1449&postdays=0&postorder=asc&start=126

◆ intToOp1()

void intToOp1 ( int x)

set the value of an int to op1

Parameters
[x]Value to be set to op1

◆ MoveOp1To()

void MoveOp1To ( unsigned int v)

moves op1 to a ram location

Parameters
[v]Ram location to copy op1 to

◆ MoveToOp1()

void MoveToOp1 ( unsigned int v)

Sets op1 to the value at a ram locations.

Parameters
[v]Ram location to copy op1 from

◆ OPT1_TO_INT()

int OPT1_TO_INT ( )

returns int of op1 "Converts a floating-point number in OP1 to a two-byte hexadecimal number in DE."