Author Topic: Getting Data in Op Vars  (Read 6912 times)

0 Members and 1 Guest are viewing this topic.

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Getting Data in Op Vars
« 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?

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Getting Data in Op Vars
« Reply #1 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
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Getting Data in Op Vars
« Reply #2 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.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Getting Data in Op Vars
« Reply #3 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 :)

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Getting Data in Op Vars
« Reply #4 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.

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Getting Data in Op Vars
« Reply #5 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.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Getting Data in Op Vars
« Reply #6 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.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Getting Data in Op Vars
« Reply #7 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.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Getting Data in Op Vars
« Reply #8 on: October 03, 2011, 10:51:01 am »
Ok. Thanks.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Getting Data in Op Vars
« Reply #9 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.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Getting Data in Op Vars
« Reply #10 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.