The P-Machine uses—or rather, would use—65536 (2^16) bits of ROM, the same as 8192 bytes or 64kb, and 256 bits of display memory (16x16 pixel screen). It also uses 6 registers (ba, bb, na, nb, ya, yb), a 1-bit conditional flag, and a call stack. It uses a bus width of 1 bit.
PASM uses the same memory as the P-Machine: 65536 bits of ROM, 256 bits of display memory, 6 registers, a conditional flag, and a call stack.
The P-Machine, and by extension PASM, uses 65536 bits of ROM.
The P-Machine has a 16x16 pixel black-and-white (1-bit colour) screen, and as such has 256 bits of display memory. It also has a display pointer, which can point to one pixel on the screen at a time.
PASM has access to 6 registers:
yb. Registers whose names start with
b store 1 bit,
n registers store 1 nybble, and
y registers store 1 byte.
The conditional flag a 1-bit flag.
The P-Machine also uses a call stack of unbounded size.
PASM code is grouped into sections. Sections can be declared by writing
[name] is the (alphanumeric) name of the section. The
.ent section is the entry point of the program. A section lasts until another section is declared. Within sections, instructions and labels can be written. Instruction arguments are separated by commas. Labels are delared by writing
[name]: before an instruction, and act partially like sections, except that they don't affect the call stack (see #Sections vs. labels).
An unlimited amount of instructions can be put within sections.
In instruction arguments,
[hex]h is a literal case-insensitive hexadecimal number, where
[hex] is the hexadecimal number; ROM can be referenced in programs by writing
[addr] is the address in hexadecimal; display memory, the display pointer, and the condition flag can not be referenced directly in programs; registers can be referenced in programs by writing
[reg] is the name of a register; and
@[name] represents the section or label called
; declares a comment until the end of a line. Spaces and tabs are ignored in programs.
Sections vs. labels
Jumping to a section pushes the location jumped to onto the call stack; jumping to a label does not.
List of instructions
||Sets the memory at |
||Sets the conditional flag to 1 if |
|Mathematical and logical operations|
||Jumps to |
||Jumps to |
||Jumps to |
||Halts the program with exit status |
||None||Do nothing (nop)|
||Sets the display pointer to (|
||Read the display at the display pointer and write it to |
Clear the screen to white
.ent mov %na,0h x: mov %nb,0h dofft %na,%nb y: dout 0h add %nb,1h cmp %nb,fh jz @y add %na,1h cmp %na,fh jz @x
Takes the top-left pixel of the screen as input (white is 0, black is 1). Sets the bottom-right pixel to 0 on input 0, infinitely toggles it on input 1.
.ent dofft 0h, 0h din %na cmp %na,1h dofft fh, fh inf: dout %na dout 0h jnz @inf