Data Types - absoluteAquarian/CSASM GitHub Wiki

CSASM supports a select few data types.

~arr

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

~set

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

~range

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

^<u32> (Index)

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

char

Character literal
Example:

  • push 'a'

f32

32-bit floating-point
Example:

  • push 1.0f

f64

64-bit floating-point
Example:

  • push 1.0

i16

Signed 16-bit integer

i32

Signed 32-bit integer
All integer constants default to this type.

i64

Signed 64-bit integer

i8

Signed 8-bit integer

obj

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

str

String literal
Example:

  • push "Hello, World!"

u16

Unsigned 16-bit integer

u32

Unsigned 32-bit integer

u64

Unsigned 64-bit integer

u8

Signed 8-bit integer

⚠️ **GitHub.com Fallback** ⚠️