### Author Topic: The ** Command  (Read 3892 times)

0 Members and 1 Guest are viewing this topic.

#### nemo

• LV9 Veteran (Next: 1337)
• Posts: 1203
• Rating: +95/-11
##### The ** Command
« on: July 21, 2010, 01:35:48 am »
Hey guys, so i've been messing around with the **  command in axe parser to help anyone who may want to figure out how to use it, or at least understand it primitively. so here are 90 minutes worth of observations i've made by testing dozens of axe programs, and then PM'd to quigibo to make sure they're correct observations, which was OK'd.

The ** Command

the documentation reads: "The signed multiplication is performed using the high byte as the integer part and the low byte as the decimal part returning a number in the same format."
here's a quick way to transfer a decimal number into something axe parser will understand. say you wanted to multiply 2.5 and 3.5. That's 8.75, you say, being superb at arithmetic. well, let's see how we can get axe to do it for us: first, break this down starting with the number 2 and one half. second, we take one half. since this is the first 8 bits, which holds the values 0-255, after that point it overflows into the next byte which holds the integer part two. this is better represented in binary:

0    0    0     0     0      0    0     0    | 0     0     0     0     0    0    0    0
32768 16384 8192  4096  2048  1024  512    256 | 128   64    32    16    8    4    2    1

the line separates the high and low bytes. since we want to display one half in the lower byte to the right, we need one half of it. since the lower byte can represent 0-255, or 256 values, to get one half we'll have to divide 256 by two. so we end up with 128. then we need to represent 2 in the higher byte. you'll notice if we divide all the values of the higher byte by 256, they become identical to the lower byte. (32768/256=128, 16384/256=64, etc.) therefore, if we look at the lower byte, figure out what number we're trying to represent (in this case, it's two) and multiply it by 256, we'll get the higher-byte equivalent. which is 2 * 256 so 512. 512+128 = 640. great. we have one number, 2.5. now we need to multiply it by 3.5 do the same thing. what's .5 on our lower-byte scale? 128. and now we add that to 3 * 256, which is 768. total, that's 896. great. now try out this program:
Code: [Select]
.EXAMPLE640->A  . 2 and a half 896->B  . 3 and a halfDisp A**B>DecWhat does it give? it gives 2240. look back at the commands list. it says it will give a number in the same format. therefore, to decode it, all you need to do is divide by 256. you'll notice you get 8.75. which is.. 3.5 * 2.5 (:
so you have a number x, and a number y. and you want to use this program without thinking in binary. here's the quick way, assuming x and y are in base 10 with decimal parts, just multiply them by 256 to get numbers that the ** command understands. 2.5 * 256 = 640, and 3.5 * 256 = 896.

Quigibo also gave me a quick BASIC program that will convert a number from -128 through 128 into 8.8 form (the form Axe reads in).
with the number in Ans:
Code: [Select]
If Ans<-128 or Ans>128:ThenDisp "OUT OF RANGEReturnEndAns+256(Ans<0256iPart(Ans)+iPart(256fPart(Ans
and Quigibo's way to go from 8.8 back to decimal:
Code: [Select]
ClrHomeInput "8.8:",AIf A>=2^16ThenDisp "OUT OF RANGE!"StopEndIf A>=2^15:ThenDisp -(2^16-A)/256    . this is a negative, not a minus signElseDisp A/256End
« Last Edit: July 21, 2010, 02:05:08 am by nemo »

#### Quigibo

• The Executioner
• CoT Emeritus
• LV11 Super Veteran (Next: 3000)
• Posts: 2031
• Rating: +1075/-24
##### Re: The ** Command
« Reply #1 on: July 21, 2010, 01:39:15 am »
Great tutorial Nemo!

Here it is in as a full TI-BASIC program.
EDIT: Also, I uploaded a converter to go the other way.
« Last Edit: July 21, 2010, 01:50:39 am by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

#### nemo

• LV9 Veteran (Next: 1337)
• Posts: 1203
• Rating: +95/-11
##### Re: The ** Command
« Reply #2 on: July 21, 2010, 01:47:08 am »
Thanks quigibo!
I edited the BASIC program to act the same as the one you posted.

#### 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.
##### Re: The ** Command
« Reply #3 on: July 21, 2010, 12:23:38 pm »
Nice job Nemo!  Thanks!
If I'm wrong, please correct me!
Unfinished Projects:
 Elmgon 14% Basic Movement Demo Homescreen Game Pack 80% Basic Latest Release Cube Droid Saves the Galaxy 65% Axe Demo Detonate 70% Axe
Completed Projects:
Exodus | Midnight |Drifter | Axe Snake | Jump! | Factory Theta | Spider | Plot Drop | Papi Jump | Numb3rs | Nibbler | Boost | Duel Tile Map Editor | Homescreen Map Editor | Key Group Check | Oasis

#### calcdude84se

• Needs Motivation
• LV11 Super Veteran (Next: 3000)
• Posts: 2272
• Rating: +78/-13
• Wondering where their free time went...
##### Re: The ** Command
« Reply #4 on: July 21, 2010, 12:24:37 pm »
Cool! This'll definitely be helpful for those who are having trouble understanding.
Great job!
« Last Edit: July 21, 2010, 12:25:10 pm by calcdude84se »
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
I'll put it online when it does something.

#### DJ Omnimaga

• Former TI programmer
• CoT Emeritus
• LV15 Omnimagician (Next: --)
• Posts: 55833
• Rating: +3151/-232
• CodeWalrus founder & retired Omnimaga founder
##### Re: The ** Command
« Reply #5 on: July 21, 2010, 12:35:04 pm »