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

zasm - Z80 Assembler – Version 4.4

Pseudo instructions

Literal text replacement using "{...}"

since version 4.2.6: in Pseudo instructions: macro, .macro, endm and .endm
8080 pseudo instructions: MACRO
macros
since version 4.4.6: everywhere

Before a source line is assembled, Expressions
8080 Assembler: Expressions
expressions between "{" and "}" are resolved.

Literal text replacement is typically used to create calculated Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
label names and can solve a common problem with Pseudo instructions: macro, .macro, endm and .endm
8080 pseudo instructions: MACRO
macros.

mx = 0  ; a counter which serves as a seed for Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
labels in all Pseudo instructions: macro, .macro, endm and .endm
8080 pseudo instructions: MACRO
macros ; .Pseudo instructions: macro, .macro, endm and .endm
8080 pseudo instructions: MACRO
macro extend_sign ; a Pseudo instructions: macro, .macro, endm and .endm
8080 pseudo instructions: MACRO
macro with a forward jump ld h,0 ld a,l add a jr nc,L{mx} ; jump forward dec h L{mx}: mx = mx+1 ; next use of Pseudo instructions: macro, .macro, endm and .endm
8080 pseudo instructions: MACRO
macro will use next number .Pseudo instructions: macro, .macro, endm and .endm
Pseudo instructions: rept, .rept, endm and .endm
endm

While backward jumps in Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
labels can simply use a redefinable Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
label to jump to, this is not possible with forward jumps. Besides other solutions (you could create 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
context in your Pseudo instructions: macro, .macro, endm and .endm
8080 pseudo instructions: MACRO
macro) you can generate Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
label names using a counter. In the above #insert: Examples:
#assert: Example:
incbin: Examples:
#assert: Example:
example the first use of the Pseudo instructions: macro, .macro, endm and .endm
8080 pseudo instructions: MACRO
macro would use Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
label L0, the second L1 and so on.

You can also iterate over a range of programmatically named Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
labels:

_n = 0
.Pseudo instructions: rept, .rept, endm and .endm
8080 pseudo instructions: REPT
rept mx .Pseudo instructions: defw, dw, .dw, .word
8080 pseudo instructions: DW
dw L{_n} _n = _n +1 .Pseudo instructions: macro, .macro, endm and .endm
Pseudo instructions: rept, .rept, endm and .endm
endm

This will generate an array with all addresses where Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
label L{mx} in the above #insert: Examples:
#assert: Example:
incbin: Examples:
#assert: Example:
example was used.
Actually you can implement arrays of Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
labels this way e.g. to automatically create jump tables.

Valid HTML   Valid CSS