|
since version 4.2.6: in Pseudo instructions: macro, .macro, endm and .endm 8080 pseudo instructions: MACROmacros since version 4.4.6: everywhere
Before a source line is assembled, Expressions 8080 Assembler: Expressionsexpressions between "{" and "}" are resolved.
Literal text replacement is typically used to create calculated Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabel names and can solve a common problem with Pseudo instructions: macro, .macro, endm and .endm 8080 pseudo instructions: MACROmacros.
mx = 0 ; a counter which serves as a seed for Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabels in all Pseudo instructions: macro, .macro, endm and .endm 8080 pseudo instructions: MACROmacros
;
.Pseudo instructions: macro, .macro, endm and .endm 8080 pseudo instructions: MACROmacro extend_sign ; a Pseudo instructions: macro, .macro, endm and .endm 8080 pseudo instructions: MACROmacro 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: MACROmacro will use next number
.Pseudo instructions: macro, .macro, endm and .endm Pseudo instructions: rept, .rept, endm and .endmendm
While backward jumps in Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabels can simply use a redefinable Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabel 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 .endlocallocal context in your Pseudo instructions: macro, .macro, endm and .endm 8080 pseudo instructions: MACROmacro) you can generate Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabel 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: MACROmacro would use Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabel 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: Labelslabels:
_n = 0
.Pseudo instructions: rept, .rept, endm and .endm 8080 pseudo instructions: REPTrept mx
.Pseudo instructions: defw, dw, .dw, .word 8080 pseudo instructions: DWdw L{_n}
_n = _n +1
.Pseudo instructions: macro, .macro, endm and .endm Pseudo instructions: rept, .rept, endm and .endmendm
This will generate an array with all addresses where Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabel 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: Labelslabels this way e.g. to automatically create jump tables.
| |