Data Types - absoluteAquarian/CSASM GitHub Wiki
CSASM supports a select few data types.
One-dimensional array
When used as the type for local/global variables, the proper format is ~arr:<type>,<length>
.
-
<type>
is one of the other CSASM types except for~arr
-
<length>
is an unsigned integer
When used in file I/O for reading a value from a file, only ~arr
needs to be specified.
When used as the operand for the conv
instruction, the length must be omitted.
Example:
push "Hello!"
conv ~arr:char
However, if the value on the stack is a ~set
or ~range
, the type must be omitted as well, due to both of these types only mapping to ~arr:i32
values.
Example:
push [1..5]
conv ~arr
Examples:
.local args : ~arr:obj,1
io.r0 ~arr
An arithmetic set, such as { 1, 3, 4, 6, 10 }
.
Can be converted to and from an ~arr:i32
value.
Example:
push {1,3,4,6,10}
print
A range of integers, such as [-5..20]
and [2..7]
. Supports having the endpoints be ^<u32>
(indexer) values.
Can be converted to an ~arr:i32
value, but only when the endpoints are integers.
Examples:
push [-5..20]
conv ~arr
push "Hello World!"
push [0..^4]
substr
push "Hello World!"
push [^6..^2]
substr
Indexer
This type is for indexing into ~arr
and str
objects indirectly
When used as the type for local/global variables or as the type in an ~arr
object, ^<u32>
should be used instead
When defining constants, a number is expected after the ^
character
Examples:
push ^1
.local a : ^<u32>
ldelem ^1
Character literal
Example:
push 'a'
32-bit floating-point
Example:
push 1.0f
64-bit floating-point
Example:
push 1.0
Signed 16-bit integer
Signed 32-bit integer
All integer constants default to this type.
Signed 64-bit integer
Signed 8-bit integer
Object
This type can be used to store values of any other type.
Examples:
.local array : obj
push 15
newarr i32
pop array
.local value : obj
push 1.0f
pop value
String literal
Example:
push "Hello, World!"
Unsigned 16-bit integer
Unsigned 32-bit integer
Unsigned 64-bit integer
Signed 8-bit integer