Registers - absoluteAquarian/CSASM GitHub Wiki
CSASM contains several predefined variables, called "registers", for usage when creating local/global variables is undesirable.
General-Purpose Registers
The $a
, $1
, $2
, $3
, $4
and $5
registers are of type obj
, meaning they can be used to store any type of value.
Furthermore, CSASM is smart enough to know what type a value in an obj
variable is when used for an instruction, so converting the value beforehand isn't required.
The $a
register, named the "accumulator", has special treatment.
A handful of instructions manipulate it directly instead of the stack, namely the conv.a
, is.a
, lda
and sta
instructions.
Flag Registers
Registers prefixed with $f.
are the flag registers.
These registers use the bool
type, a type not directly accessible by CSASM.
Currently, the flag registers include the following registers:
- Carry (
$f.c
)- This register is modified by the
rol
andror
instructions - The
clf.c
andstf.c
instructions clear and set this register, in that order
- This register is modified by the
- Conversion (
$f.n
)- This register is set by the
conv
instruction when a conversion from astr
value to a numerical type was successful - The
clf.n
andstf.n
instructions clear and set this register, in that order
- This register is set by the
- Comparison (
$f.o
)- This register is set by the
comp
,comp.gt
,comp.gte
,comp.lt
,comp.lte
,is
,is.a
andisarr
instructions - The
clf.o
andstf.o
instructions clear and set this register, in that order
- This register is set by the
Console Registers
Registers prefixed with $con.
are the console registers.
These registers modify aspects of the console.
Register | Type | Usage |
---|---|---|
$con.bcol |
i32 |
Gets or sets the background colour for the text written to the console |
$con.bh |
i32 |
Gets or sets the buffer height of the console: the amount of rows of characters the console can contain |
$con.bw |
i32 |
Gets or sets the buffer width of the console: the amount of columns of characters the console can contain |
$con.caps |
bool |
Gets whether the CAPS LOCK key is active |
$con.cx |
i32 |
Gets or sets the column the cursor is located at |
$con.cy |
i32 |
Gets or sets the row the cursor is located at |
$con.fcol |
i32 |
Gets or sets the foreground colour for the text written to the console |
$con.ttl |
str |
Gets or sets the title of the console window |
$con.wh |
i32 |
Gets or sets the window height of the console: how many rows of characters are displayed at once |
$con.ww |
i32 |
Gets or sets the window width of the console: how many columns of characters are displayed at once |
File I/O Registers
These registers are explained in detail in the File I/O page on the wiki.
Miscellaneous Registers
These registers do not fit in any of the above categories.
$args
: An~arr:str
representing the arguments passed to the program, excluding the defined debugging flags (-verbose
and-reportstack
)$as.e
: The empty arithmetic set (∅). This register is of type~set
.