Author Topic: Routines  (Read 313172 times)

0 Members and 2 Guests are viewing this topic.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Routines
« Reply #405 on: October 01, 2010, 08:57:59 am »
I just helped someone out with a specific case of writing a value to an OS list, so I figured I'd post this generic routine for others to use while I'm at it.

A note about list names: for L1 through L6, you can just define the name with something like:
Code: [Select]
"L₁"→Str1But for custom lists, you must do the following:
Code: [Select]
[015D]→Str1
"NAME"
[00]

And now the actual routine:

Code: [Select]
.Write a series of 2-byte values to an OS list (Pointer to name, number of elements, pointer to list of 2-byte values)
Lbl OSL
  GetCalc(r₁,r₂*9)→r₄
  r₂→{r₄-2}ʳ
  For(r₅,0,r₂-1)
    {r₅*2+r₃}ʳ→float{r₅*9+r₄}
  End
Return
« Last Edit: October 01, 2010, 09:09:38 am by Runer112 »

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 #406 on: October 01, 2010, 09:44:00 am »
Mhmm, wait, so 015D would be the L character, right?

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Routines
« Reply #407 on: October 01, 2010, 09:53:36 am »
Yes, and it doesn't appear to work correctly when trying to store it into a string. Perhaps this is something Quigibo should look into fixing?
« Last Edit: October 01, 2010, 09:54:07 am by Runer112 »

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 #408 on: October 01, 2010, 04:57:59 pm »
Aw I see :(. Are you sure it would be an Axe bug? Might be something he should check, indeed.

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 #409 on: October 01, 2010, 05:04:32 pm »
That's a nice routine Runer. :)  Thanks! ;D

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Routines
« Reply #410 on: October 02, 2010, 08:11:04 am »
number input routine:
Code: [Select]
..INNUMBER
"Your text here->Str9
.(following is not necessary)
.sub(IN)
.return

Lbl IN
DiagnosticOff
ClrHome
Str9->A
"+-*/^C -369)TV .258(CPS0147,SALO>LL[X2][X-1]MA->Str4
Text(2,0,A)
0->K
While K=0
getKey->K
End
Text(8,6,{Str4+K-10}>Char)
0->L
While L=0
getKey->L
End
Text(12,6,{Str4+L-10}>Char
0->M
While M=0
getKey->M
End
Text(16,6,{Str4+M-10}>Char
{Str4+K-10}->X
{Str4+L-10}->Y
{Str4+M-10}->Z
Pause 2000
ClrHome
0->K

Please notify me if the code is too long and feel free to optimize them.

NOTE and EDIT: in code you see [X2] and [X-1]
you should type X2 and X-1
in code you cant type that...
« Last Edit: October 02, 2010, 08:14:26 am by aeTIos »
I'm not a nerd but I pretend:

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: Routines
« Reply #411 on: October 02, 2010, 12:19:41 pm »
Nice. Some opts:

Use Repeat K instead of While K.

Save a byte by changing "+-*/^C -369)TV .258(CPS0147,SALO>LL[X2][X-1]MA->Str4 to []->Str4:"+-*/^C -369)TV .258(CPS0147,SALO>LL[X2][X-1]MA".

Also, try not to leave closing parentheses/quotes off.




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 #412 on: October 02, 2010, 09:56:22 pm »
Use Repeat K instead of While K.
To clarify, "Use Repeat K instead of While K=0." :)

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: Routines
« Reply #413 on: October 02, 2010, 10:55:40 pm »
Right. I've gotta start proofing my posts...




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 #414 on: October 03, 2010, 04:32:42 am »
Nice routine :D

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Routines
« Reply #415 on: October 04, 2010, 09:42:03 pm »
Here's a very compact 125-byte library for hex display. It contains the following subroutines:
  • N2H: Nibble to hex – Example: 13sub(N2H) would return the character "D"
  • B2H: Byte to hex – Example: sub(B2H,69) would return a pointer to the string "45"
  • W2H: Word (2 bytes) to hex – Example: sub(W2H,1234) would return a pointer to the string "04D2"

To include it in your program, send prgmHEXLIB to your calculator and put prgmHEXLIB among the other subroutines in your program. Just make that sure wherever you put it, it won't be accidentally reached and executed unless you call it.

I challenge anyone to find a single optimization in this code or produce a smaller library of their own ;) (/me waits for Quigibo to make it way more compact than anyone thought possible)


EDIT: Changed name from prgmHEXSRC to prgmHEXLIB and reuploaded. This name just seems more appropriate for a library that you don't compile as a standalone program.
« Last Edit: October 04, 2010, 10:07:05 pm by Runer112 »

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 #416 on: October 04, 2010, 09:58:19 pm »
Nice! :D

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: Routines
« Reply #417 on: October 04, 2010, 10:50:45 pm »
Awesome! And great job on the optimizations :)

I challenge anyone to find a single optimization in this code or produce a smaller library of their own ;) (/me waits for Quigibo to make it way more compact than anyone thought possible)

Easy. Just take out the comments ;)

J/k.




Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Routines
« Reply #418 on: October 06, 2010, 02:59:18 pm »
I'm not a nerd but I pretend:

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Routines
« Reply #419 on: October 06, 2010, 03:34:31 pm »
number input routine:(EDITED)
Code: [Select]
..INNUMBER
"Your text here->Str9
.(following is not necessary)
.sub(IN)
.return

Lbl IN
DiagnosticOff
ClrHome
Str9->A
"+-*/^C -369)TV .258(CPS0147,SALO>LL[X2][X-1]MA->Str4
Text(2,0,A)
0->K
repeat getKey->K
End
Text(8,6,{Str4+K-10}>Char)
0->L
While L=0
getKey->L
End
Text(12,6,{Str4+L-10}>Char
0->M
While M=0
getKey->M
End
Text(16,6,{Str4+M-10}>Char
{Str4+K-10}->X
{Str4+L-10}->Y
{Str4+M-10}->Z
X-48*10+Y-48*10+Z-48->X
Pause 2000
ClrHome
0->K

WOW v2.1 :)

« Last Edit: October 07, 2010, 06:45:14 am by aeTIos »
I'm not a nerd but I pretend: