Author Topic: Degree symbol  (Read 3131 times)

0 Members and 1 Guest are viewing this topic.

Offline coops

  • LV3 Member (Next: 100)
  • ***
  • Posts: 58
  • Rating: +3/-0
    • View Profile
Degree symbol
« on: September 07, 2016, 01:03:21 am »
Hey, just a quick question on the degree symbol. i noticed that its used in a lot of ya'lls code, but i'm not sure what it is used for. the command list says "Returns the address of the variable in memory."
So...i can basically use any name for the variable if i use the degree symbol?
...maybe a couple of examples could help me understand...

Offline jacobly

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 205
  • Rating: +161/-1
    • View Profile
Re: Degree symbol
« Reply #1 on: September 07, 2016, 03:07:06 am »
° in Axe is very much like & in C. EXP→X stores some value into some memory represented by "X". Where is this memory you ask? Why at the address °X. This means that EXP→X is actually the exact same thing as EXP→{°X}ʳ. In fact, X and {°X}ʳ are completely interchangeable for any access to the variable X.

One use for this is to sign extend a byte located in X. Axe has a signed{} command, but that requires an address to load from. The solution is to use signed{°X}.

Another use (which, oddly enough, I can't seem to find in Commands.html) is for creating named variables:

EXP→°AB creates a variable called AB which can be used just like variable A, etc, and is stored at the address EXP.

An example showing both uses is °A->°AA which creates a variable called AA which aliases (always contains the same value as) A.