-

Changes

Jump to: navigation, search

Z80 Assembler Reference Manual

101 bytes added, 20:42, 30 July 2017
no edit summary
{|
|+!Character|| !! Radix|| !! Name|
|-
!|B|| 2|| binary|
|-
!|O|| 8|| octal|
|-
!|Q|| 8|| octal|
|-
!|o|| 8|| octal|
|-
!|q|| 8|| octal|
|-
!|H|| 16|| hexadecimal|
|-
!|h|| 16|| hexadecimal|
|}
{|
|+!Operator|| !! Meaning
|-
!|&|| Bitwise AND
|-
!|*|| Multiplication
|-
!|<nowiki>+</nowiki>|| Addition
|-
!|<nowiki>-</nowiki>|| Subtraction.and.|| Bitwise AND
|-
!|.eqand.|| Equality test Bitwise AND
|-
!|.gteq.|| Signed greater thanEquality test
|-
!|.highgt.|| Hi byte of operand Signed greater than
|-
!|.lowhigh.|| Low Hi byte of operand
|-
!|.ltlow.|| Signed less than Low byte of operand
|-
!|.modlt.|| Modulus Signed less than
|-
!|.notmod.|| Bitwise complementModulus
|-
!|.ornot.|| Bitwise orcomplement
|-
!|.shlor.|| Shift left Bitwise or
|-
!|.shrshl.|| Shift rightleft
|-
!|.ultshr.|| Unsigned less thanShift right
|-
!|.ugtult.|| Unsigned greater less than
|-
!|.xorugt.|| Exclusive orUnsigned greater than
|-
!/|.xor.| Divison| Exclusive or
|-
!<|/|| Signed less thanDivison
|-
!=|<|| EqualitySigned less than
|-
!>|=|| Signed greater thanEquality
|-
!|>|| Signed greater than|-|^|| Bitwise or
|}
psect text, global
alabel:
ld hl,astring call putit ld hl,anotherstring
psect data, global
astring:
defm 'A string of chars' defb 0 anotherstring: defm 'Another string' defb 0
psect text
putit:
ld a,(hl) or a ret z call outchar inc hl jr putit
==== DEFB, DB ====
:This pseudo-op should be followed by a comma-separatedlist of expressions, which will be assembled into sequential  byte locations. Each expression must have a value between-128 and 255 inclusive. DB can be used as a synonym forDEFB. Example:
DEFB 10, 20, 'a', 0FFH
==== DEFF ====
:This pseudo-op assembles floating point constants into32 bit HI-TECH C format floating point constants. For exam-pleexample:
pi: DEFF 3.14159
==== DEFW ====
:This operates in a similar fashion to DEFB, except thatit assembles expressions into words, without the value restriction. Example:
DEFW -1, 3664H, 'A', 3777Q
==== DEFS ====
:Defs reserves memory locations without initializingthem. Its operand is an absolute expression, representingthe number of bytes to be reserved. This expression isadded to the current location counter. Note however thatlocations reserved by DEFS may be initialized to zero by thelinker if the reserved locations are in the middle of theprogram. Example:
DEFS 20h ;reserve 32 bytes of memory
==== EQU ====
:Equ sets the value of a symbol on the left of EQU tothe expression on the right. It is illegal to set the valueof a symbol which is already defined. Example:
SIZE equ 46
==== DEFL ====
:This is identical to EQU except that it may redefineexisting symbols. Example:
==== DEFM ====
:Defm should be followed by a string of characters,enclosed in single quotes. The ASCII values of these char-acters characters are assembled into successive memory locations.Example:
DEFM 'A string of funny *@$ characters'
==== END ====
:The end of an assembly is signified by the end of thesource file, or the END pseudo-op. The END pseudo-op mayoptionally be followed by an expression which will definethe start address of the program. This is not actually use-ful useful for CP/M. Only one start address may be defined per pro-gramprogram, and the linker will complain if there are more. Exam-pleExample:
END somelabel
==== COND, IF, ELSE, ENDC ====
:Conditional assembly is introduced by the COND pseudo-op. The operand to COND must be an absolute expression. Ifits value is false (zero) the code following the COND up tothe corresponding ENDC pseudo-op will not be assembled.COND/ENDC pairs may be nested. IF may be used as a synonymfor COND. The ELSE pseudo operation may be included withina COND/ENDC block, for example:
IF CPM
==== ELSE ====
:See COND.
==== ENDC ====
:See COND. 
==== ENDM ====
:See MACRO.
==== PSECT ====
:This pseudo-op allows specification of relocatable pro-gram program sections. Its arguments are a psect name, optionallyfollowed by a list of psect flags. The psect name is a sym-bol symbol constructed according to the same rules as for labels,however a psect may have the same name as a label withoutconflict. Psect names are recognized only after a PSECTpseudo-op. The psect flags are as follows: ;ABS:Psect is absolute
:;GLOBALABS::Psect is globalabsolute
:;LOCALGLOBAL::Psect is not global
:;OVRLDLOCAL::Psect is to be overlapped by linkernot global
:;PUREOVRLD::Psect is to be read-onlyoverlapped by linker
:;PURE
::Psect is to be read-only
:If a psect is global, the linker will merge it with anyother global psects of the same name from other modules.Local psects will be treated as distinct from any otherpsect from another module. Psects are global by default.
:By default the linker concatenates code within a psectfrom various modules. If a psect is specified as OVRLD, thelinker will overlap each module's contribution to thatpsect. This is particularly useful when linking moduleswhich initialize e.g. interrupt vectors.
:The PURE flag instructs the linker that the psect is tobe made read-only at run time. The usefulness of this flagdepends on the ability of the linker to enforce the requirement. CP/M fails miserably in this regard.
:The ABS flag makes a psect absolute. The psect will beloaded at zero. This is useful for statically initializinginterrupt vectors and jump tables. Examples:
==== GLOBAL ====
:Global should be followed by one more symbols (commaseparated) which will be treated by the assembler as globalsymbols, either internal or external depending on whetherthey are defined within the current module or not. Example:
==== ORG ====
:An ORG pseudo-op sets the current psect to the default(absolute) psect, and the location counter to its operand,which must be an absolute expression. Example:
ORG 100H
==== MACRO ====
:This pseudo-op defines a macro. It should be eitherpreceded or followed by the macro name, then optionally fol-lowed followed by a comma-separated list of formal parameters. Thelines of code following the MACRO pseudo-op up to the nextENDM pseudo-op will be stored as the body of the macro. Themacro name may subsequently be used in the opcode part of anassembler statement, followed by actual parameters. The textof the body of the macro will be substituted at that point,with any use of the formal parameters substituted with the
corresponding actual parameter. For example:

Navigation menu