A92: Re: what can possibly be wrong?


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

A92: Re: what can possibly be wrong?




> This is my keylib.asm library:
>
>     include "doorsos.h"
>     xdef    _ti89
>     xdef    _ti92plus
>     xdef    _library
>     xdef    keylib@0000
> keylib@0000:
>     tst.w   (doorsos::kb_vars+$1C)      ; has a key been pressed?
>     beq \put_zero           ; if not, go to put_zero
>     move.w  (doorsos::MaxHandles+$1E),d0    ; puts the value of the keypress
> into d0
>     clr.w   (doorsos::kb_vars+$1C)      ; clear key buffer
>     bra \done               ; exits out
> \put_zero
>         move.w  #0,d0
> \done
>     rts
>     end
>
> However, when l try to call this library from an program, l either get the
> message "function did not return a value" or "Illegal instruction" appears on
> the status line and the program exits.  lt seems to me that whether or not a
> key is pressed that a value is moved into d0, but yet the messages say no.
> What is happening?
> The C program is calling the library, and in doing so it stores whatever
> keylib@0000 returns in d0 into another variable.

To use a library function in a C program you have to add something like this to
either the C header file for the library or directly in your program:

#define MyLibraryFunction mylib@0001
int MyLibraryFunction(void);

...making sure that the return value and arguments are defined correctly, just
like for a normal C function. If you don't, the C compiler won't know if the
returned value exists, what to do with it, and what to pass the arguments as.


 / Niklas Brunlid
Check out Prosit for the TI-89 / TI-92+ at http://prosit.ticalc.org
Random PQF Quote follows:

Still, it was a relief to get away from that macabre sight. Gander
considered that gnolls didn't look any better inside than out. He hated
their guts.
        -- (Terry Pratchett, Equal Rites)




References: