[TI ASM] Floating Point to binary

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
leofox
Calc Master
Posts: 1064
Joined: Fri 17 Dec, 2004 3:22 pm
Location: Probably playing DDR
Contact:

[TI ASM] Floating Point to binary

Post by leofox »

So, here's the thing. I made a basic program for the input of variables, and an assembly program to do something with the variables (if you want to know what, search for Gravlab II).
The problem is, I can't get the ASM program to read the basic data. I have it set in a list, so by using some romcalls I can easily get an element in op1. The problem is converting it to the format my program uses: 24bit big endian binary variables. I know of ConvOp1, but that only goes up to 9999. And I don't think it can handle negatives. The significant data in each variable is usually only 2 bytes, but bringing it down to less is hard..

I have thought of some solutions:
-Make my own routine that can convert op1 numbers to my format (HARD)
-Find a routine that can at least properly convert it to 16bit (Probably doesnt exist)
-Make the basic program output in a long string, then convert that to binary (HARD, requires whole change of the basic input. Also, ASM string to binary NEVER works for me)
-Limit the input accuracy (unacceptable)
-Use some clever pre- and post- transfer calculation to make sure it more or less works (doable, but i'd still ahve to limit input a bit)
-have the ASM program do the input too (impossible, why do you think i splitted it in the first place..)

So yeah.. i hope you can understand what i'm trying to say. How would you do it anyway? Can you give me some advice on whats the best way?
Image
Image
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

I doubt you'd find a pre-existing solution, given that for some bizarre reason you insist on using non-standard big-endian values.

You say you use 24-bit values. How is that split up?

The easiest method I can think of would be to premultiply the floating point value and then store that as an integer into a variable (plus some swapping of bytes around to accomodate the big-endian weirdness). If you were using 16.8 fixed point (16-bits for the whole part and 8 for the fractional), multiply the floating point value by 256, truncate the result to an integer then store the integral part.
leofox
Calc Master
Posts: 1064
Joined: Fri 17 Dec, 2004 3:22 pm
Location: Probably playing DDR
Contact:

Post by leofox »

benryves wrote:I doubt you'd find a pre-existing solution, given that for some bizarre reason you insist on using non-standard big-endian values.

You say you use 24-bit values. How is that split up?

The easiest method I can think of would be to premultiply the floating point value and then store that as an integer into a variable (plus some swapping of bytes around to accomodate the big-endian weirdness). If you were using 16.8 fixed point (16-bits for the whole part and 8 for the fractional), multiply the floating point value by 256, truncate the result to an integer then store the integral part.
It's 8 for the whole part, then 16 for the fraction. I told you, the storing isn't the problem. Even a routine that converts floating point to a 16bit value would do, kinda like ConvOP1, but that works with numbers larger than 9999.
The big endian doesnt matter, i can always swap stuff around.
Image
Image
snowman_hater
New Member
Posts: 19
Joined: Mon 01 Jan, 2007 12:17 pm
Location: Ticalc, Obsessing over Stats

Post by snowman_hater »

leofox wrote:It's 8 for the whole part, then 16 for the fraction. I told you, the storing isn't the problem. Even a routine that converts floating point to a 16bit value would do, kinda like ConvOP1, but that works with numbers larger than 9999.
The big endian doesnt matter, i can always swap stuff around.
So do you just need rounded integer values, or do the decimal parts need to be preserved? What is the place value of the various bits in the decimal part of your binary number?
Post Reply