7.6 IMCC Quick Reference
This is a summary of PIR directives
and instructions. Any PASM opcode is valid in PIR code, so you should
also look at Section 6.9. For more details and the
latest changes, see
languages/imcc/docs/syntax.pod or dive into the
source code in languages/imcc/imcc.l and
languages/imcc/imcc.y.
7.6.1 Directives
Push a value onto the user stack.
Define a named constant.
Define a named macro that expands to a given value. Macros are called
as directives, so .NAME
(PASM code only).
Define a compilation unit of PASM code. Always paired with
.eom.
End a compilation unit. Always paired with .sub.
End a macro definition. Always paired with .macro.
End a namespace. Always paired with .namespace.
End a compilation unit of PASM code. Always paired with
.emit.
Include the contents of an external file by inserting it in place.
Define a local named variable.
Define a named macro with a list of parameters. The macro is called
as .NAME
(arg1,arg2,...).
Always paired with .endm. (PASM code only.)
Define a namespace. Always paired with
.endnamespace.
.param DEST
.param TYPE NAME
|
|
Pop a value off the user stack into a register or typed identifier.
Pop a value off the user stack.
Return a value to the calling subroutine by pushing it onto the user
stack.
Define a compilation unit. Always paired with
.end. Names begin with
"_" by
convention.
Same as .local.
7.6.2 Instructions
Assign a value to a particular register, temporary register, or named
variable.
Add two numbers or PMCs.
DEST = VAL1 - VAL2
DEST = - VAL
|
|
Subtract VAL1 from
VAL2. The unary
"-" negates a
number.
Multiply two numbers or PMCs.
Divide VAL1 by
VAL2.
Raise VAL1 to the power of
VAL2.
Divide VAL1 by
VAL2 and return the
(mod) remainder.
Concatenate two strings.
if VAL1 < VAL2 goto LABEL
|
|
Conditionally branch to a label if VAL1 is
less than VAL2.
if VAL1 <= VAL2 goto LABEL
|
|
Conditionally branch to a label if VAL1 is
less than or equal to VAL2.
if VAL1 > VAL2 goto LABEL
|
|
Conditionally branch to a label if VAL1 is
greater than VAL2.
if VAL1 >= VAL2 goto LABEL
|
|
Conditionally branch to a label if VAL1 is
greater than or equal to VAL2.
if VAL1 = = VAL2 goto LABEL
|
|
Conditionally branch to a label if VAL1 is
equal to VAL2.
if VAL1 != VAL2 goto LABEL
|
|
Conditionally branch to a label if VAL1 is
not equal to VAL2.
Logical AND. Return VAL1 if
it's false, VAL2 if
VAL1 is true.
Logical OR. Return VAL1 if
it's true, VAL2 if
VAL1 is false.
Logical XOR. Return VAL1 if
it's true and VAL2 is
false. Return VAL2 if
VAL2 is true and
VAL1 is false. Otherwise, return false.
Logical NOT. Return a true value if VAL is
false.
Bitwise AND on two values.
Bitwise OR on two values.
DEST = VAL ~ VAL
DEST = ~ VAL
|
|
Bitwise XOR on two values. The unary form is a bitwise NOT on a value.
Bitwise shift VAL1 left by
VAL2 number of bits.
Bitwise shift VAL1 right by
VAL2 number of bits.
Logically shift VAL1 right by
VAL2 number of bits.
DEST = PMC [ KEY ]
PMC [ KEY ] = VAL
|
|
Indexed access to a PMC and indexed assignment to a PMC.
DEST = STRING [ OFFSET ]
STRING [ OFFSET ] = VAL Access a one-character substring on a string, starting at a
particular offset, or assign to that substring.
Return the address of a label.
Call the named subroutine (a .sub label).
Create a clone of a variable.
Test a value or keyed value for definedness.
DEST = global NAME
global NAME = VAL
|
|
Access a global for read or write.
Jump to the named identifier (label or subroutine name).
If the value or expression evaluates as true, jump to the named
identifier.
Create a new PMC of type TYPE.
Unless the value evaluates as true, jump to the named
identifier.
|