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

# zasm - Z80 Assembler – Version 4.4

# Pseudo instructions

[<prev] [next>]

| ### Label definition
    <name>[:][:] [<instruction>]
    <name>[:][:] Pseudo instructions: equ
    Types of labels: Named values
    Labels: EQUequ  <value>
    <name>[:][:] =    <value>
    <name>[:][:] Pseudo instructions: defl, set and '='
    Labels: SETset  <value>
    <name>[:][:] defl <value>
    #define <name>    <value>
Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels Label names may be of any length. Upper or lower case is distinguished. The Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label name may be followed by one or two colons ':'. Normally, label definitions must start in column 1 and instructions must be indented with some spaces. The assembler decides based on the starting column of a name whether it is a label definition or an instruction. Any name which starts in column 1 and is not an assembler directive (which always starts with a hash '#') or a comment (which always starts with a semicolon ';') is treated as a label definition. unless --Command Line Options: --dotnames, .dotnames Commands for command line options: --dotnames, .dotnames Label definition: --dotnames dotnames is also Pseudo instructions: defl, set and '=' Labels: SET set, Pseudo instructions 8080 Assembler: 8080 pseudo instructions pseudo instructions starting with a dot are also recognized in column 1. ##### --reqcolon Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endif If the source is assembled with Differences from v3 to v4: Command line options Command Line Options Command Line Options: Command line options command line option '--reqcolon', then one colon is required after the Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label name. This allows label definitions to start in any column, either in column 1 as usual or indented with some spaces and tabs, and it allows instructions to start in column 1. The assembler decides based on the existance or absence of a colon whether it is a label definition or an instruction. Note: even with --reqcolon no colon is required after Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels labels defined with 'Pseudo instructions: equ Types of labels: Named values Labels: EQU equ' and similar. Recommendation: Start label definitions in column 1, indent instructions with one or two tabs and put a colon after label definitions. ##### --dotnames Normally Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label names cannot start with a dot. Names starting with a dot were introduced by some assemblers to easily distinguish betwen Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label names, instructions and assembler Pseudo instructions 8080 Assembler: 8080 pseudo instructions pseudo instructions, so these could be written in column 1 Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endif if the programmer desired so. Having seen that, some people immediately developed the need to start their Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label names with a dot as well… Recommendation: Don't start Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label names with a dot. ##### --casefold Normally Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label names are case sensitive or people just tend to just write them allways in the same way. Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endif If an older source does not distinguish between uppercase and lowercase writing of Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label names, then you can use this option to tell zasm to ignore upper and lower case as well. Note: instruction and register names are always case insensitive. This option is implied by --asm8080. Recommendation: Don't use this option unless required. #### Types of labels ##### Program labels
    <name>[:][:] [<instruction>]
Types of labels: Program labels Types of labels: Program labels Program labels basically are what we just talked about: A name put in front of an instruction to give the current code position a name so that it can be used in a later call or jp statement.
    foo:    jp  _bar
This defines a Types of labels: Program labels Types of labels: Program labels program label named 'foo' and the instruction jumps to a Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label named '_bar' which is likely a Types of labels: Program labels Types of labels: Program labels program label as well. The address of the current instruction can also be referenced as '$', so in some easy cases you don't need to define a Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label. Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endif If you request that your list file includes accumulated cpu cycles, then the counter is reset at every Types of labels: Program labels Types of labels: Program labels program label definition. ##### Named values
    <name>[:][:] Pseudo instructions: equ
    Types of labels: Named values
    Labels: EQUequ  <value>
    <name>[:][:] =    <value>
    #define <name>    <value>
Frequently you start your source with a bunch of definitions for constant values, like printing control codes or port addresses. These definitions require the keyword 'Pseudo instructions: equ Types of labels: Named values Labels: EQU equ' after the Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label, in exchange a colon after the Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label name is never required, even with --reqcolon, but may be present.
    foo     Pseudo instructions: equ
    Types of labels: Named values
    Labels: EQUequ 255 -1
    bar     Pseudo instructions: equ
    Types of labels: Named values
    Labels: EQUequ 255 -2
    shelf   =   0xffff
    #define foobar foo & bar
Most assemblers require keyword 'Pseudo instructions: equ Types of labels: Named values Labels: EQU equ', some use '='. The use of 'Pseudo instructions: equ Types of labels: Named values Labels: EQU equ' is recommended. Additionally zasm supports the use of the c preprocessor-style definition using '#define'. ##### Redefinable named values
    <name>[:][:] Pseudo instructions: defl, set and '='
    Labels: SETset  <value>
    <name>[:][:] defl <value>
Especially for use in Pseudo instructions: macro, .macro, endm and .endm 8080 pseudo instructions: MACRO macros it is possible to define Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels labels which can be redefined to another value. These definitions require the keyword 'Pseudo instructions: defl, set and '=' Labels: SET set' or 'defl' after the Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label, in exchange a colon after the Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label name is never required, even with --reqcolon, but may be present. Note: don't confuse the 'Pseudo instructions: defl, set and '=' Labels: SET set' Pseudo instructions 8080 Assembler: 8080 pseudo instructions pseudo instruction with the Command Line Options: --z80 Pseudo instructions: .z80, .z180 and .8080 Targets: #target Z80 Z80's 'Pseudo instructions: defl, set and '=' Labels: SET set' instruction! This defines a Pseudo instructions: macro, .macro, endm and .endm 8080 pseudo instructions: MACRO macro which counts the occurances of something: Note: the final count is only valid after the last use of this Pseudo instructions: macro, .macro, endm and .endm 8080 pseudo instructions: MACRO macro in your source!
    foo     Pseudo instructions: defl, set and '='
    Labels: SETset 0
            Pseudo instructions: macro, .macro, endm and .endm
    8080 pseudo instructions: MACROmacro COUNT
    foo     Pseudo instructions: defl, set and '='
    Labels: SETset foo+1
            Pseudo instructions: macro, .macro, endm and .endm
    Pseudo instructions: rept, .rept, endm and .endmendm
Use of a redefinable Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label in place of a Types of labels: Program labels Types of labels: Program labels program label: Note: forward jumping can't be implemented this way!
            Pseudo instructions: macro, .macro, endm and .endm
    8080 pseudo instructions: MACROmacro WAIT &N
            ld      b,&N
    foo     defl    $
            call    wait_1ms
            djnz    foo
            Pseudo instructions: macro, .macro, endm and .endm
    Pseudo instructions: rept, .rept, endm and .endmendm
The value is valid from the position where it was defined to the position where it is redefined or the Pseudo instructions: end, .end 8080 pseudo instructions: END end of the source. References to this Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label before it's first definition are illegal! ##### global labels Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels Labels are defined in the current 'scope', which is either the default global scope or, after Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal#local, a Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal local scope. Normally Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels labels defined after Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal#local are only known in the Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal local scope:
    Assembler directives: #local, #endlocal, .local and .endlocal
    Pseudo instructions: #local, #endlocal, .local and .endlocal
    Including C Source Files: #local, #endlocal, .local and .endlocal#local
    foo:    nop
            ...
            jr  foo
    Assembler directives: #local, #endlocal, .local and .endlocal
    Pseudo instructions: #local, #endlocal, .local and .endlocal
    Including C Source Files: #local, #endlocal, .local and .endlocal#endlocal
You can also define global labels inside a Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal local scope: Just put two colons '::' after the Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label name or use the Pseudo instructions 8080 Assembler: 8080 pseudo instructions pseudo instruction '.globl':
    Assembler directives: #local, #endlocal, .local and .endlocal
    Pseudo instructions: #local, #endlocal, .local and .endlocal
    Including C Source Files: #local, #endlocal, .local and .endlocal#local
            .globl  bar
    foo::   nop             ; global
            ...
    bar:    nop             ; global
            ...
    shelf:: Pseudo instructions: equ
    Types of labels: Named values
    Labels: EQUequ foo+1       ; global
    Assembler directives: #local, #endlocal, .local and .endlocal
    Pseudo instructions: #local, #endlocal, .local and .endlocal
    Including C Source Files: #local, #endlocal, .local and .endlocal#endlocal
##### Reusable labels zasm supports the 'recyclable' Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels labels used by sdcc:
    foo::
            ...
    123$:   nop
            jp  123$
            jp  199$
    199$:   nop
            ...
    bar::
            ...
    123$:   nop
            ...
The name of a reusable label is only valid in the range between two normal Types of labels: Program labels Types of labels: Program labels program labels. The naming scheme is a little but unlucky. Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endif If you put a dollar sign '$' after a number it becomes a Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labels label name. :-/ |

[<prev] [top] [next>]