Author Topic: 4-byte integer  (Read 4698 times)

0 Members and 1 Guest are viewing this topic.

Offline Torio

  • LV3 Member (Next: 100)
  • ***
  • Posts: 83
  • Rating: +22/-0
    • View Profile
4-byte integer
« on: January 24, 2012, 12:15:20 pm »
Hello,
I would like to know if it is possible to handle 4-byte integers in Axe Parser.
I would like to do divisions and modulo operations with those numbers.

Thank you !

(Sorry about my mistakes, I'm French.)
Sorry about my mistakes, I'm French.

Projects :  Pokemon TI-89 | Ti-Tank

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: 4-byte integer
« Reply #1 on: January 24, 2012, 02:48:45 pm »
There were no mistakes that I could see actually :)
As for your question, I do not believe Axe normally supports 4-byte (32-bit/octet) values :/
I might have a hex opcode for 32 bit/16 bit and the same for modulo, though :)

Offline Torio

  • LV3 Member (Next: 100)
  • ***
  • Posts: 83
  • Rating: +22/-0
    • View Profile
Re: 4-byte integer
« Reply #2 on: January 24, 2012, 03:09:09 pm »
Dommage...

I think I have to give up my idea in Axe and to program it in TI-Basic, but it is so sloooooow...
Sorry about my mistakes, I'm French.

Projects :  Pokemon TI-89 | Ti-Tank

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: 4-byte integer
« Reply #3 on: January 24, 2012, 03:10:38 pm »
Hmm, what inputs and outputs do you need? There are lots of folks around that are better than I (I don't know Axe very well)

Offline Torio

  • LV3 Member (Next: 100)
  • ***
  • Posts: 83
  • Rating: +22/-0
    • View Profile
Re: 4-byte integer
« Reply #4 on: January 24, 2012, 03:25:27 pm »
Well, I would like to make a program that gives the decomposition in primary numbers (is this the right word ?) of a number.
I need to make a 32b/16b division and modulo, as well as a 32b square root.

Is your hexcode usable in Axe, because it could be interesting ?
« Last Edit: January 24, 2012, 03:27:11 pm by Torio »
Sorry about my mistakes, I'm French.

Projects :  Pokemon TI-89 | Ti-Tank

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: 4-byte integer
« Reply #5 on: January 24, 2012, 03:35:37 pm »
o.o Okay, I see why you need this, now. Are you saying you want to factor a number (I am an almost mathematician, so I understand your words). You mean like 78 is 2*3*13?

I can see what I can do... I know I could do the math parts in assembly, but it may take a while

Offline Torio

  • LV3 Member (Next: 100)
  • ***
  • Posts: 83
  • Rating: +22/-0
    • View Profile
Re: 4-byte integer
« Reply #6 on: January 24, 2012, 04:03:29 pm »
Yes, you have understood what I want to do.
I have already done a version in TI-Basic, but too slow for great numbers, so I wanted to make it in Axe. Yet it is perfectly functional for usual numbers (lower than 1 million), so don't waste your time for a program that in fact wouldn't be very useful.
Sorry about my mistakes, I'm French.

Projects :  Pokemon TI-89 | Ti-Tank

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: 4-byte integer
« Reply #7 on: January 24, 2012, 04:07:15 pm »
EDIT2: This code does not work yet :/

Okay :)
I have not tested this code, but it might work for 32/16:
Code: [Select]
A/C→D
A^C*256+B/256→A
B*256→B
D+A/C→D
A^C*256+B/256→A
A^C→E
D+A/C→D
It does AB/C and returns the division in D and the mod in E
(well, it is supposed to)

EDIT: Made it faster/smaller

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: 4-byte integer
« Reply #8 on: January 24, 2012, 05:08:52 pm »
Axe does not natively support integers larger than 16-bits since it is a game oriented language and most games don't need large integers.  However, if you know a little bit about arithmetic algorithms you can definitely code these routines in Axe as Xeda has done above, or even some inline assembly if you want a more optimized version and you know z80.
« Last Edit: January 24, 2012, 05:10:28 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

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: 4-byte integer
« Reply #9 on: January 24, 2012, 05:10:01 pm »
Also, Jacobly has found my code not to work (and I had syntax issues, too) :/

Offline Torio

  • LV3 Member (Next: 100)
  • ***
  • Posts: 83
  • Rating: +22/-0
    • View Profile
Re: 4-byte integer
« Reply #10 on: January 25, 2012, 09:29:55 am »
Ok, thank you for your help !

I have found the code for the modulo, but it is the easiest for the three operations.

To make AB^P and store it into R :
Code: [Select]
65535^P+1^P*A^P+B^P=>R
I'm going to try the square root now !
Sorry about my mistakes, I'm French.

Projects :  Pokemon TI-89 | Ti-Tank

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: 4-byte integer
« Reply #11 on: January 25, 2012, 11:14:09 am »
Is an approximation okay? I have some algorithms that could work for you and I am working on some more :) A very small and easy algorithm looks like this:
(This is not Axe code, but it will work very nicely for 32-bit integers)
Code: [Select]
65535→B          ;just the initial condition. Feel free to experiment, this can be anything. (try 32767?)
Repeat abs(X-B)<2
(B+X/B)/2→B
End
It will need at most 16 iterations for a 32-bit number (fewer iterations for larger numbers) for a 32-bit number. There are, however, faster methods, but I don't know how to do it in Axe :/ Again, I could write some assembly code, possibly or a mix of Assembly and Axe.

EDIT: Fixed my code, I accidentally forgot to remove some scratch work