ZX-Assembler

Usage

  • Edit your Z80 assembler files
  • Open binary files and edit the recalculated assembler code
  • Run your files with your favourite emulator
     
  • Browse through labels:
    When you compile assembler code that has labels, ZX-Assembler builds up a label list. The label list can be toggled and shows all labes. Sort the list by addresses or names. Click on a label to jump to the source code line.
     
  • File Dropbox:
    Create binary files into the Dropbox or directly onto disk. The Dropbox can be used to test the file output of self-made code. Output commands with file names without paths will be stored in the File Dropbox automatically.

Working features

  • List of available and planned assembler instructions:
CommandSyno 1Syno 2ParametersDescription
#LENGTHFIELD[<value>]Same as LENGTH (within structures) or FIELD (outside structures)
##ALIGNMAPALIGN[<alignment>]Same as ALIGN (within structures) or MAPALIGN (outside structures).
@@<Z80 instruction>Ensures that the Z80 instruction is used, if a macro with same name exists.
<cnt><loop count> <commands>Repeats the following line of commands. Line repeater can be nested simply by attaching them next to each other. The loop counter can be evaluated with function % (first level), %% (second level), etc.
[<cnt>][<loop count>] <commands>Repeats the following line of commands. Line repeater can be nested simply by attaching them next to each other. The loop counter can be evaluated with function % (first level), %% (second level), etc
<macro name>[<parameter list>]Calls the macro <macro name> and may expect parameters to be attached. The code is inserted as it is, including labels. So, macros may contain code fragments, e.g. open loops etc. There may be different macros with same name, but in that case they must differ in count of parameters. Parameters can be single values or bracketed lists (e.g. (89,90)) and may be seen as only one parameter by the macro processor.
<structure name>[<parameter list>]Calls the structure <structure name>. If a label is placed before that call, there are sub-labels created for that label. In that case, the data that has been defined in the structure is generated. If <replace values> are used, the default values of the data definitions are replaced by those values in the same order as defined in the structure.
ABYTE<offset>, <byte or string sequence>Same as BYTE, but all bytes or strings are incremented by <offset>.
ABYTEC <offset>, <byte or string sequence> Same as BYTEC, but all bytes or strings are incremented by <offset>.
ABYTEZ <offset>, <byte or string sequence> Same as BYTEZ, but all bytes or strings are incremented by <offset>.
ALIGN<alignment> [, <fill byte>]Aligns the memory position to fit exactly to <alignment>. The skipped space can be filled with the optional <fill byte> instead of zero bytes.
ASSERT<condition> [, <alternative string>]If condition gives 0, an assertion message will be output. If an alternative text message is given, it is displayed instead of the default message.
ASSIGN<identifier> [,] <expression>Creates a definition <identifier> in the definition list with value <expression>.
BLOCKDSDEFS<count> [, <fill value>]Results a group of <count> bytes as a filler. Default for <fill value> is 0. Same as DS and DEFS.
BLOCKSTART<start address> Necessary for block editing; sets the start address of the destination data
block to the given address. Includes an ORG <start address>
BREAKBreaks a WHILE or REPEAT loop.
BYTEDB
DM
DEFB
DEFM
<byte or string sequence>Results a byte or group of bytes. Same as DB, DEFB, DM and DEFM.
BYTECDCDEFC <byte or string sequence> Results a byte or group of bytes, where each string (not single bytes) ends with a byte with bit 7 set. Same as DC and DEFC.
BYTEZDZDEFZ <byte or string sequence> Results a byte or group of bytes, where the whole sequence is followed by a zero byte. Same as DZ and DEFZ.
CODE[?] , [@ <address or address range> ] ,
[# <alignment> ] , [PAGE <page or page range>]
not yet implemented
CONTINUEContinues a WHILE or REPEAT loop and skips the following instructions until the ENDWHILE/ENDREPEAT.
DEFINE<identifier> [,] <replacement>Defines a definition in the definition list, which can have a replacement. If a replacement is given, the identifier is replaced by it. Also strings with an introducing @ (e.g. @”test”) will be replaced.
DEFPAGE<page or page range> [, <origin> [, <size> ] ]Not yet implemented
DEPHASEUNPHASEENT
ENDT
Restores the old address counter, remembered by PHASE. Same as UNPHASE, ENT and ENDT.
DISPLAY<strings and numbers>Adds an entry to the display output box. You may format the output of numbers with special switches outside strings: /A for both, decimal and hexadecimal, /D for decimal and /H for hexadecimal. Strings, numbers, expressions or the mentioned switches must be separated by comma.
DISPLAY CLEARClears the display output box
DWORDDDDEFD<dword or dword sequence>Results a dword or group of dwords (dword = 32 bit integer). Same as DD and DEFD.
ELSEBegins the ELSE block of an IF..ELSEIF..ELSE..ENDIF structure.
ELSEIF<condition> Same as ELSE and following IF.
ELSEIFB <macro parameter>Same as ELSE and following IFB.
ELSEIFDEF<identifier>Same as ELSE and following IFDEF.
ELSEIFDIF<macro parameter 1>,<macro parameter 2>Same as ELSE and following IFDIF.
ELSEIFDIFI<macro parameter 1>,<macro parameter 2>Same as ELSE and following IFDIFI.
ELSEIFEXISTS<file name> Same as ELSE and following IFEXISTS.
ELSEIFIDN<macro parameter 1>,<macro parameter 2>Same as ELSE and following IFIDN.
ELSEIFIDNI<macro parameter 1>,<macro parameter 2>Same as ELSE and following IFIDNI.
ELSEIFNB<macro parameter>Same as ELSE and following IFNB.
ELSEIFNDEF<identifier>Same as ELSE and following IFNDEF.
ELSEIFNEXISTS<file name>Same as ELSE and following IFNEXISTS.
ELSEIFNNUM<macro parameter>Same as ELSE and following IFNNUM.
ELSEIFNSTR<macro parameter>Same as ELSE and following IFNSTR.
ELSEIFNUM<macro parameter>Same as ELSE and following IFNUM.
ELSEIFSTR<macro parameter>Same as ELSE and following IFSTR.
ENDStops the assembling and ignores all following instructions.
ENDIFCloses an IF..ELSEIF..ELSE..ENDIF structure.
ENDMACROENDMCloses a macro definition. Same as ENDM.
ENDMAPCloses the current map counter and restores the previous one (if any).
ENDMODULEENDMOD[<module name>]When no module name is given, the current module is closed. When a module name is given, all last defined modules up to and including the given module name will be closed. Same as ENDMOD.
ENDREPEATEDUPENDRCloses a REPEAT loop. REPEAT loops can be nested, but not overlap. Same as EDUP and ENDR.
ENDSTRUCTENDSCloses a STRUCT structure macro definition. Same as ENDS.
ENDWHILEENDWCloses a WHILE loop. WHILE loops can be nested, but not overlap. Same as ENDW.
EQU=<address>Sets the preceding label to the value. Same as =
EXECUTE<file name>Executes the file on disk.
EXPORT<label>Not yet implemented
FIELD#[<increment>]Sets a label to the value of the current map counter and increments the map counter by <increment>. Same as # (outside of structures).
FLOATDFDEFF<float or float sequence>Results a float or group of floats (float = 5 byte ZX-Spectrum format). Same as DF and DEFF.
FPOS<position>Sets the file pointer of the current output file to the value.
IF<condition>Starts an IF structure, that may consist of IF..ELSEIF..ELSE..ENDIF. If <condition> is zero, the next ELSE or ELSEIF is executed.
IFB<macro parameter>Same as IF, but results true, if the macro parameter is empty.
IFDEF<identifier>Same as IF, but results true, if the <identifier> has been defined with DEFINE.
IDEFINE<identifier> [,] <replacement>Same as DEFINE, but case-insensitive version.
IFDIF<macro parameter 1>,<macro parameter 2>Same as IF, but results true, if both macro parameters are not identical (case-sensitive).
IFDIFI<macro parameter 1>,<macro parameter 2>Same as IF, but results true, if both macro parameters are not identical (case-insensitive).
IFEXISTS<file name>Same as IF, but results true, if file exists on disk or in the file dropbox.
IFIDN <macro parameter 1>,<macro parameter 2>Same as IF, but results true, if both macro parameters are identical (case-sensitive).
IFIDNI<macro parameter 1>,<macro parameter 2>Same as IF, but results true, if both macro parameters are identical (case-insensitive).
IFNB<macro parameter>Same as IF, but results true, if the macro parameter is not empty.
IFNDEF<identifier>Same as IF, but results true, if the <identifier> has not been defined with DEFINE.
IFNEXISTS<file name>Same as IF, but results true, if file does not exists on disk nor in the file dropbox.
IFNNUM<macro parameter>Same as IF, but results true, if the macro parameter is not numeric.
IFNSTR<macro parameter>Same as IF, but results true, if the macro parameter is not a string.
IFNUM<macro parameter>Same as IF, but results true, if the macro parameter is numeric.
IFSTR<macro parameter>Same as IF, but results true, if the macro parameter is a string.
INCBINBINARYINSERT<file name> [, <offset>] [, <length>]Includes the content of a binary file from <offset> with <length> bytes. <offset> and <length> are optional. File must be on disk or in the file dropbox. Same as BINARY and INSERT.
INCHOB<file name> [, <offset>] [, <length>]Includes the content of a hobeta disk file from <offset> with <length> bytes. <offset> and <length> are optional. File must be on disk or in the file dropbox.
INCLUDE<file name>Includes the assembler code of the given file. ZX-Assembler reads it before the assembler starts its code iteration. So, including a file is exactly the same as if the content would be entered directly.
INCTRD<TRD file name> , <inner file name>
[, <offset>] [, <length>]
Includes the content of an <inner file name> inside a <TRD file> from <offset> with <length> bytes. <offset> and <length> are optional. The TRD file must be on disk or in the file dropbox.
LENGTH#<length>Used only within STRUCT definitions and outputs <length> zero bytes. Same as #.
MACRO<name> [<parameter>
[= <default>]]
[<parameter count>] [<parameter range>]
Defines a macro that can later be called simply by using its name. Optional parameters can be named identifiers and followed by optional numbered parameters. Named parameters can be used directly with their names, while numbered parameters can be accessed with @<number> function.
MAP<value>Creates a new map. Use FIELD to set labels to current map counter. Use ENDMAP to close the current and restores the previous one.
MAPALIGN##[<alignment>]Aligns the map position to <alignment>. Default value is 4.
MODULE<module name>Defines a new module that bases on previous modules. Labels are local to the current module.
ORG<address>Sets the address counter to a new value.
OUTPUT<file name> [, <mode>]Loads the content of the file, if it exists on disk or in the file dropbox. If the file is not present, it will be created. You may use mode T (= default) to clear the file, R to rewind to position 0, or A to append code to the end of the file.
PAGE<page or page range>Not yet implemented
PHASEDISPTEXTAREA<address>Remembers the current address and sets origin address <address>. Same as TEXTAREA and DISP.
REPEATDUPREPT<loop count>Together with ENDREPEAT starts a REPEAT loop. REPEAT loops can be nested, but not overlap. Same as DUP and REPT. The loop counter can be evaluated with function @# (first level), @@# (second level), etc.
ROTATE<value>Rotates the numerated parameters of the current macro to left, if value is >0, or to right, if value is <0. The rotation of parameters is circular.
SIZE<minimum file size>Ensures the current output file has the <minimum file size>. It does not change the FPOS file position.
STRUCT<name> [,<initial offset> [,<alignment>]]Defines a data structure. Creates a label <name> containing length of structure, as well as sub-labels containing the offsets of defined fields. A structure can be used with a preceding label, which defines corresponding sub-labels and sets the fields to the defined values or default values. A structure call without a preceding label just creates the data. Only define commands, ALIGN (##) and LENGTH (#) are allowed within structures.
TRIPLEDT
D24
DEFT
DEF24
<triple or triple sequence>Results a triple or group of triples (triple = 24 bit integer). Same as DT, D24, DEF24 and DEFT.
UNDEFINE<identifier> | *If <identifier> is given, it”s erased from the definition list. If * is used, all definitions are cleared. Even the pre-defined ones.
VAR=<address>Sets the preceding label to the value. Same as :=
WHILE<condition>Together with ENDWHILE starts a WHILE loop. WHILE loops can be nested, but not overlap. The loop counter can be evaluated with function @# (first level), @@# (second level), etc.
WORDDWDEFW<word or word sequence> Results a word or group of words (word = 16 bit integer). Same as DW and DEFW.
XDEFINE<identifier> [,] <replacement>Same as DEFINE, but the replacement already is expanded at definition.
XIDEFINE<identifier> [,] <replacement>Same as XDEFINE, but case in-sensitive version.
ZXBASIC<string>Converts all spelt-out tokens in the string to one-byte ZX-Spectrum 48k tokens.
  • List of available expressions and functions:
SymbolUsageResultDescription
– <number>int/floatgives the negative value of <number>
<num1> – <num2>int/floatgives the difference of <num1> minus <num2>
!<number> !floatgives the faculty of <number>. = FACT <number>
!! <number>integerlogical NOT. Gives -1 if <num> is 0, otherwise 0
!=<num1> != <num2>integergives -1 if <num1> is unequal to <num2>, otherwise 0
$$integergives the current address value
%<num1> % <num2>integergives the modulo of <num1> / <num2>
%%integergives the current loop counter of the line repeater.
Use % to get the counter of the rightmost line repeater,
%% for the second level, %%% for the third, and so on.
&<num1> & <num2>integerbinary AND. Gives the result of binary AND operation
of both numbers.
&&<num1> && <num2>integerlogical AND. Gives -1 if <num1> and <num2> are
both <>0, otherwise 0.
*<num1> * <num2>int/floatgives the product of <num1> times <num2>.
**<num1> ** <num2>int/floatgives the power of <num2> to base <num1>.
/<num1> / <num2>floatgives the quotient of <num1> through <num2>
?? (<cond>, <num1> [, <num2>])int/float/
string
Gives <num1>, if condition <cond> is true,
otherwise <num2>. If <num2> is not given,
the result is 0, if <cond> is not true.
@@<number>int/float/
string
Used within macro definitions. If <number>
is 0, the result is the count of numbered
parameters. In case of 1..n it results the value
of the numbered parameter.
@@<string>stringincludes the result of the string to the
definition replacement procedure
@#@#integerGives the current loop counter of repeat or
while loop. @# gives the counter of the topmost
loop level, @@# the second level, @@@# the
third, and so on.
^<num1> ^<num2>integerbinary XOR. gives the result of binary XOR
operation of both numbers.
|<num1> | <num2>integerbinary OR. Gives the result of binary OR
operation of both numbers.
||<num1> || <num2>integerlogical OR. Gives -1 if <num1> or <num2>
is <>0, otherwise 0.
~~ <number>integerbinary NOT. Reverses all bits of <number>.
++ <number>int/floatgives <number> (does nothing)
+<num1> + <num2>int/floatgives the sum of <num1> plus <num2>
<<num1> < <num2>integergives -1 if <num1> is less than <num2>,
otherwise 0.
<?<num1> <? <num2>int/floatgives the lowest of both numbers
<<<num> << <count>integergives <num> bitwise shifted to left
<=<num1> <= <num2>integergives -1 if <num1> is less than or equal to
<num2>, otherwise 0
<><num1> <> <num2> integergives -1 if <num1> is unequal to <num2>,
otherwise 0
=<num1> = <num2> integergives -1 if <num1> is equal to <num2>,
otherwise 0
==<num1> == <num2> integergives -1 if <num1> is equal to <num2>,
otherwise 0
=><num1> => <num2> int/floatgives the result of <num1> * 256 + <num2>
><num1> > <num2> integergives -1 if <num1> is greater than <num2>,
otherwise 0
>?<num1> >? <num2>int/floatgives the highest value of both numbers
>=<num1> >= <num2>integergives -1 if <num1> is greater than or equal to
<num2>, otherwise 0
>><num> >> <count>integergives <num> bitwise shifted to right
°<degrees> °floatgives the radiant value of <degrees>. Is equal to
<degrees> * PI / 180
²<number> ²floatgives the square of <number>. Inverse function
of SQR. Same as SQU.
³<number> ³floatgives the cubic value of <number>. Inverse function
of CUR. Same as CUB.
ABSABS <number>int/floatgives the unsigned value of <number>
ACSACS <number>floatgives the arcus cosine of <number>. Inverse function
of COS.
AND<num1> AND <num2>integerbinary AND. Gives the result of binary AND operation of
both numbers.
ASCASC <string>integergives the ANSI code of character in string. Inverse function
of CHR.
ASNASN <number>floatgives the arcus sine of <number>. Inverse function of SIN.
ATNATN <number>floatgives the arcus tangens of <number>. Inverse function of
TAN.
AVGAVG (<list of numbers>)int/floatgives the average value of the numbers. Numbers must be
separated by comma.
BINBIN <number>stringgives the binary result of <number> as string.
BITBIT (<num>,<start> [, <stop>])integergives the bit or bit range of <num>.
CASECASE (<index>,<list of
numbers and strings>)
int/float/
string
gives the item of the list with index <index>. The first
index is 1.
CEILCEIL <number>integergives the unrounded integer value of <number>,
incremented by 1 if fraction value is >0.
CHRCHR <number>stringgives the ANSI character of <number>. Inverse function
of ASC.
COSCOS <number>floatgives the cosine of <number> in the range
CUBCUB <number>floatgives the cubic value of <number>. Inverse function of CUR.
CURCUR <number>floatgives the cubic root of <number>. Inverse function of
CUB.
DIV<num1> DIV <num2>integergives the integer quotient (always rounded down) of
<num1> / <num2>.
EXPEXP <number>floatgives the exponent of <number> to base e.
FACTFACT <number>floatgives the faculty of <number>. Same as <number> !
FBYTEFBYTE <address>integergives a byte from the current OUTPUT file.
FLOORFLOOR <number>integergives the unrounded integer value of <number>,
decremented by 1 if fraction value is <0.
FNAMEFNAMEstringgives the file name path of the current OUTPUT file.
FPOSFPOSintegergives the current output file position. Starts at 0.
FRACFRAC <number>floatgives the fraction value of <number>.
FSIZEFSIZEintegergives the length of the current OUTPUT file.
FWORDFWORD <address>integergives a 16-bit-word from the current OUTPUT file.
HEXHEX <number>stringgives the hexadecimal result of <number> as string.
HIGHHIGH <number>integergives the high byte of 16-bit value <number>.
IFIF (<cond>,<num1>
[, <num2>])
int/float/
string
gives <num1> if condition <cond> is true, otherwise
<num2>. If <num2> is not given, the result is 0, if <cond>
is not true.
INTINT <number>integergives the unrounded integer value of <number> without
fraction.
INTVINTV (<num>,<min>,<max>)int/floatgives the number <num>, which is set to <min> if less,
or set to <max> if greater. Ensures <num> not to leave
the limits.
LEFTLEFT (<string>,<count>)stringgives the left string part with <count> characters.
LENLEN <string>integergives the length of <string> in characters.
LNLN <number>floatgives the logarithmis naturalis of <number> to base e.
Inverse function of EXP.
LOGLOG <number>floatgives the logarithmis of <number> to base 10. Inverse
function of TEN.
LOWLOW <number>integergives the low byte of 16-bit-value <number>.
MAXMAX (<list of numbers>)int/floatgives the highest number of the list. Numbers must be
separated by comma.
MIDMID (<string>,<pos>
[, <count>])
stringgives a part string of <string>, starting at position <pos>
and <count> characters. <count> is 1 if not given.
MINMIN (<list of numbers>)int/floatgives the lowest number of the list. Numbers must be separated by comma.
MOD<num1> MOD <num2>integergives the modulo of <num1> / <num2>
NEGNEG <number>int/floatgives the negative value of <number>
NOTNOT <num>integerlogigal NOT. Gives -1 if <num> is 0, otherwise 0.
OR<num1> OR <num2>integerbinary OR. Gives the result of binary OR operation of both numbers.
PIPIfloatthe constant ratio of the diameter and circumference of a circle: 3.1415926…
RADRAD <degrees>floatgives the radiant value of <degrees>. = <degrees> * PI / 180.
RCPRCP <number>float gives the reciprocal value of <number> or 1 / <number>.
RIGHTRIGHT (<string>,<count>)stringgives the right string part with <count> characters.
RNDRNDfloatgives a random number in the range 0 <= RND < 1.
SGNSGN <number>integergives the sign of <number>, means -1 for negative, 1 for positive values or 0 for zero.
SHL<num> SHL <count>integergives <num> bitwise shifted to left.
SHR<num> SHR <count>integergives <num> bitwise shifted to right.
SINSIN <number>floatgives the sine of <number> in the range -1 .. 1. Inverse function of ASN.
SQRSQR <number>floatgives the square root of <number>. Inverse function of SQU.
SQUSQU <number>floatgives the square of <number>. Inverse function of SQR.
STRSTR <number>stringgives the string result of <number>.
STRSTR (<num>,<fraction digits> [ ,<total digits>])stringgives the string result with the given fraction digits, expanded to the total digits, if room available.
SUMSUM (<list of numbers>)int/floatgives the sum of the numbers. Numbers must be separated by comma.
TANTAN <number>floatgives the tangens of <number>. Inverse function of ATN.
TENTEN <number>floatgives the tenth power of <number>. Inverse function of LOG.
UNBINUNBIN <string>integergives the numeric result of binary number in <string>
UNHEXUNHEX <string>integergives the numeric result of hexadecimal number in <string>.
VALVAL <string>int/floatcalculates the numeric result in <string>. May contain another formula.
XOR<num1> XOR <num2>integerbinary XOR. Gives the result of binary XOR operation of both numbers.
_VERSION_VERSIONstringgives the current version of ZX-Assembler as string.
_APPPATH_APPPATHstringgives the path of the associated application.
_APPFILE_APPFILEstringgives the file name of the associated application.
_TMPPATH_TMPPATHstringgives the system temporary file folder.
_ZXAPATH_ZXAPATHstringgives the current execution path of ZX-Assembler.

List of changes:

Date:Description of changes:
Nov. 2012Creating a new application
May 2013Completing a way of editing the assembler code within a string grid. I added some
features for inserting and deleting lines.
2014 – 2015Implementing the full or nearly full command set of SJasm and SJasmPlus.
Implementing file drop box which can be used for all commands that perform file accessing, if no path is given.
May 2015Implementing column toggle window, BLOCKSTART instruction, that is necessary for data block editing, functions to insert ASM files or binary data at cursor position, optimized function for editing bytes
June 2015New program version 0.8 published. Final state for now!

Downloading ZX-Assembler for Windows:

Necessary files description:Files:Version state:Download here:

ZX-Assembler 0.8
ZX-Assembler.exe
ZX-Assembler.chm
Common changes ZX-Modules.chm
datablocks.chm
snapshot48.sna
ZX-Spectrum ROM labels.asm
ztvCabinet.dll
ztvUnrar39.dll
ztvUnace26.dll
July 14th, 2015ZX-Assembler_0.8_Setup.zip