6.9 PASM Quick Reference
This is a condensed list of PASM opcodes, sorted alphabetically
for easy reference. For complete details on each opcode and the
latest changes, read docs/core_ops.pod, or look at
all the .ops files in the main Parrot source
directory. We've followed a few conventions.
DEST is always the register where the result of
the operation is stored. Sometimes the original value of
DEST is one of the source values.
VAL indicates that the actual value might be a
literal integer, float, or string, or a register containing an
integer, float, string, or PMC. See core.ops for
the combinations allowed with a particular operation.
Return the absolute value of a number. If
VAL is left out,
DEST gets the absolute value of itself.
The arc cosine of VAL in radians.
add DEST, VAL
add DEST, VAL, VAL
|
|
Add two values and return the sum. If only one
VAL, add VAL to
DEST.
Logical AND. Return VAL1 if
it's false, VAL2 if
VAL1 is true.
The arc sine of VAL in radians.
The arc secant of VAL in radians.
Assign a value to a PMC.
atan DEST, VAL
atan DEST, VAL1, VAL2
|
|
The arc tangent of VAL1 /
VAL2 in radians (sign significant). If no
VAL2, the arc tangent of
VAL.
band DEST, VAL
band DEST, VAL, VAL
|
|
Bitwise AND on two values. If only one
VAL, bitwise AND on
DEST and VAL.
Bitwise NOT on VAL.
Bitwise OR on two values. If only one VAL,
bitwise OR on DEST and
VAL.
Toggle bytecode bounds checking in the interpreter (0 for off, 1 for
on).
Branch to a label. The label is calculated as a relative offset.
Intersegment branch to the location of the given fixup table entry.
Branch to a label, like branch, but also push the
current location onto the call stack so ret can
return to it.
bxor DEST, VAL
bxor DEST, VAL, VAL
|
|
Bitwise XOR on two values. If only one
VAL, bitwise XOR on
DEST and VAL.
chopn DEST, VAL1
chopn DEST, VAL1, VAL2
|
|
Remove VAL2 number of characters from
string VAL1. If no
VAL2, remove
VAL number of characters from string
DEST.
Return the character represented by the given number.
cleari
clearn
clearp
clears
|
|
Clear all registers of the given type
("i" = integer,
"n" = float,
"p" = PMC,
"s" = string).
Clone (deep copy) a string or PMC and return the result.
Close the filehandle in the given register.
C's built-in mod operator.
See also mod.
Trigger a garbage collection (GC) run.
Disable garbage collection runs (nestable).
Re-enable garbage collection runs.
compile DEST, COMPILER, SOURCE
|
|
Compile a string of source code with a given compiler PMC and store
the result.
Return a compiler PMC for a particular type of source code.
concat DEST, VAL
concat DEST, VAL, VAL
|
|
Concatenate two strings. If only one VAL,
concatenate VAL onto
DEST.
The cosine of VAL in radians.
The hyperbolic cosine of VAL in radians.
Toggle debugging in the interpreter (0 for off, 1 for on).
Decrement a value by 1.
defined DEST, PMC
defined DEST, PMC[KEY]
|
|
Test a keyed PMC value for definedness. If no
KEY, test a PMC for definedness.
Delete a keyed value from an aggregate PMC.
Delete a named property from a PMC.
See also setprop and getprop.
Return the depth of the user stack.
div DEST, VAL
div DEST, VAL1, VAL2
|
|
Divide VAL1 by
VAL2. If VAL2
is left out, divide DEST by
VAL.
dlfunc DEST, LIBRARY, SYMBOL, SIGNATURE
|
|
Look up a symbol in a dynamic link library PMC and create a
subroutine PMC for that symbol with the given signature.
End execution within the current code segment or halt the interpreter
if in the main code segment.
Return the type of an entry in the user stack, by position in the
stack.
Jump to a label if the two values are equal.
Return the system error code (INT) or message (STR).
Exchange the contents of two registers.
Test a PMC key for existence.
Base of the natural logarithm, e, to the power
of VAL.
The exsecant of VAL in radians.
Return the factorial of INT.
find_lex DEST, NAME
find_lex DEST, DEPTH, NAME
find_lex DEST, DEPTH, POSITION
|
|
Return the lexical variable of the given name from a lexical
scratchpad. If DEPTH is provided, only
return a variable from the scratchpad at that depth. A find by
position returns the variable at a particular position in the
scratchpad.
See also store_lex.
Return a global variable with the given name.
See also store_global.
find_method DEST, PMC, NAME
|
|
Look up a method by name in a PMC's vtable. Return a
method PMC.
Find the enum value for a PMC type or native Parrot datatype by name.
See also typeof.
Return the name of the current file.
Return the current line number.
Return the current package name.
Return the value of a named property on a PMC.
See also setprop and prophash.
Return the greatest common divisor of two values.
Toggle garbage collection debugging in the interpreter (0 for off, 1
for on).
Jump to a label if VAL1 is greater than or
equal to VAL2.
Jump to a label if VAL1 is greater than
VAL2.
The haversine of VAL in radians.
Jump to a label if the condition is a true value.
index DEST, STRING, SEARCH
index DEST, STRING, SEARCH, POS
|
|
Return the position of the first occurrence of
SEARCH string in
STRING, starting at
POS. If the POS
is unspecified, start at the beginning of the string.
Increment a value by one.
Return the depth of the integer stack.
Return information about the interpreter. An integer flag selects
which information to return, as listed in Table 6-7.
Table 6-7. Interpinfo flags
1
|
Allocated memory, in bytes.
|
2
|
Number of DOD sweeps performed.
|
3
|
Number of GC runs performed.
|
4
|
Number of active PMCs.
|
5
|
Number of active buffers.
|
6
|
Number of allocated PMCs.
|
7
|
Number of allocated buffers.
|
8
|
Number of new PMC or buffer headers allocated since last DOD run.
|
9
|
Number of memory blocks allocated since last GC run.
|
10
|
Amount of memory copied during GC runs, in bytes.
|
Restore a register from the integer stack.
Save a value onto the integer stack.
Call a subroutine, coroutine, or continuation stored in a PMC. If no
PMC register is specified, it calls the subroutine in
P0 and uses the standard calling conventions.
Otherwise, no calling convention is defined. Also
yield from a coroutine.
Jump to a specified absolute address.
See also set_addr.
Jump to an address, like jump, but also push the
current location onto the call stack so ret can
return to it.
Return the least common multiple of two values.
Jump to a label if VAL1 is less than or
equal to VAL2.
Return the character length of a string.
The natural logarithm of VAL.
Load a dynamic link library by name and store it in a PMC.
See also dlfunc.
The base 2 logarithm of VAL.
The base 10 logarithm of VAL.
Retrieve an entry from the user stack by position. A positive offset
counts from the top of the stack; a negative offset counts from the
bottom.
Logically shift a value right by a given number of bits.
Jump to a label if VAL1 is less than
VAL2.
mul DEST, VAL
mul DEST, VAL, VAL
|
|
Multiply two values and return the result. If only one
VAL, multiply
DEST by VAL.
mod DEST, VAL
mod DEST, VAL1, VAL2
|
|
Divide VAL1 by
VAL2 and return the remainder. If
VAL2 is left off, divide
DEST by VAL.
The operation is defined as:
x mod y = x - y * floor(x / y)
Jump to a label if the two values are not equal.
Return the negative of a number. If there is no
VAL, DEST is
the negative of itself.
new DEST, TYPE
new DEST, TYPE, INITIALIZE
|
|
Create a new PMC of type TYPE.
INITIALIZE is an array PMC of
initialization data for the new PMC.
new_pad DEPTH
new_pad DEST, DEPTH
|
|
Create a new lexical scope pad. If a destination PMC is provided,
store the pad in the PMC, otherwise push it onto the lexical scope
stack. DEPTH specifies the static nesting
depth for the pad (lower static depths are copied from the current
static nesting).
Create a new interpreter and store it in a PMC.
See also runinterp.
Do nothing.
Logical NOT. True if VAL is false.
open DEST, FILENAME, MODE
|
|
Open a file in the specified mode
("<",
">", etc.) and return a
filehandle.
Logical OR. Return VAL1 if
it's true, VAL2 if
VAL1 is false.
ord DEST, STRING
ord DEST, STRING, POS
|
|
Return the character at position POS in
STRING. If POS
isn't specified, return the 0th character.
Store the current lexical scope pad in a PMC.
Pop the last entry off an aggregate PMC and return it.
Pop the current lexical scope pad off the lexical scope stack.
See also peek_pad.
Restore all the registers of one type from the stack
("i" = integer,
"n" = float,
"p" = PMC,
"s" = string).
See also pushX.
Return VAL1 raised to the power of
VAL2.
Print a value to an I/O object or file descriptor. If no
IO is given, print the value to standard
output.
Print a string to stderr.
Toggle profiling in the interpreter (0 for off, 1 for on).
Return a hash containing all the properties from a PMC.
See also getprop.
Push a value onto the end of an aggregate PMC.
Push a scratchpad stored in a PMC onto the lexical scope stack.
Save all the registers of one type to the stack
("i" = integer,
"n" = float,
"p" = PMC,
"s" = string). Restore with
popX.
Print a value to stdout.
read DEST, BYTES
read DEST, IO, BYTES
|
|
Read the specified number of bytes from a Parrot I/O object. Read
from stdin if no IO is
provided.
Repeat a string REPEAT number of times.
Restore a register from the user stack.
Restore all the registers. Does a
popX for every type.
Go to the location on the top of the call stack (also pop it off the
stack). Often used with bsr and
jsr.
Rotate the top COUNT entries on the user
stack. A positive number rotates up: the top entry becomes the
COUNTth entry, and the others move up one
(the second entry becomes first, the third becomes the second, etc.).
A negative number rotates down: the
COUNTth entry becomes the top, and the
others move down (the first becomes second, etc.).
Use an interpreter stored in PMC to run code starting at a given
offset.
See also newinterp.
Save a value onto the user stack.
Save all the registers. Does a
pushX for every type.
Save a clone of a value onto the user stack.
The secant of VAL in radians.
The hyperbolic secant of VAL in radians.
seek DEST, IO, OFFSET, STARTFLAG
seek DEST, IO, UPPER32, LOWER32, STARTFLAG
|
|
Set the file position of a Parrot I/O object to a given offset from a
starting position (STARTFLAG: 0 is the beginning of the file, 1 is
current the position, 2 is the end of the file).
DEST is the success or failure of the
seek.
64-bit seek combines
UPPER32 and
LOWER32 to get one 64-bit
OFFSET.
Set a register to a value.
set DEST[KEY], VAL A keyed set operation on a PMC.
set DEST, PMC[KEY] A keyed get operation on a PMC.
Return the current address plus the offset to
LABEL. Often used to calculate absolute
addresses for jump or jsr.
Set the value of a named property on a PMC.
See also getprop and delprop.
Shift a value off the front of an aggregate PMC.
Bitwise shift a value left by a given number of bits.
Bitwise shift a value right by a given number of bits.
The sine of VAL in radians.
Sleep for the given number of seconds.
splice DEST, REPLACE, OFFSET, COUNT
|
|
Starting at OFFSET, replace
COUNT number of values in the destination
PMC with values provided in the REPLACE
PMC.
sprintf DEST, FORMAT, ARGS
|
|
Format arguments in an aggregate PMC, using format string
FORMAT.
store_lex NAME, OBJECT
store_lex DEPTH, NAME, OBJECT
store_lex DEPTH, POSITION, OBJECT
|
|
Store an object as a lexical variable with a given name. If the
symbol doesn't exist, it will be created in the
lexical scratchpad at the specified depth (a negative depth counts
back from the current scope). If DEPTH
isn't provided, the symbol must already exist. If a
position is provided instead of a name, the symbol will be stored at
the given position in the scratchpad.
See also find_lex.
store_global NAME, OBJECT
|
|
Store a global variable as a named symbol.
See also find_global.
stringinfo DEST, STRING, FLAG
|
|
Return information about a string. An integer flag selects which
information to return, as listed in Table 6-8.
Table 6-8. Stringinfo arguments
1
|
Location of string buffer header.
|
2
|
Location of start of string memory.
|
3
|
Allocated length, in bytes.
|
4
|
String flags.
|
5
|
Used length of string buffer, in bytes.
|
6
|
String length, in characters.
|
sub DEST, VAL
sub DEST, VAL1, VAL2
|
|
Subtract VAL2 from
VAL1. If no
VAL2, subtract
VAL from DEST.
substr DEST, STRING, OFFSET, LENGTH
substr DEST, STRING, OFFSET, LENGTH, REPLACE
substr DEST, OFFSET, LENGTH, REPLACE
|
|
Return a substring of a string. If REPLACE
is given, also replace substring in
STRING. If
STRING is left out, replace substring in
DEST.
Trigger a dead object detection (DOD) sweep.
Disable DOD sweeps (nestable).
Re-enable DOD sweeps.
The tangent of VAL in radians.
The hyperbolic tangent of VAL in radians.
Return the current system time.
Toggle tracing in the interpreter (0 for off, 1 for on).
Return the type of a PMC or Parrot data type, either class name (to a
string destination) or enum value (to an integer destination).
Jump to a label unless the condition is a true value.
Unshift a value onto the front of an aggregate PMC.
Check whether a PMC type or native Parrot datatype is a valid one.
The versine of VAL in radians.
Turn off a particular category of warnings: 1 = undef, 2 = IO, -1 =
all.
Turn on a particular category of warnings: 1 = undef, 2 = IO, -1 =
all.
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.
|