Basics
PASM has a simple syntax. Each statement stands on its own line. Statements begin with a Parrot instruction code (commonly referred to as an “opcode”). The arguments follow, separated by commas:
[label]opcodedest,source,source...
If the opcode returns a result, it is stored in the first argument. Sometimes the first register is both a source value and the destination of the operation. The arguments are either registers or constants, though only source arguments can be constants:
LABEL:
print "The answer is: "
print 42
print "\n"
end # halt the interpreter
Comments
are marked with the hash sign (#) and continue to
the end of the line. Any line can start with a label definition like
LABEL:, but label definitions can also stand
on their own line.
Constants
Integer constants are signed integers.[35]
Integer
constants can have a positive (+) or negative
(-) sign in front. Binary integers are preceded by
0b or 0B, and hexadecimal
integers are preceded by 0x or
0X:
print 42 # integer constant print -0b101 # binary integer constant with sign print 0Xdeadbeef # hex integer constant
Floating-point constants can also be positive or negative. Scientific
notation provides an exponent, marked with e or
E (the sign of the exponent is optional):
print 3.14159 # floating point constant print -1.23e+45 # in scientific notation
String constants are wrapped in single or double quotation marks. Quotation marks and other nonprintable characters inside the string have to be escaped by a backslash. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access