Author Topic: Code optimization  (Read 16182 times)

0 Members and 3 Guests are viewing this topic.

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: Code optimization
« Reply #15 on: June 18, 2010, 03:10:15 pm »
Actually, even though the bottom is cleaner and easier to read, the top is still more optimized I think.  That's because he doesn't need to store to temporary variables to call the subroutine, the original subroutine was specifically made to only draw points from the X,Y variables which is fine for his use.

EDIT: And yes, r1-r6 work just like normal variables.  Anywhere you can use a letter A-Theta you can also use r1-r6, including for loops and storing to them.
« Last Edit: June 18, 2010, 03:12:22 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: Code optimization
« Reply #16 on: June 18, 2010, 04:33:33 pm »
But they look very convenient for temporary uses like in functions and loops.
That really should help readability of code. Nice add!
Hobbing in calculator projects.

Offline Magic Banana

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 371
  • Rating: +77/-1
  • It's not an apple, it's a ... magic banana.
    • View Profile
Re: Code optimization
« Reply #17 on: June 18, 2010, 08:07:31 pm »
Another question about parameters: Can we use constants as parameters in addition to variables? Something like:
Code: [Select]
Sub(SE,X,Y,14or just
Code: [Select]
Sub(BL,9,30,2to store those numbers to the r1-r6? Also, since it's r1-r6, does that mean we can send up to 6 to the sub?
I do sprites and stuff, so yeah.

Quote from: yunhua98
i'M NOT SURE WHAT A SWORD SKILL IS BUT HERE'S THE SWORD ANIMATION FROM THE TWO SPRITES ON PG 13

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: Code optimization
« Reply #18 on: June 18, 2010, 08:29:21 pm »
Not only can you use constants AND variables, you can us ANY expression including other subroutines and asm code.   If you want, you can call something with sub(L,X+2,Str-X*2^5-A,sign{'A'+sub(B)-{L1}}).  Go crazy.

And yes, you can have up to 6 arguments and as few as 0.  Only the temporary variables than need to be passed actually get updated.  You can have subroutines that take a variable number of arguments too.  Like if you make the first parameter be "number of arguments" then you can have the same subroutine function multiple ways with different numbers of arguments.
___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: Code optimization
« Reply #19 on: June 18, 2010, 08:48:40 pm »
Just don't do stuff like this :P

sub(AA,sub(AB,sub(AC,sub(AD,sub(AE,sub(AF,sub(AG,sub(AH,sub(AI,sub(AJ,sub(AK,sub(AL,sub(AM,sub(AN,sub(AO,sub(AP,sub(AQ,sub(AR,sub(AS,sub(AT,sub(AU,sub(AV,sub(AW,sub(AX,sub(AY,sub(AZ,sub(BA,sub(BB,sub(BC,sub(BD,sub(BE,sub(BF,sub(BG,sub(BH,sub(BI,sub(BJ,sub(BK,sub(BL,sub(BM,sub(BN,sub(BO,sub(BP,sub(BQ,sub(BR,sub(BS,sub(BT,sub(BU,sub(BV,sub(BW,sub(BX,sub(BY,sub(BZ,sub(CA,sub(CB,sub(CC,sub(CD,sub(CE,sub(CF,sub(CG,sub(CH,sub(CI,sub(CJ,sub(CK,sub(CL,sub(CM,sub(CN,sub(CO,sub(CP,sub(CQ,sub(CR,sub(CS,sub(CT,sub(CU,sub(CV,sub(CW,sub(CX,sub(CY,sub(CZ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

...unless that is actual valid code?
« Last Edit: June 18, 2010, 08:49:07 pm by DJ Omnimaga »

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Code optimization
« Reply #20 on: June 18, 2010, 08:51:52 pm »
excuse my french but... mindfuck? i dare someone to have a program with 20 subroutines and the line that DJ just posted only. and it has to do something useful.


Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: Code optimization
« Reply #21 on: June 18, 2010, 08:51:56 pm »
Just don't do stuff like this :P

sub(AA,sub(AB,sub(AC,sub(AD,sub(AE,sub(AF,sub(AG,sub(AH,sub(AI,sub(AJ,sub(AK,sub(AL,sub(AM,sub(AN,sub(AO,sub(AP,sub(AQ,sub(AR,sub(AS,sub(AT,sub(AU,sub(AV,sub(AW,sub(AX,sub(AY,sub(AZ,sub(BA,sub(BB,sub(BC,sub(BD,sub(BE,sub(BF,sub(BG,sub(BH,sub(BI,sub(BJ,sub(BK,sub(BL,sub(BM,sub(BN,sub(BO,sub(BP,sub(BQ,sub(BR,sub(BS,sub(BT,sub(BU,sub(BV,sub(BW,sub(BX,sub(BY,sub(BZ,sub(CA,sub(CB,sub(CC,sub(CD,sub(CE,sub(CF,sub(CG,sub(CH,sub(CI,sub(CJ,sub(CK,sub(CL,sub(CM,sub(CN,sub(CO,sub(CP,sub(CQ,sub(CR,sub(CS,sub(CT,sub(CU,sub(CV,sub(CW,sub(CX,sub(CY,sub(CZ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

...unless that is actual valid code?

ok i am starting to hate you dj.
WHY DIDN'T YOU TELL ME BEFORE I TRIED!!!!!!
lol i  am just kidding.  did you see the caps? really draws your attention doesn't it
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 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: Code optimization
« Reply #22 on: June 18, 2010, 08:56:08 pm »
Lol

Try to avoid abuse of them, though, because many french people visits this board and in our netiquette, all caps are considered as yelling, unlike on english boards, where they are considered as emphasis, so some people could take them as rude.

And nemo I was kidding with that code :P. It just basically meant to not go WAY too overboard either :P
« Last Edit: June 18, 2010, 08:57:52 pm by DJ Omnimaga »

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Code optimization
« Reply #23 on: June 18, 2010, 08:59:10 pm »
psh, whether or not you were kidding i am going to try a program with that.  :D

edit: i'm twelve and what is this?
« Last Edit: June 18, 2010, 09:02:49 pm by nemo »


Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: Code optimization
« Reply #24 on: June 18, 2010, 09:00:53 pm »
sounds fun.  send me the code when you are done.

sry not trying to be rude XD
« Last Edit: June 18, 2010, 09:01:04 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
____________________________________________________________

Offline Magic Banana

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 371
  • Rating: +77/-1
  • It's not an apple, it's a ... magic banana.
    • View Profile
Re: Code optimization
« Reply #25 on: June 18, 2010, 09:01:05 pm »
Oh the possibilities ...
This makes things much more interesting.

@DJ Omni
What is this, I don't even ...
I do sprites and stuff, so yeah.

Quote from: yunhua98
i'M NOT SURE WHAT A SWORD SKILL IS BUT HERE'S THE SWORD ANIMATION FROM THE TWO SPRITES ON PG 13

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: Code optimization
« Reply #26 on: June 18, 2010, 09:02:34 pm »
the r1 and r2 code thing really helps me understand this update better
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 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: Code optimization
« Reply #27 on: June 18, 2010, 09:02:56 pm »
psh, whether or not you were kidding i am going to try a program with that.  :D
Just backup first, of course :P (I, myself, managed to forget that part, once, before testing a little program, even if I told myself I must backup first)
« Last Edit: June 18, 2010, 09:06:09 pm by DJ Omnimaga »

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Code optimization
« Reply #28 on: June 18, 2010, 09:11:27 pm »
if axe supported floating point, i would make this the most epic quadratic solver known to man. because i'm lacking in that department, this will be.. interesting.


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: Code optimization
« Reply #29 on: June 18, 2010, 09:17:23 pm »
lol

Since this project started, I wished that floating point numbers support would only come after the first Axe program is uploaded on ticalc.org. I still have some bad memories of when I saw the very first ever BBC Basic language upload there. :P

Anyway back on topic, I assume the r1 through r6 stuff can be used inside sub() commands too, right? (such as sub(AB,r6,C)
« Last Edit: June 18, 2010, 09:20:00 pm by DJ Omnimaga »