This is a Zilog Z80 assembler.
I've already written a Z80 assembler in Python which is available in my
z80 repository. The difference is that
zasm
is a 2-pass asm whereas the python one passed the source several times and
is significantly slower.
; Comment (until newline)
label:
ld hl, [msg + 2] ; Indirect addressing is using [square brackets].
; This is different from most Z80 assemblers
; which use (parentheses).
; Expressions (including labels and characters)
; are allowed.
jp $ ; $ = current address
RET NZ ; Instructions, conditions and directives are
; case-insensitive.
; Directives
include "another/file.s" ; Include another source
incbin "binary/file.bin" ; Include binary data
org 0x8000 ; Assume the code is loaded at address 0x8000
db "Hello, World!", 10, 0 ; Emit bytes
dw 'a' ; Emit words (this example will result in
; 0x61 0x00 being emitted)
ds 100, 45 ; Emit 100 bytes filled with value 45
def IDENTIFIER, 1 ; Define UART_PORT identifier as number 1
Number formats allowed are:
- decimal:
97
, - hexadecimal:
0x61
(however,61h
is currently unsupported), - octal:
0141
, - and character-based:
'a'
.
Strings are delimited by "
.
Save labels and their corresponding addresses to a file.
Import labels from a file.
Make the output verbose with level 1
or 2
.
Emit the resulting binary into a file.
Save the code as a tape image (TAP format, e.g. for use in ZX Spectrum emulators).
- Importing labels from multiple files