A89: Re: Floats and functions from assembly


[Prev][Next][Index][Thread]

A89: Re: Floats and functions from assembly




Hi!

> First of all, how do I call a function from an assembly program? That is,
> say I define a function f(t) in the main directory. I need to know [1]
how
> to find this function and call it [2] how to pass in the independent
> variable(s) and [3] how to get the result back.  (For that matter, I
might
> want to pass the functions in as parameters to the assembly program.)

Your questions are very hard, especially if you are beginner, but I will
give to you the basic ideas:

Executing BASIC functions from ASM is not a very good idea from the aspect
of speed, but it is possible via the expressions stack, which uses RPN
(Reverse Polish Notation). You can construct the function call on estack,
then call NG_approxESI or NG_rationalESI to evaluate it in approx or 
exact mode respectively. There is also much easier (but slower) method:
construct a string which contains exact call as you want, with concrete
argument values. For example, if the function is f(t), and you want to
pass t=37, construct a string "f(37)", then pass such string as the 
argument to TIOS ROM call push_parse_text. It will convert your string in
RPN and push it on estack. Then, you can call NG_approxESI or 
NG_rationalESI passing global variable top_estack as the parameter. If
you don't understand this, I will repeat: your question is not 
elementary! You need to know much about TIOS (see below for a reference).

Once you called NG_approxESI or NG_rationalESI, the result is on the
top of estack, and you can call various functions which pops the result
from the stack, like estack_number_to_Float.

> Second, once I get the result, I'll need to be working with floating
point
> values. How does the TIOS deal with floats in the absence of built-in
float
> support on the cpu?

TIOS has built-in floating point emulator, which works with floats in
SMAP II BCD format.

> Finally, I'll need to call some built-in math fucntions (trig, in
> particular).

TIOS has a lot of math functions, including trig, etc. To call them (sin
for example), push the float number (10-bytes) to the machine stack,
load A6 register to point to the end byte of a 10-byte long buffer where
the result will be stored, then call the function. The procedure is same
for functions with two arguments (like bcdadd - floating point addition).
Of course, you need to know a format of a floating point numbers. The
reference is also given below...

> I've seen a bunch of 89/92 assembly tutorials and stuff around the web,
but
> none of them really seemed to address my particular difficulties.

ASM tutorials are mostly about writing games. I think that the best
reference about TIOS ROM calls etc. may be found in my documentation 
which comes with TIGCCLIB library for TI-GCC compiler. Download it from

www.ticalc.org/pub/win/asm

All infos in this reference is given using C-language syntax, but basic
infos about how to interpret these info in ASM is also given...

Cheers,

Zeljko Juric