Author Topic: Commands for Axe  (Read 45363 times)

0 Members and 2 Guests are viewing this topic.

Offline p2

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 849
  • Rating: +51/-11
  • I'm back :)
    • View Profile
Commands for Axe
« on: June 15, 2011, 05:11:08 am »
What should I write in a BASIC-program instead of the following commands, if I want to create an APP of it (Wint Axe) ??

randInt(1,5)→X

{1,2,3,4,5}→L₁

sub("ABCDEF",3X-2,3)→Str1

iPart(X)+abs(Y)→Z

For(X,1,20,1)
End

dim(L₁)→A
« Last Edit: June 18, 2011, 12:14:27 pm by p2 »
*insert supercool signature*

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Commands for Axe
« Reply #1 on: June 15, 2011, 05:21:41 am »
Giving you the answer (IE writing the program for you) doesn't really help you learn the language, so here's a pointer in the right direction:

Code: [Select]
rand^5+1->X
[0102030405]->L1
"ABCDEF"->Str1
3*x-2->Y
.perform Substring operation on array pointed to by Str1.
.Be careful to handle the case where the starting location is greater than 3, as will often happen if X can vary between 1 and 5
For(X,1,20)
End
.no need for ipart in Axe, since Decimals aren't supported.
5->A

Be sure to keep in mind that you can't always just take BASIC code and easily translate it into Axe, particularly with the high level commands like Sub(). Axe might look like BASIC, but it requires a slightly different mindset.
:)

EDIT: I'm going to move this into the Axe discussion board, since it's more likely to get help  and the topic fits in with that board better.
« Last Edit: June 15, 2011, 05:26:48 am by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline p2

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 849
  • Rating: +51/-11
  • I'm back :)
    • View Profile
Re: Commands for Axe
« Reply #2 on: June 15, 2011, 08:37:16 am »
And what is:


if X=1 and Y≥2:Then
end




Art_of_camelot:
     I'll try it!
« Last Edit: June 29, 2011, 06:56:26 am by p2 »
*insert supercool signature*

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Commands for Axe
« Reply #3 on: June 15, 2011, 08:54:23 am »
Hi, in the future, try to avoid double posting like this. You can just use the quick modify button in the top right of your post to add additional thoughts.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Commands for Axe
« Reply #4 on: June 15, 2011, 09:30:56 am »
And what is:


if X=1 and Y≥2:Then
end




Art_of_camelot:
     I'll try it!

also use code tags [ code] [/ code] w/o the spaces
Code: [Select]
if X=1 and Y≥2:Then
End
 
would be
If X=1 and (Y≥2)
End
I'm not a nerd but I pretend:

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: Commands for Axe
« Reply #5 on: June 15, 2011, 11:44:31 am »
also use code tags [ code] [/ code] w/o the spaces
For future reference, you don't need to exclude spaces if you write it like this:
[nobbc][code] [/code][/nobbc]  (Which looks like [code] [/code]) :)

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: Commands for Axe
« Reply #6 on: June 15, 2011, 01:30:45 pm »
randInt(1,5)→X
max(rand^6,1)→X

{1,2,3,4,5}→L₁
data(1,2,3,4,5)→GBD1
or
for(A,0,4)
A+1→{L1+A}
end


sub("ABCDEF",3X-2,3)→Str1
erm... not? 3*X-2+Str1 is possible,but this returns everything behind it

iPart(X)+abs(Y)→Z
:S dunno

For(X,1,20,1)
End
For(X,0,19)
End
it always adds 1 in axe

dim(L₁)→A
Not necessairy since axe doesn't save anything.
If you like my work: why not give me an internet?








Offline p2

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 849
  • Rating: +51/-11
  • I'm back :)
    • View Profile
Re: Commands for Axe
« Reply #7 on: June 15, 2011, 01:52:08 pm »
sub("ABCDEFGHIJKLMNOPQRSTUVWXYS",3x-2,3) means:
if X=1     "ABC"
if X=2     "DEF"
if X=3     "GHI"
...


which commands are also different?
« Last Edit: July 03, 2011, 03:47:33 am by p2 »
*insert supercool signature*

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: Commands for Axe
« Reply #8 on: June 15, 2011, 02:49:08 pm »
randInt(1,5)→X
max(rand^6,1)→X
Woah, hold on there.  This doesn't provide the same result as randInt(1,5), it provides the same result as max(1,randInt(0,5)).  In other words, 1 is twice as likely as all the other numbers.  What you want to use is this:
rand^5+1→X

sub("ABCDEF",3X-2,3)→Str1
Alright, let's see if I can whip up some code to do that:
Data(65,66,67,68,69,70)→Str1A  // Note that 65 is the ASCII value for 'A', 66 for 'B', and so on.
Zeros(4)→Str1
For(A,0,3)
{3*X-3+A+Str1A}→{A+Str1}
End

That should work. :)
If you need an explanation for that, just let us know. :D
« Last Edit: June 15, 2011, 02:51:54 pm by ztrumpet »

Ashbad

  • Guest
Re: Commands for Axe
« Reply #9 on: June 15, 2011, 02:53:47 pm »
Data(65,66,67,68,69,70)→Str1A  // Note that 65 is the ASCII value for 'A', 66 for 'B', and so on.
Zeros(4)→Str1
For(A,0,3)
{3*X-3+A+Str1A}→{A+Str1}
End


an easier way:

"ABCDEF"→Str1
Zeros(4) → Str2
Copy(3*X-3+Str1,Str2,3)


« Last Edit: June 15, 2011, 02:54:51 pm by Ashbad »

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: Commands for Axe
« Reply #10 on: June 15, 2011, 02:57:21 pm »
Yeah, that's much easier.  I wish I had thought of that. :)

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Commands for Axe
« Reply #11 on: June 15, 2011, 03:17:02 pm »
I know I'm a bit late to join the party to help out here, but I have a lot more information to offer. What follows is a list of code conversions for all your examples, each accompanied with an exhaustive list of notes. These notes specify how the Axe code works and help outline how it is different from its BASIC counterpart.

If you have any questions left unanswered by this, please ask!


BASIC   Axe   Notes

randInt(1,5)→X   rand^5+1→X   
  • rand returns a pseudo-random integer from 0 to 65535.
  • ^ is the modulus function, which would then limit this number's range to 0 to 4.
  • Adding one increases the range to 1 to 5.
  • Axe 1.0 may have a built-in random integer function with a specifiable range, making the above obsolete.

{1,2,3,4,5}→L₁   Data(1,2,3,4,5)→GDB1   
  • Instead of storing the list of numbers in an OS list variable accessible outside of the program, the data is stored inside of the program.
  • If this is compiled as an application, you will be unable to change the values in this list. Get around this by copying the list to RAM and instead operating on the copy.
  • Each number is only a 1-byte integer instead of a 9-byte float.
  • Get used to only using 1- or 2-byte integers in Axe!
  • Whereas code to access this list in BASIC would be like L₁(3), the Axe code would be {3-1+GDB1}. The -1 is added because data in Axe is zero-indexed.
  • You could make this a list of 2-byte numbers by adding the ʳ modifier to the end of each number. Elements of the list would then be accessed with code like {3*2-2+GDB1}ʳ

sub("ABCDEF",3X-2,3)→Str1   sub(SUB,"ABCDEF",X*3-2,3)→S

.Later in the code:
Lbl SUB
0→{Copy(r₂+r₁-1,ᴇ8000,r₃)}
Return ᴇ8000
   
  • Axe has very few built-in string manipulation functions, which is why...
  • You supply your own routine! Lbl SUB is a custom routine for the substring operation. It places the substring starting at byte 0x8000 in memory in a 256-byte section of free RAM not used by anything else in Axe.
  • sub(SUB,[arg1,arg2,...]) calls the routine named SUB, with up to 6 arguments optionally specified. These arguments are then placed in order into the variables r₁-r₆
  • Note that implicit multiplication (e.g. 3X) is not supported. X*3 is used instead. 3*X would also work, but it much less optimized.
  • The result of the function is not an actual string object, but a pointer to the object. So the value returned is stored to the integer variable S.
  • Get used to strings, OS variables, and more being referenced as pointers to the objects, not the objects themselves!

iPart(X)+abs(Y)→Z   X+abs(Y)→Z   
  • Since values in Axe are 2-byte numbers, floats and decimals along with functions like iPart() are out.
  • Because certain code can result in more optimized assembly, this would be more optimized as abs(Y)+X→Z

For(X,1,20,1)
End
   For(X,1,20)
End
   
  • Axe does not support an increment argument with For() loops, so it's a good thing your sample code had an increment of one!
  • Axe 1.0 will hopefully support the optional increment argument with For() loops
  • I don't know if you have no code inside of the For() loop because this was just an example, or if you were using it simply to generate a pause. If you are just aiming to generate a pause, Axe's Pause # command should be very helpful. A Pause 1800 approximately correlates to a one-second pause at 6MHz, or approximately a Pause 4500 at 15MHz. (Unless you use the Full command in your program and it is executing on a non-83+BE, your code is running at 6MHz)

dim(L₁)→A   Data(1,2,3,4,5)→GDB1
[]→GDB0
GDB0-GDB1→A
   
  • This code assumes L₁ is the list you defined earlier.
  • GDB1 points to the first byte of the list, and GDB0 points to the first byte after the list. So subtracting the two gives you the distance between them, in this case the size of the data.
  • If this were a list of 2-byte numbers, you would need to make sure to divide the distance calculated by 2.
  • To make a dynamic list with a variable number of elements, you would need to put the list in a section of free RAM somewhere and keep track of the number of elements yourself.

« Last Edit: June 15, 2011, 03:21:23 pm by Runer112 »

Offline p2

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 849
  • Rating: +51/-11
  • I'm back :)
    • View Profile
Re: Commands for Axe
« Reply #12 on: June 16, 2011, 06:26:58 am »
Cool, thanx! :)

I have a question/problem: :-\

Code: [Select]
:.FORCEATT
:ClrDraw
:Circle(15,15,10
:Circle(80,15,10
:Text(57,10,(„DEF“)
:Text(57,75,(“OFF”)
:Line(25,15,30,10
:Line(70,15,65,10
:Line(30,10,45,10
:Line(65,10,50,10
:Line(45,10,47,8
:Line(50,10,48,8
:Line(30,7,65,7
:Line(30,7,28,0
:Line(65,7,67,0
:Line(5,15,0,10
:Line(90,15,95,10
:rand^1+101→F
:For(U,1,F
:If U≥0 and (U≤9):-3→Q
:If U>99:3→Q
:If U≥10 and (U≤99):0→Q
:Text(-1,44,10-Q,U
:End
:rand^1+101→N
:For(U,1,N
:If U≥0 and (U≤9):-3→Q
:If U>99:3→Q
:If U≥10 and (U≤99):0→Q
:Text(-1,44,75-Q,U
:End
:Line(36,60,58,60
:Pt-On(35,62
:Pt-On(35,61
:Pt-On(59,62
:Pt-On(59,61
:Line(89,29,89,61
:Line(89,29,93,29
:Line(94,29,94,61
:Line(89,61,4,61
:Line(91,U,92,U
:Pause 5000
It should create a picture of a Card (ForceAttax - Don't think you know them)

BUT:
1st Pass:   75%
ERR: ARGUMENT

 :banghead:



WHAT IS IT???????????  ???
« Last Edit: July 02, 2011, 02:15:50 pm by p2 »
*insert supercool signature*

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: Commands for Axe
« Reply #13 on: June 16, 2011, 06:39:25 am »
Pt-On is the sprite drawing command which takes 3 arguments.  You want Pxl-on to draw pixels.  Also, you seem to be under the impression that it is easy to convert a BASIC program into an Axe one.  This is definitely not the case.  Even though they look the same, they function completely differently.  Luckily, Axe comes with some documentation of how it works written for people already familiar with BASIC, just like you.  You should definitely give it a read, its not that long.  Also, be sure to check the commands.htm file before using any command in Axe just to make sure it does what you think it does. :)

Oh and by the way, if you press [prgm] right after an error, it will scroll to the error.

EDIT: And also, you'll want a DispGraph at the end to display the buffer on the LCD.  And starting text with -1 doesn't do what you think either, you'll need the "Fix" commands.
« Last Edit: June 16, 2011, 06:45:49 am by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline p2

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 849
  • Rating: +51/-11
  • I'm back :)
    • View Profile
Re: Commands for Axe
« Reply #14 on: June 16, 2011, 06:54:26 am »
I did not know that yet.
PRGM after Error.
Thanks. Smiley


It's the Pt-ON( command.





Now, it says MISSING END
( after the Pause 5000 )


What should that be?
*insert supercool signature*