// –––––––––––––––––––––––––––––––––––––––––
H1 Command Line Options
p Note: command line options can also be set in line 1 of the source if it starts with '#!' (Shebang).
H5 Command line options
p When invoking zasm you can append options to it on the command line, most notably the name of the source file.
pre zasm [options] [-i] inputfile [[-l] listfile|dir] [[-o] outfile|dir]
p default output dir = source dir
default list dir = output dir
p.b Typical invocations
pre zasm -uwy emuf_rom.asm
h6 List of command line options as printed by zasm:
pre -u --opcodes include object code in list file
-w --labels append label listing to list file
-y --cycles include cpu clock cycles in list file
-b --bin write output to binary file (default)
-x --hex write output in intel hex format
-s --s19 write output in motorola s-record format
-z --clean clear intermediate files, e.g. compiled c files
-e --compare compare own output to existing output file
-T --test run self test (requires developer source tree)
-g --cgi prevent access to files outside the source dir
--maxerrors=NN set maximum for reported errors (default=30, max=999)
--date=DATETIME for reproducible __date__ and __time__ (default=now)
--target=ram default to 'ram' not 'rom' => cpu addresses in hex files
-o0 don't write output file
-l0 don't write list file
--z80 target Zilog Z80 (default except if --asm8080)
--z180 enable Z180 / HD64180 instructions
--8080 restrict to Intel 8080 (default if --asm8080)
--asm8080 use 8080 assembler syntax
--convert8080 convert source from 8080 to Z80 mnemonics
-v0 -v1 -v2 verbosity of messages to stderr (0=off, 1=default, 2=more)
--ixcbr2 | …xh enable ill. instructions like 'set b,(ix+d),r' or 'set b,xh'
--dotnames allow label names starting with a dot '.'
--reqcolon colon ':' after program label definitions required
=> label definitions and instructions may start in any column
--casefold label names are case insensitive (implied if --asm8080)
--flatops no operator precedence: evaluate strictly from left to right
-c path/to/cc set path to c compiler (default: sdcc in $PATH)
-t path/to/dir set path to temp dir for c compiler (default: output dir)
-I path/to/dir set path to c system header dir (default: sdcc default)
-L path/to/dir set path to standard library dir (default: none)
p Options can be packed, e.g. '-uwy' is the same as giving 3 separate options.
Also, due to the way zasm parses it's arguments, you can even include options which require an additional argument in this way:
pre $> zasm -cuwy /bin/sdcc emuf.asm
p Here the 'c' will eat the '/bin/sdcc'.
H5 -u --opcodes
p Request a list file which includes the generated bytes.
pre 0215: ;/pub/Develop/Projects/zasm-4.0/Test/main.c:11: int mult(int a, int b)
0215: ; ---------------------------------
0215: ; Function mult
0215: ; ---------------------------------
0215: _mult:
0215: DDE5 push ix
0217: DD210000 ld ix,#0
021B: DD39 add ix,sp
021D: ;/pub/Develop/Projects/zasm-4.0/Test/main.c:13: return a * b;
021D: DD6E06 ld l,6 (ix)
0220: DD6607 ld h,7 (ix)
0223: E5 push hl
0224: DD6E04 ld l,4 (ix)
0227: DD6605 ld h,5 (ix)
022A: E5 push hl
022B: CDA003 call __mulint
022E: F1 pop af
022F: F1 pop af
0230: DDE1 pop ix
0232: C9 ret
H5 -w --labels
p Request a labels summary at end of the list file. Also lists the defined code and data segments.
pre ; +++ segments +++
#CODE PROG_HEADER: start=0 len=17 flag=0
#CODE PROG_DATA: start=0 len=55 flag=255
...
#CODE _CABS: start=36246 len=0
#CODE _GSFINAL: start=36246 len=0
#CODE _INITIALIZER: start=36246 len=12
#DATA _DATA: start=23296 len=53
#DATA _INITIALIZED: start=23349 len=203
; +++ global symbols +++
CODE_DATA = $5DC0 = 24000 CODE_DATA test-tap.asm:107 (unused)
CODE_HEADER = $0000 = 0 CODE_HEADER test-tap.asm:95 (unused)
_CABS = $8D96 = 36246 _CABS test-tap.asm:120 (unused)
_CODE = $717E = 29054 _CODE test-tap.asm:119 (unused)
_DABS = $5C00 = 23552 _DABS test-tap.asm:137 (unused)
_DATA = $5B00 = 23296 _DATA test-tap.asm:135
_GSFINAL = $8D96 = 36246 _GSFINAL test-tap.asm:121 (unused)
...
H5 -y --cycles
p Requests to include accumulated cpu cycles in the list file.
p 'accumulated' means that zasm does not print the individual execution time for each instruction but sums it up for a thread of code. Program labels are supposed to be entry points from arbitrary positions in code and therefore the sum is reset at every program label. Instructions with varying execution time are given with their run-through time in first place and the branching or repeating time as a second value.
pre ; initialize initialized data:
5DC0: 010C00 [10] ld bc,_INITIALIZER_len ; length of segment _INITIALIZER
5DC3: 11355B [20] ld de,_INITIALIZED ; start of segment _INITIALIZED
5DC6: 21968D [30] ld hl,_INITIALIZER ; start of segment _INITIALIZER
5DC9: 78 [34] ld a,b
5DCA: B1 [38] or c
5DCB: 2802 [45|50] jr z,$+4
5DCD: EDB0 [61|21] ldir
H5 -b --bin
p Request to write the output file in binary format. This is the default.
H5 -x --hex
p Request to write the output file in Intel Hex format. This is only allowed for target ROM (the default) or target BIN.
pre :200000003E00ED79ED79ED793E40ED793EDAED793E37ED79ED780F30FB3A1027D370ED787B
:090020000F0F30FADB70321027DB
:00000001FF
H5 -s --s19
p Request to write the output file in Motorola S-Record format. This is only allowed for target ROM (the default) or target BIN.
p This format supports a header and zasm uses it to store the source file name and assembly date. Since it is encoded as hex data, it is not directly readable in the example below:
pre S00F00007320323031352D30312D313178
S12C00003E00ED79ED79ED793E40ED793EDAED793E37ED79ED780F30FB3A1027D370ED780F0F30FADB7032102772
S5030001FB
S9030000FC
H5 --target=ram
p [4.4.6] If you assemble an old source which uses no #target directive then the target is 'rom' by default. This makes a tiny difference for the fillbyte ($FF instead of $00) and a big difference if you write the output to a hex file which include addresses: target 'rom' stores addresses starting from $0000 for an eprom burner, while target 'ram' stores addresses as set in the #code directives or by the '.org' pseudo opcode suitable for a ram downloader. This command line option – in combination with -x or -s – allows to create hex files for downloading to ram without the use of the #target directive.
H5 -z --clean
p This requests zasm to erase all cached files from the c compiler. These files are stored in subdirectory 's/' in the selected temp directory, which is by default the source file's directory.
H5 -e --compare
p This allows to check whether the output for a certain source file has changed: The output file of the assembly is not written but compared to the already existing output file of an older assembly. The main purpose for this option is to support zasm's self test, but you may use it to check your source for code-effective modifications without the need to supply a different output file name and to run cmp against the two files.
pre $> zasm -e zx82.asm "ROMs/zx82 standard rom for ram/zxsp rom for ram.rom"
--> mismatch at $33FC: old=$AA, new=$00
--> mismatch at $33FD: old=$04, new=$00
assemble: 10665 lines
time: 0.1129 sec.
zasm: 2 errors
p In this example i have compiled the original source of the ZX Spectrum rom and compared it with a modified rom, where a routine which dumps unwanted data at address 0x0000 has been modified to dump it somewhere else, (when i look at the output this seems to be address 0x04AA) so that the rom file can be used in ram (if you have ram at address 0x0000).
p If the files match, then simply an ok message is printed and no files are written. If they don't match, then zasm stores a list file with generated opcodes so that you can immediately scrutinize the generated code at the losted addresses.
p An output file is actually written to the /tmp/ directory.
H5 -g --cgi
p Assemble potentially malicious sources, e.g. in a CGI script for a web site.
p This option prevents #insert and #include to include files or directories from outside the source file's directory. Additionally option -I is rejected in #cflags. Traversal via symlinks to any location are possible, also paths in the command line arguments are not affected. #cpath can only be used to select the compiler (without directory path) but only sdcc and vcc are recognized.
H5 --maxerrors
pre --maxerrors=NN
p Set the maximum amount of errors after which zasm will bail out. Default value is 30 errors. Some errors, especially after assembler directives starting with '#', are 'fatal' and will always immediately terminate assembly regardless of this setting.
H5 --date
pre --date=DATESTRING
p Set date and optionally time for the __date__ and __time__ macros. This can be used to create reproducible binaries, e.g. for test and verify. The date is also used in the S0 record of Motorola S19 hex files.
p Examples:
pre --date=20201231
--date=2020-04-12,12:00:00
--date='2020-4-12 12:00'
H5 -o0
p Use this if you don't want the output file to be created, e.g. if you just want to recreate the list file. This will save you some milli seconds…
H5 -l0
p Use this option if you don't want a list file to be created. Normally, if no list file specific option is given, a 'plain' list file is genertaed which is mostly the same as the source file, plus any included files, plus markers for any occured error.
H5 --z80
p Set the target cpu to Z80. This is the default, except if --asm8080 is used to assemble source using 8080 assembler syntax.
Alternative: Use the pseudo instruction '.z80' at the start of the source file.
p If target Z80 is set with --z80 or .z80 and not by default only, then the label _z80_ is defined and can be tested with 'defined(_z80_)' in expressions.
(changed in version 4.3.4)
H5 --z180
p Set the target cpu to Z180 / HD64180. This enables additional instructions and disables all illegal instructions, because the Z180 traps them.
Alternative: Use the pseudo instruction '.z180' at the start of the source file.
p If target Z180 is set with --z180 or .z180, then the label _z180_ is defined and can be tested with 'defined(_z180_)' in expressions.
H5 --8080
i8080
p Set the target cpu to the Intel 8080. This disables all additional Z80 instructions. The source must still be in Z80 syntax unless you also use --asm8080, in which case you don't need --8080 because it is implied. Use this option if you want to verify that your program will also run on the 8080 cpu, e.g. for CP/M.
p Note: The pseudo instruction '.8080' has an additional effect: '.8080' also selects 8080 assembler syntax!
p If target 8080 is set with --8080 or .8080, then the label _8080_ is defined and can be tested with 'defined(_8080_)' in expressions.
(changed in version 4.3.4)
H5 --asm8080
p Announce that this is an assembler source in the Intel 8080 assembler format with these 'weird mnemonics'. This option implies the option --casefold and set's the default cpu target to the Intel 8080.
p '--asm8080' can be used in combination with '--z80' to assemble source for a Z80 (including the Z80's additional opcodes) in 8080 assembler syntax. See section about 8080 assembler instructions.
Alternative: Use the pseudo instruction '.asm8080' at the start of the source file.
p Note: The pseudo instruction '.8080' has a similar effect but does not only select 8080 assembler syntax but also set's the target cpu to Intel 8080.
H5 --convert8080
p Since version 4.3.0: Convert 8080 assembler source file to Z80 style.
p zasm converts the source and writes it to the output file or a file with a derived name. Then it assembles the original source and the converted source and compares the outputs. The Z80 source is assembled with option '--casefold'. Flags required to assemble the 8080 source – e.g. '--reqcolon' – must also be used for the conversion. The source is converted independently of any successive errors.
H5 -v[0,1,2]
v0,v1,v2
p Set verbosity of messages to stderr. Default is -v1.
p By default some warnings, all errors and a '123 errors' / 'no errors' message are printed.
With -v2 some more warnings are printed.
With -v0 nothing is printed.
+ __ixcbr2.txt
+ __dotnames.txt
+ __reqcolon.txt
+ __casefold.txt
+ __flatops.txt
+ __test.txt
+ command line options for c compiler.txt