Author Topic: Routines  (Read 312692 times)

0 Members and 2 Guests are viewing this topic.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Routines
« Reply #15 on: February 24, 2010, 12:06:39 pm »
How to add/subtract two 32-bit numbers:
Code: [Select]
:'This will do AB+CD->AB
:((B+D->B)<D)+A+C->A
:'This will do AB-CD->AB
:A-C-((B-D->B)>=-D)->A
Note ">=" is greater than or equal token
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

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: Routines
« Reply #16 on: February 24, 2010, 01:53:37 pm »
Nice!  Although you don't need all those parenthesis since order of operations is still just left to right:
:B+D->B<D+A+C->A
:A-C-(B-D->B>=-D)->A
Won't make a difference in the compiled code, but saves some memory in the source.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #17 on: February 24, 2010, 02:19:06 pm »
I think I will probably start coding this by using the conventional BASIC operation syntax because I still can't memorize the weird Axe syntax so it's gonna take me a while to get used to when coding x.x

Offline trevmeister66

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1009
  • Rating: +14/-5
    • View Profile
Re: Routines
« Reply #18 on: February 24, 2010, 02:35:48 pm »
I think I will probably start coding this by using the conventional BASIC operation syntax because I still can't memorize the weird Axe syntax so it's gonna take me a while to get used to when coding x.x
You could always create your code the conventional BASIC way and then post it here and someone can convert it to "Axe friendly syntax" if you want.
Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit :)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #19 on: February 24, 2010, 02:42:56 pm »
I guess that could work too :P, altough if the code is massive some ppl might not want to XD

I want to port WoW to Axe Parser... j/k

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Routines
« Reply #20 on: February 24, 2010, 03:02:23 pm »
I optimized even more now :D
Code: [Select]
:'This does AB+CD->AB
:B>(+D->B)+A+C->A
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

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: Routines
« Reply #21 on: February 24, 2010, 04:54:55 pm »
Nice job Calc84! :D

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Routines
« Reply #22 on: February 24, 2010, 06:03:10 pm »
Wow nice!
/e

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: Routines
« Reply #23 on: February 24, 2010, 06:11:52 pm »
That's actually 1 byte less optimized. Try it.

That's because the parenthesis require a push and pop (2 bytes), and the "greater than" and "less than or equal to" operators take 2 more bytes than the other comparisons.  So you saved 3 bytes but then added 4.

You could have done this:
Code: [Select]
:B>=(+D->B-1)+A+C->ABut then its the same size as your first attempt.  Not sure if the speed is faster or slower though.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Routines
« Reply #24 on: February 24, 2010, 06:22:46 pm »
That's actually 1 byte less optimized. Try it.

That's because the parenthesis require a push and pop (2 bytes), and the "greater than" and "less than or equal to" operators take 2 more bytes than the other comparisons.  So you saved 3 bytes but then added 4.

You could have done this:
Code: [Select]
:B>=(+D->B-1)+A+C->ABut then its the same size as your first attempt.  Not sure if the speed is faster or slower though.
Well, my logic was that it did one less variable access than before.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Routines
« Reply #25 on: February 25, 2010, 10:15:08 pm »
Here is my (most likely unoptimised) Sin approximation routine.  Since floating point numbers have not been implemented (yet?) I was forced to use a different approach.  Input is in 10x and output is in 10x.  For example to input 3.1 (PI :P) you would input 31.  And output is from -10 to 10.  It also *does* loop, so your input can go beyond 2PI (63).

Code: [Select]
Lbl S
->A
A^64/16->B
A^16->A
If B=1 Or (B=3
16-A->A
End
A-(A*A*A/600)->A
If B>1
-A->A
End
A
Return

The code is meant to be used like this

Code: [Select]
31sub(S)->C    //Will return 10x the sin of 3.1
Optimizations are welcome, i'm sure there are some ;D
« Last Edit: February 26, 2010, 05:33:00 pm by Builderboy »

Offline rthprog

  • LV2 Member (Next: 40)
  • **
  • Posts: 29
  • Rating: +5/-0
    • View Profile
Re: Routines
« Reply #26 on: February 26, 2010, 11:54:44 am »
I'm not familiar with Axe, so I'm just guessing when I make these modifications.

Code: [Select]
Lbl S
->Ans^16->A
A^4/16->B
A-2(A-8)(T=1 Or T=3
Ans-Ans^3/600-2(T>1->A
Return
« Last Edit: February 26, 2010, 12:05:42 pm by rthprog »

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Routines
« Reply #27 on: February 26, 2010, 01:01:08 pm »
Unfortunatly Axe does not have Ans yet, and we don't know if it ever will. Also it would probably be slower to have it anyways.
/e

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: Routines
« Reply #28 on: February 26, 2010, 03:27:59 pm »
Ans is always implied as the last computation every new line so its not really needed.  Storing it to a temporary variable is what "Ans" would do anyway, so just pick a variable and pretend that its "Ans".


I'm a little bit confused why you store to B and never use it and then reference T but don't declare it.  I'll assume thats a typo and are meant to both be the same variable.

Here are some optimizations:
Code: [Select]
Lbl S
->A^64/16->B
A^16->A
If B^2          ;Says "If B is odd"
16-A->A
End
A-(A*A*A/600)->A
If B/2^2        ;Checks 2nd bit
-A->A
End
A
Return
This should now work at ANY value of A, but I guess it is still just one term of the Maclaurin so estimates will be off...

EDIT: oops, fixed.
« Last Edit: February 26, 2010, 07:34:04 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #29 on: February 26, 2010, 04:51:36 pm »
I wonder if he just posted a portion of his code, it could be why

Btw the other nigth I started messing around a bit with Axe the same way I started BASIC: by looking at code examples (in this case, Fall Down) and modifying parts of them, such as having the ball move 8x faster or the like. Maybe eventually I'll have some motivation and time to make an entire game to myself