manual:chapter5:asm

This is an old revision of the document!


Registers and pseudo-registers

There are 8 global and persistent registers, named A through H, free for the users to assign any object to them.

There's 7 pseudo-registers that correspond to the stack levels: S1 through S7.

Finally there's 2 additional pseudo-registers P and R. P pushes a result to the stack, and it is used only as a destination register, not as an argument. R is a reference to the next object in the executing program. R cannot be used as a destination.

Instruction syntax

Asm instructions always must start with colon : and may not have any spaces. Wherever a separator is needed, use the dot ..

Statements always have:

  • An optional destination (A-H, S1-S7 or P)
  • An optional assignment operator (=, +=, -=, *= or /=)
  • An operator or command (+,-,*,/,^ as operators, or other commands as listed below)
  • One or 2 arguments to the operator or command. Arguments can be a register or reference (A-H, S1-S7 or R), or an integer number in the range 0-15.

Examples:

a) Simple assignments with operators:

:A=B+1 –> adds one to the register B and assigns the result to A.

:P=A –> Pushes the register A to the stack

:A=S2 :S2=S1 :S1=A –> Equivalent to SWAP

:C+=B^2 –> Squares B, adds the result to C

b) Assignment with math functions or commands

:A+=ABS.S1 –> Adds ABS(Stack level 1) to the value of A. :C*=SIN.A –> Compute SIN(A) and multiply with the content of C.

c) Comparison: :CMP.A.B –> Compares A and B and sets internal flags

d) Flow control: :SKIP.EQ –> Skip next instruction if result of last comparison was Equal. Other possible comparison results are LT (less than), LTE (less than or equal), GT (greater than), GTE (greater than or equal), or NE (not equal)

:LOOP.EQ –> Must be followed by a program or secondary « … » or :: … ;. It will repeat the secondary while the result of the last comparison matches, see SKIP for other comparisons. Notice the program that follows MUST update the internal flags with a :CMP.x.y instruction or it will loop infintely.

e) Stack helpers: :A=POP.x.y –> Remove values from the stack (POP) from the given stack levels and store the values on registers A, B, C… starting with A, and as many values as needed. The argument x is either an integer number that refers to a stack level (1 to current stack depth), and can be given as a literal, as another register or reference to the stack.

  • manual/chapter5/asm.1574203288.txt.gz
  • Last modified: 2019/11/19 14:41
  • by claudio