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

# zasm - Z80 Assembler – Version 4.4

# Pseudo instructions

[<prev] [next>]

| ### org, .org or .loc
        org <value>
        .org <value>
        .loc <value>
        org <value>, <fillbyte>
The Pseudo instructions 8080 Assembler: 8080 pseudo instructions pseudo instruction 'org' has two use cases: It can define the start address of the assembler code or it can insert some space up to the new address. #### Define the start address for the code zasm requires that the source initially defines the address where the code will be stored and run. This can be done in either of two ways: Define a Assembler directives: #target Including C Source Files: #target#target and subsequently some #code and #data segments Just define a code origin with 'org'. Using 'org' is the traditional way for old sources. The code origin must be defined before any real code. When the origin is defined, zasm will silently create a single code segment. Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endif If you use 'org' you cannot specify a target or define multiple code segments or any data segments. Then Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels labels for data and variables in ram must be defined like other const values with 'Pseudo instructions: equ Types of labels: Named values Labels: EQU equ' or similar. Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endif If you want to create code for a special target or Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endif if you want to include c sources then you must use Assembler directives: #target Including C Source Files: #target#target, #code and #data and cannot use 'org' to define the start address of your code. 'org' actually defines two kinds of addresses: the 'physical' code address and the 'logical' code address 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. The logical code address can be moved with `.phase` and `.dephase`. The physical code address is the address at which the generated code is actually visible to the cpu. (At least it should be.) Because most code is executed at the same address where it is visible to the cpu (which means: it is not copied somewhere else in ram before it is executed there) the physical and the logical address are most times the same. 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! #### Insert space up to a new address The second use case for 'org' – which can also be used Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endif if you use Assembler directives: #target Including C Source Files: #target#target, #code and #data – is to advance the code position up to the new logical origin, filling the space with the current segment's default #code: Fill Byte #code: Fill Byte fill byte. The default #code: Fill Byte #code: Fill Byte fill byte is $FF for ROMs and $00 for all other target formats. Since version 4.3.6 the #code: Fill Byte #code: Fill Byte fill byte can be specified as a second argument to 'org'. This is the same as with 'defs'. Note: This second behavior of 'org' differs from the behavior in zasm v3. In zasm v3 'org' was solely used to Pseudo instructions: defl, set and '=' Labels: SET set the logical origin. Use .phase and .dephase for this now! The 'org' instruction is most commonly used to advance the code position up to the address of the next restart vector:
        org 8
is the same as
        defs    8-$
'org' behaves exactly the same Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endif if you use it in a Assembler directives: #code Including C Source Files: #code#code or Assembler directives: #data Including C Source Files: #data#data segment:
    Assembler directives: #code
    Including C Source Files: #code#code _FOO, 0x4F00
        org 0x5000
        ...
This will insert 256 spaces at the beginning of the segment. Name '.loc' is also recognized to support sources for different assemblers. `org` is recommended, the others are deprecated for new source. |

[<prev] [top] [next>]