Re: A89: TIOS int format


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

Re: A89: TIOS int format




> 1. Bytes of the integer in little endian;

Little endian?  That's opposite order, I'm assuming that's because it comes
out big endian off the ESI stack?

> These integers are kept on the expressions stack, or in TI-Basic
> variables (of course, in TI-Basic variables, there are two length
> bytes at the begining).

Same format in the BASIC vars as on the stack, in little endian?

> So, such structure can't be strictly represented
> using C syntax, because it requires something as
>
> struct big_int
> {
>   BYTE data[size];   // but size is not known in advance
>   BYTE size;
>   BYTE tag;
> }

I figured as much - but, getting to the root of my inquiry, if one were
designing a CAS, how would they create/use/reference a similar structure?
Or does it actually store everything with a special routine?  ie, you
couldn't do:

 // Ignore any unimportant errors, not sure if my syntax is all right
big_int* myint=malloc(size+2);
for(int i=0;i<size;i++)
    myint->data[i]=data[i];
myint->size=size;

???

> Such routines surely exist in TIOS, but the strange fact is that such
> routines are not in TIOS jump table (read: they are not usable).

That's really odd - they must plan to support that in the SDK, and it seems
like a rather obvious entry point to include. . .

> long long is 8 bytes. Multiplying and dividing longlongs are not
> open-coded but require library routines (like "longmul" patch, etc.).
> I am thinking about writing such routines too.

Shouldn't really be hard - I've got a some nice binary
multiplcation/division algorithms which could handle that easily. . .

> By the way, I wrote a small program which ilustrates operations with
> big integers. I uploaded it on ticalc before 5 days, but it is still
> not present in the archive. It may be interesting for 89 programmers,
> so I will attach it to this message. Sorry for posting binaries, but
> it may be useful for a lot of programmers...

binary, grrrr... and I can't receive it any cause I'm on the digest.  Can
you send me a copy privately, off the list?

    -Scott




Follow-Ups: References: