Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: ACagliano on October 01, 2011, 08:25:57 pm

Title: Getting Data in Op Vars
Post by: ACagliano on October 01, 2011, 08:25:57 pm
Let us assume that I have some floating point data in RAM that I want to move to an Op variable. How would I get it there correctly. I know about the type byte, the exponents, and all that, but I know that, in the actual bytes 2-8, the data is in hex, but you still see your actual decimal numbers, 2 to a byte. How the blazes do I manage that?
Title: Re: Getting Data in Op Vars
Post by: calc84maniac on October 01, 2011, 09:22:26 pm
If you have a floating point number you want to move to an OP variable, all you have do is copy 9 bytes. :) There are lots of bcalls to do that for you if you want to reduce code size (at a bit of a speed cost). Note, copying 9 bytes to OP1 can be done with a single byte of code that doesn't incur a full bcall overhead, that is, rst rMOV9TOOP1
Title: Re: Getting Data in Op Vars
Post by: ACagliano on October 02, 2011, 10:36:06 am
I know HOW to move it. My issue is getting the floating point into the correct format.
Title: Re: Getting Data in Op Vars
Post by: Xeda112358 on October 02, 2011, 10:48:40 am
I am confused about what you mean? What exactly are you trying to copy? From where exactly?

EDIT: If you are copying floating point data, it is already in the correct format. So if that is the case, just copy it to OP1 by pointing HL to the data and then using the rst mentioned :)
Title: Re: Getting Data in Op Vars
Post by: ACagliano on October 02, 2011, 05:51:08 pm
No, it will not already be FP data. I Will be trying to convert the results of an getkey input routine (numerical data only) into FP data.
Title: Re: Getting Data in Op Vars
Post by: thepenguin77 on October 02, 2011, 06:53:28 pm
Ok, so you could be in one of two situations:

1. You have a text string with the numerical data
    If this is the case, the answer is pretty easy, copy low nibbles of the text data into the data section OP1. Then, take the number of nibbles you copied, add it to 7F, and store that in the exponent field.

Example:
  Text = 12345 = $31, $32, $33, $34, $35 Copy this into OP1, OP1 = 00 84 12 34 50 00 00 00 00

2. You have a hex number in some register/location
    This one is way easier. There are two bcalls you'll be interested in. bcall(_setXXOp1) and bcall(_setXXXXOp2). The first one uses A and the second one uses HL. Either way, OP1/OP2 will be formatted correctly.
Title: Re: Getting Data in Op Vars
Post by: ACagliano on October 03, 2011, 10:34:18 am
Ok, so you could be in one of two situations:

1. You have a text string with the numerical data
    If this is the case, the answer is pretty easy, copy low nibbles of the text data into the data section OP1. Then, take the number of nibbles you copied, add it to 7F, and store that in the exponent field.

Example:
  Text = 12345 = $31, $32, $33, $34, $35 Copy this into OP1, OP1 = 00 84 12 34 50 00 00 00 00

This is the way it will be. The issue is, the numerical string MAY contain a decimal point.
Title: Re: Getting Data in Op Vars
Post by: calc84maniac on October 03, 2011, 10:41:40 am
Ok, so you could be in one of two situations:

1. You have a text string with the numerical data
    If this is the case, the answer is pretty easy, copy low nibbles of the text data into the data section OP1. Then, take the number of nibbles you copied, add it to 7F, and store that in the exponent field.

Example:
  Text = 12345 = $31, $32, $33, $34, $35 Copy this into OP1, OP1 = 00 84 12 34 50 00 00 00 00

This is the way it will be. The issue is, the numerical string MAY contain a decimal point.
In that case, take the number of nibbles you copied before the decimal point and add $7F to get the exponent.
Title: Re: Getting Data in Op Vars
Post by: ACagliano on October 03, 2011, 10:51:01 am
Ok. Thanks.
Title: Re: Getting Data in Op Vars
Post by: calc84maniac on October 03, 2011, 12:04:18 pm
Hmm, I just realized that you'll also have to properly handle non-significant zeros, like if they type 01337 or 0.0001. The only FP value that is allowed to start with a 0 nibble is zero itself. Leading zeros before the decimal point can simply be ignored, but leading zeros after the decimal point should also decrease the exponent.
Title: Re: Getting Data in Op Vars
Post by: ACagliano on October 03, 2011, 12:12:31 pm
Hmm, I just realized that you'll also have to properly handle non-significant zeros, like if they type 01337 or 0.0001. The only FP value that is allowed to start with a 0 nibble is zero itself. Leading zeros before the decimal point can simply be ignored, but leading zeros after the decimal point should also decrease the exponent.

Easy. Just ignore every zero until you hit a non-zero character.