Author Topic: Axe Space Questions  (Read 5346 times)

0 Members and 1 Guest are viewing this topic.

Offline collechess

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +22/-2
    • View Profile
Axe Space Questions
« on: December 02, 2011, 05:09:06 pm »
How much space does a string take?  Can you change the amount of space by adding extra spaces at the end? e.g. "STUFF      "->Str1
What about a pointer to a string?  Or a decimal number?

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Space Questions
« Reply #1 on: December 02, 2011, 05:12:09 pm »
A string takes up 1 byte for every character contained in the string.  Remember a String in Axe is just data, just the same if you were to do [0FA76FA937ABC]->Str1  You can change the length of the string by adding on additional characters, and that will increase the amount of data that the string of data contains.  Str1 is the pointer to the string, and it is 2 bytes large.  What do you mean by Decimal number?  Do you want to add a decimal number into the string or ask how much space they take up?

Offline collechess

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +22/-2
    • View Profile
Re: Axe Space Questions
« Reply #2 on: December 02, 2011, 05:20:30 pm »
I meant a decimal number by itself.   Like in this:

Code: [Select]
[FFFFFFFFFFFFFFFF]->GDB1            the sprite is 8 bytes
[00]                                            this is one byte
55                                               how much is this?
"HELLO    "                                     so this is 7?
Str1                                                how much is this?

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Space Questions
« Reply #3 on: December 02, 2011, 05:24:52 pm »
Oh I see, you want to know how much space these will take up in your program?  Well simply placing 55 on a single line will take up 3 bytes of program space.  Same with placing Str1 on a single line.  That Hello string looks like it has 4 spaces on the end, so it would take up 9 bytes.

Note however that will not always be constant, with things like automatic optimizations and the peephole routines, size is relative to change in a hard-to-predict manner.  Out of curiosity, why do you want to know how much space these take up in the actual program?

Offline collechess

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +22/-2
    • View Profile
Re: Axe Space Questions
« Reply #4 on: December 02, 2011, 05:27:51 pm »
No, I want to access the elements by GDB1+something.  Do pointers take a constant amount, or vary based on what they point to?

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Space Questions
« Reply #5 on: December 02, 2011, 05:30:04 pm »
What do you mean by 'Pointers take a constant amount'?

Offline collechess

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +22/-2
    • View Profile
Re: Axe Space Questions
« Reply #6 on: December 02, 2011, 05:34:09 pm »
If I had


Code: [Select]
"HI"->Str1
"HELLO"->Str2
"GOODBYE"->Str3


Str1->GDB1
Str2
Str3

What would x be to access "GOODBYE" with GDB1+x

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Space Questions
« Reply #7 on: December 02, 2011, 05:37:31 pm »
Line 6 is illegal in Axe, but if you were using Str1+x in order to get the pointer to the start of "Goodbye", x would be 9, assuming lines 1 through 3 are included in the program in that order.  When storing strings to a pointer, Axe automatically adds a terminating byte to the end, making them 1 byte longer than the number of characters they contain.  "HI"->Str1 stores 3 bytes into the program, "Hello"->Str2 stores 6 bytes into the program.
« Last Edit: December 02, 2011, 05:39:05 pm by Builderboy »

Offline collechess

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +22/-2
    • View Profile
Re: Axe Space Questions
« Reply #8 on: December 02, 2011, 05:39:32 pm »
Thanks.  Can you do {Str1}->GDB1

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Space Questions
« Reply #9 on: December 02, 2011, 05:42:20 pm »
No, you can only store defined constant data into constant pointers.  GDB1 is not a list of data itself, it is only a pointer to data that has been stored into your program by Axe.  When you do [00]->Str1 in an Axe program, during compile, Axe inserts the byte 00 into the end of your program at a certain address $A.  From then on, whenever it sees the token Str1, it treats it as the number $A. 

Offline collechess

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +22/-2
    • View Profile
Re: Axe Space Questions
« Reply #10 on: December 02, 2011, 05:45:56 pm »
Ohhh.  That explains a lot of bugs in my programs.  Thanks for the help.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Space Questions
« Reply #11 on: December 02, 2011, 05:46:50 pm »
No problem, pointers can be a hard thing to understand at first, especially when we are used to treating Str1 as an actual container of data.

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: Axe Space Questions
« Reply #12 on: December 02, 2011, 10:53:18 pm »
By the way, I assume you are trying to make a method to access the nth string correct?  This can be done fairly easily by using the [00] terminating character for strings.  The string that comes before the Nth [00] is the Nth string.  So suppose you had this:


[]->Str1
"Hello"[00]
"World"[00]
"Goodbye"[00]
"Awesome"[00]


You can grab the Nth string (count starting at zero) with this simple subroutine:


Lbl Grab
0->A
For(r2,1,r1)
inData(0,A+Str1)+A->A
End
Return A+Str1


Now calling Grab(0) returns a pointer to "Hello", Grab(1) returns "World", Grab(2) is "Goodbye", etc.
« Last Edit: December 02, 2011, 10:54:35 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Axe Space Questions
« Reply #13 on: December 05, 2011, 07:06:16 am »
You can do this too:

"Hello"->Str1
"Baibai"->Str2
"Doyado"->Str3
Data(Str1,Str2,Str3)->GDB1

Then use {GDB1+x} to access the pointers to the strings.
I'm not a nerd but I pretend: