| back |  | Last regenerated: 2022-04-20 17:31:36 kio

# zasm - Z80 Assembler – Version 4.4

# Pseudo instructions

[<prev] [next>]

| ### .phase and .dephase
        .phase <address>
        ...
        .dephase
This Pseudo instructions 8080 Assembler: 8080 pseudo instructions pseudo instruction Pseudo instructions: defl, set and '=' Labels: SET sets the logical origin for the following code to the new address. The new logical origin is valid until the .dephase instruction resets it to the physical origin or another .phase instruction Pseudo instructions: defl, set and '=' Labels: SET sets it to another value. (note: in zasm v3 'org' was used to change the logical origin.) The logical code address is what you mostly work with. E.g. Types of labels: Program labels Types of labels: Program labels program labels and '$' refer to the logical code address. This logical code address can be moved with .phase and .dephase. The physical code address is the address at which the code stored by the assembler is supposed to be visible to the cpu. (At least it should be.) Because most code is executed where it was stored (which means: it was not copied somewhere else in ram before it is executed there) the physical and the logical address are most times the same. .phase and .dephase are typically used Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endif if some portions of code are copied from rom into ram, where it can be modified by the running program. In case you need to access the physical address of the code at a position where you have shifted the logical address with .phase you can use '$$' instead of '$'. Note: the physical code address is biased to the 'org' address resp. to the start address of the current Assembler directives: #code Including C Source Files: #code#code or Assembler directives: #data Including C Source Files: #data#data segment, not the start of the eprom! ##### Example: relocated jump table In this #insert: Examples: #assert: Example: incbin: Examples: #assert: Example:example a jump table is copied from rom to ram, either to Assembler directives: #assert Pseudo instructions: #assert assert fixed addresses or to allow the running program to patch some entries:
                ...                 ; some code
                ccf
                ret

                .phase  $FE00       ; shift origin
    rom_table:  Pseudo instructions: equ
    Types of labels: Named values
    Labels: EQUequ $$
    ram_table:  Pseudo instructions: equ
    Types of labels: Named values
    Labels: EQUequ $

    putchar:    jp      putchar_rom
    puttext:    jp      puttext_rom
    getchar:    jp      getchar_rom
    getline:    jp      getline_rom

    table_size: Pseudo instructions: equ
    Types of labels: Named values
    Labels: EQUequ     $ - ram_table

                .dephase            ; back to physical code address

    gizmo:      ld      de,ram_table
                ld      hl,rom_table
                ld      bc,table_size
                ldir

                ld  a,0             ; more code
                ...

[<prev] [top] [next>]