Skip to content

Address manipulation directives β€” #addr, #align, #res

Lorenzi edited this page Mar 6, 2021 · 1 revision

Address directive

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.

Align directive

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.

Reserve directive

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