-
-
Notifications
You must be signed in to change notification settings - Fork 57
Address manipulation directives β #addr, #align, #res
You can skip ahead to a certain address within the current bank by using
the #addr
directive. Skipped bits will be filled with zeroes.
For example:
#d8 0xab, 0xcd, 0xef
#addr 0x8
#d8 0xab, 0xcd, 0xef
...would be assembled into:
0x0: ab cd ef
0x3: 00 00 00 00 00
0x8: ab cd ef
Note how the directive skipped to the address 0x8
, leaving zeroes behind.
The #align
directive can be used to ensure that the next output will have an address evenly divisible by the given number of bits.
For example:
#d8 0xff
#align 32
loop:
jmp loop
...would be assembled to:
0x0: ff 00 00 00
0x4: 55 00 04
Note that the value passed to #align
is specified in bits, disregarding
the current #bits
setting.
The #res
directive advances the current address by the given value
without any data output. This effectively reserves a location for some
other desired purpose, usually variables in RAM. This directive can be
useful in non-writable banks.
For example, in a machine where data and instructions reside on the same memory space, you could do:
jmp start
variable:
#res 1
start:
lda 0x77
inc variable
...and it would be assembled into:
0x0: 55 00 04
0x3: 00
0x4: 10 77
0x6: cc 00 03
- 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