Author Topic: [Help needed] 3-4 byte numbers  (Read 8236 times)

0 Members and 1 Guest are viewing this topic.

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
[Help needed] 3-4 byte numbers
« on: December 04, 2010, 10:39:07 am »
how can i deal with 3-4 byte numbers in axe?

School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

ASHBAD_ALVIN

  • Guest
Re: [Help needed] 3-4 byte numbers
« Reply #1 on: December 04, 2010, 10:41:01 am »
you CAN, but you have to write your own routines to do so.

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: [Help needed] 3-4 byte numbers
« Reply #2 on: December 04, 2010, 10:41:36 am »
ya, thats why i am asking.
« Last Edit: December 04, 2010, 10:45:58 pm by happybobjr »
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

ASHBAD_ALVIN

  • Guest
Re: [Help needed] 3-4 byte numbers
« Reply #3 on: December 04, 2010, 10:46:26 am »
well, it's much mroe complicated than you think.  basically, you're treating data not in bytes or words, but rather in dwords and 24 bit values.  Basically, to do math in this format, you have to check the value of the added number to see how large it is and how many bytes it consumes.  so, if it's within one byte, add the number to the very least significant byte and add overflow to the nextmost significant byte (and continue if that overflows too)

for a 16 bit addition, add the least most significant bits, carry overflow, then add the next most next significant byte, then carry overflow etc.

Never really done in axe before, though very possible to do in assembly.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: [Help needed] 3-4 byte numbers
« Reply #4 on: December 04, 2010, 10:51:27 am »
how can i deal with 3-4 byte numbers in axe?



What kind of things do you need to do? Things like addition, subtraction, logic, and comparisons are definitely easily doable, but things like multiplication and division are trickier.
« Last Edit: December 04, 2010, 10:52:16 am by Runer112 »

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: [Help needed] 3-4 byte numbers
« Reply #5 on: December 04, 2010, 12:11:49 pm »
any information would be great.
i would b using L1 for the byte probably.
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

ASHBAD_ALVIN

  • Guest
Re: [Help needed] 3-4 byte numbers
« Reply #6 on: December 04, 2010, 12:12:39 pm »
I think there's a explanation of it in "learn 83+ assembly in 28 days"

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: [Help needed] 3-4 byte numbers
« Reply #7 on: December 04, 2010, 12:24:43 pm »
You want to look here:
http://future_history.freehostia.com/Files/Resources/ASM/ASMin28Days/lesson/day15.html

However, it's ridiculously complex and would be better suited for an Axiom. :)
« Last Edit: December 04, 2010, 12:25:13 pm by ztrumpet »

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: [Help needed] 3-4 byte numbers
« Reply #8 on: December 04, 2010, 12:28:38 pm »
how will that work with axe though?
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: [Help needed] 3-4 byte numbers
« Reply #9 on: December 04, 2010, 12:37:29 pm »
any information would be great.
i would b using L1 for the byte probably.

Let's see... You probably know how to do equality (just check the two byte pairs for equality individually). Greater than/less than is also pretty easy: check the high (most significant) byte pair first, whichever one that is, and if it's equal, check the other byte pair. AND, OR, and XOR should work about the same: just do it on both byte pairs, then compare.

For math, addition and subtraction should be easiest, but the fastest way to do it would involve carries, which would require some messing with Asm(.

You can also do it without ASM (in normal Axe), so here's a quick rundown involving two 4-byte numbers (since it's the easiest to do). By "least-significant byte pair" I mean the two bytes that take up the smallest place value, and the "most-significant byte pair" is the two bytes that are at the highest place value.

Let's say you want to add two numbers together. It's easy if the least significant byte pair doesn't end up overflowing past 65535, since in that case all you have to do is add the least significant byte pair, then the other one. No messing around with anything; just simple addition.

But then if the smaller byte pair overflows, you'll have to add an extra one (carrying) to the other one. We tend to get used to it in real life, so to recap, it's like this:


 1
 19
+22
 41


That extra 1's the carry I'm talking about. So how would you check for it? Well, basically if you add the least significant byte pair and it ends up being smaller than the first number you started with, you know there's a carry (like the 9+2 becoming a 1 above). Just test for this before and after you do the actual addition, and if there is a carry, add one more when you add the most significant byte pairs together.

Subtraction works pretty much the same way, but in the opposite direction: if you subtract two least-significant byte pairs and it ends up being bigger than the one you started with, there's a carry, so subtract one more when you do the other byte pair.
« Last Edit: December 04, 2010, 12:38:44 pm by Deep Thought »




Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: [Help needed] 3-4 byte numbers
« Reply #10 on: December 04, 2010, 12:39:43 pm »
thank you much, i am starting too read... ;)
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: [Help needed] 3-4 byte numbers
« Reply #11 on: December 04, 2010, 12:40:57 pm »
No problem, and sorry if it's confusing. I should probably give you more examples, but I gotta go. If anyone else understands it, they can give you any examples.




Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: [Help needed] 3-4 byte numbers
« Reply #12 on: December 04, 2010, 12:50:28 pm »
now about square roots?
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: [Help needed] 3-4 byte numbers
« Reply #13 on: December 04, 2010, 12:51:12 pm »
Lol, that'd be hard. Axe doesn't even support that for one or two-byte numbers...




Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: [Help needed] 3-4 byte numbers
« Reply #14 on: December 04, 2010, 12:53:52 pm »
axe does support square root for 2 byte numbers.
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________