-
-
Notifications
You must be signed in to change notification settings - Fork 59
Expressions
-
123
,0b111_010
,0o137
,0x4bf86
Integer literals. Sizes are derived automatically from the given radix and digits (except for decimal literals), and leading zeroes matter in this regard. You can use an underscore_
to visually separate digits. If you need to explicitly indicate a value's size, you can use the slice operator, as seen below.
The following operators are listed in the order of the lowest precedence to the highest.
-
?
,? :
Binary and Ternary Conditional -
=
Assignment -
@
Concatenation -
||
Lazy Or -
&&
Lazy And -
==
,!=
,<
,<=
,>
,>=
Relational -
|
Binary Or -
^
Binary Xor -
&
Binary And -
<<
,>>
Binary Shifts -
+
,-
Addition and Subtraction -
*
,/
,%
Multiplication, Division, and Modulo -
[hi:lo]
Slice -
´size
Slice shorthand -
!
,-
Unary Not and Unary Negation
You can also use code blocks.
-
$
orpc
The address of the current instruction or the current expression in a data directive.
-
le(value)
Reverses the bytes of an integer, essentially performing little-endian encoding. It's important that the value have a size which is a multiple of 8 bits. For example:le(0x1234)
orle(65000`16)
. -
assert(condition)
Generates an error whencondition
is false. Useful to check for the validity of instruction arguments, and also for multiple-match resolution. -
utf8(str)
,ascii(str)
,utf16be(str)
,utf16le(str)
,utf32be(str)
,utf32le(str)
Reencodes the given string. For example,utf16be("abc")
will give you0x0061_0062_0063
. The default string encoding is alreadyutf8
, so that function is usually redundant. For theascii
encoding, invalid codepoints are converted to0x00
. -
incbin(relative_filename)
Reads the given binary file and returns its contents as a sized integer. Useful with the unsized data directive for including existing binary files into your output, for example as#d incbin("graphics.bin")
-
incbinstr(relative_filename)
Reads the given text file, which should only contain the ASCII digits0
and1
(ignoring whitespace and underscores), and returns the interpreted binary value as a sized integer. Useful for including files generated from customasm with thebinstr
format. -
inchexstr(relative_filename)
Reads the given text file, which should only contain the valid hexadecimal ASCII digits (ignoring whitespace and underscores), and returns the interpreted hexadecimal value as a sized integer. Useful for including files generated from customasm with thehexstr
format.
- Getting started
- Defining mnemonics — #ruledef, #subruledef
- Declaring labels and constants
- Setting the minimum addressable unit — #bits
- Outputting data blocks — #d
- Working with banks — #bankdef, #bank
- Address manipulation directives — #addr, #align, #res
- Splitting your code into multiple files — #include, #once
- Advanced mnemonics, cascading, and deferred resolution — assert()
- Available expression operators and functions — incbin(), incbinstr(), inchexstr()
- Functions — #fn
- Conditional Compilation — #if, #elif, #else