Digital Research Assembler User Manual
Below you will find brief information for ASM. ASM is an assembler software translates assembly language source files into machine code. Key capabilities include program formatting, operand handling, directive usage for program organization, and error message reporting.
Advertisement
Advertisement
Le.
= Wo T
ti ) Is era.)
nis
4
{
¡pu
aa
VA mas e wm
- - £5
ma Sr не ара
т и -
Copyright (c) 1976, 1978 by Digital Research. All rights
reserved. No part of this publication may be reproduced,
transmitted, transcribed, stored in a retrieval system, or
translated into any language or computer language, in any
form or by any means, electronic, mechanieal, magnetic,
optical, chemical, manual or otherwise, without the prior
written permission of Digital Research, Post Office Box 579,
Pacific Grove, California 93950.
— Disclaimer
Digital Research makes no representations or warranties with
respect to the contents hereof and specifically disclaims any
implied warranties of merchantability or fitness for any
particular purpose. Further, Digital Research reserves the
right to revise this publication and to make changes from
time to time in the content hereof without obligation of
Digital Research to notify any person of such revision or
changes.
DIGITAL ACocARCA
Post Office Box 579, Pacific Grove, California 93950, (408) 649-3896
CP/M ASSEMBLER (ASM)
USERS GUIDE
COPYRIGHT (c) 1976, 1978
DIGITAL RESEARCH
Copyright (c) 1976, 1978 by Digital Research. All rights reserved.
No part of this publication may be reproduced, transmitted, transcribed,
stored in a retrieval system, or translated into any language or computer
language, in any form or by any means, electronic, mechanical, magnet-
ic optical, chemical, manual or otherwise, without the prior written
permission of Digital Research, Post Office Box 579, Pacific Grove,
California 93950.
Disclaimer
Digital Research makes no representations or warranties with respect to
the contents hereof and specifically disclaims any implied warranties of
merchantability or fitness for any particular purpose. Further, Digital
Research reserves the right to revise this publication and to make
changes from time to time in the content hereof without obligation of
Digital Research to notify any person of such revision or changes.
Table of Contents
Section
1.
2.
3e
4.
Se
7.
INTRODUCTION >: COCxoGCCECOCRNCCQCQCCE = NN QECOCAQQRQCQCQN=OC—NOCONOONOOOOO
PROGRAM FORMAT 00000800 090000500058050502009000000020009000250008
FORMING THE CPERAND 006600600000 06060000000060066000G6GGS
3.1. Labels еее вова
3.2. Numeric Constants еее ово вов фе
3.3. Reserved Words SOO SOP DODDOOOOISOSIOIOSOOSOISLISBOSIOSTBTOEOSTOSOPRES
3.4. String Constants еее ово
3.5. Arithmetic and Logical Operators ...sscccooceo
3.6. Precedence Of Operators ...sesccoocanccncacece
ASSEMBLER DIRECTIVES 9000050000000000000000000050200 5008
4,1. The ORG Directive еее RQONCOOCACLTECOC OOCNGODAN
4,2. The END Directive 0000608015 60000600606000000000600666G66
4,3. The EQU Directive еее ве
4.4. The SET Directive 0600406004608660606000006080600006060006
4.5. The IF and ENDIF Directives еее в
4.6. The DB Directive еее ово вое
4.7. The DW Directive сетевое ово ево
ОРЕВАТТОМ CODES COLT COOCCCOCCLCOC осо ев овес
Sel. Jumps, Calls, and Returns еее ев
Dele Immediate Operand Instructions LA KE
5,3. Increment and Decrement Instructions 0.0.0000
5.4. Data Movement Instructions 0000000000000000000
5e5. Arithmetic Logic Unit Operations ..e«sscovccooo
5.0. Control Instructions [BE EN NX BN NN NN NNENNENDNZ-NNMNNMNHMNHMNHMNHMNN
ERROR MESSAGES зе еее
А SAMPLE SESSION 009090000050000000008080000%292050000000909098508
3
put
SO YO 0-1 AO UT Ie Se Le NA
= fe
jos x
12
12
13
14
14
14
15
16
16
17
CP/M Assembler User 's Guide
1. INTRODUCTION.
The CP/M assembler reads assembly language source files fram the diskette,
and produces 8680 machine language in Intel hex format. The CP/M assembler 1s
initiated by typing
ASM filename
or
AM filename.parms
In both cases, the assembler assumes there is a file on the diskette with the
name
fil ename .ASM
which contains an 8080 assembly language source file. The first and second
forms shown above differ only in that the second form allows parameters to be
passed to the assembler to control source file access and hex and print file
destinations.
In either case, the CP/M assembler loads, and prints the message
CP/M ASSEMBLER VER n.n
where n.n is the current version number, In the case of the first command,
the assembler reads the source file with assumed file type "ASM" and creates
two output files
filename .HEX
and
filename . PRN
the "HEX" file contains the machine code corresponding to the original program
in Intel hex format, and the "PRN" file contains an annotated listing showing
generated machine code, error flags, and source lines. If errors occur during
translation, they will be listed in the PRN file as well as at the console
The second cammand form can be used to redirect input and output files
from their defaults. In this case, the “parms" portion of the command is a
three letter group which specifies the origin of the source file, the
destination of the hex file, and the destination of the print file. The fom
is
filename .plp2p3
where pl, p2, and p3 are single letters
pl: A,B, ..., ¥Y designates the disk name which contains
the source file
p2: A,B, ..., Y designates the disk name which will re-
celve the hex file
Z skips the generation of the hex file
p3: A,B, «es, Y designates the disk name which will re-
ceive the print file
places the listing at the console
skips generation of the print file
EN <
Thus, the command
ASM X.AAA
indicates that the source file (X.ASM) is to be taken from disk A, and that
the hex (X.HEX) and print (X.PRN) files are to be created also on disk A.
This form of the command is implied if the assembler is run from disk A. That
is, given that the operator is currently addressing disk A, the above command
1s equivalent to
AM X
The command
AM X.ABX
indicates that the source file is to be taken from disk A, the hex file is
placed on disk B, and the listing file is to be sent to the console. The
command
ASM X.BZZ
takes the source file from disk B, and skips the generation of the hex and
print files (this command is useful for fast execution of the assembler to
check program syntax).
The source program format is compatible with both the Intel 8080 assembler
(macros are not currently implemented in the CP/M assembler, however), as well
as the Processor Technology Software Package #1 assembler. That is, the CP/M
assembler accepts source programs written in either format. There are certain
extensions in the CP/M assembler which make it somewhat easier to use. These
extensions are described below.
2. PROGRAM FORMAT,
An assembly language program acceptable as input to the assembler consists
of a sequence of statements of the form
lines label operation operand rcomment
where any or all of the fields may be present in a particular instance. Each
~embly language statement is terminated with a carriage return and line feed
(the line feed is inserted automatically by the ED program), or with the
character "!" which is a treated as an end-of-line by the assembler (thus,
multiple assembly language statements can be written on the same physical line
if separated by exclaim symbols).
The linet is an optional decimal integer value representing the source
program line number, which is allowed on any source line to maintain
compatibility with the Processor Technology format. In general, these line
numbers will be inserted if a line-oriented editor is used to construct the
original program, and thus ASM ignores this field if present.
The label field takes the form
identifier
or
identifier:
and is optional, except where noted in particular statement types. The
identifier is a sequence of alphanumeric characters (alphabetics and numbers),
where the first character is alphabetic. Identifiers can be freely used by
the programmer to label elements such as program steps and assembler
directives, but cannot exceed 16 characters in length, All characters are
significant in an identifier, except for the embedded dollar symbol ($) which
can be used to improve readability of the name. Further, all lower case
alphabetics become are treated as if they were upper case. Note that the ":"
following the identifier in a label is optional (to maintain compatibility
between Intel and Processor Technology). Thus, the following are all valid
instances of labels
X ху long S$name
X: yxl: longer $Snamed$data :
x1Y2 xix2 х234$5678$9012$3456:
The operation field contains either an assembler directive, or pseudo
operation, or an 8080 machine operation code. The pseudo operations and
machine operation codes are described below.
The operand field of the statement, in general, contains an expression
formed out of constants and labels, along with arithmetic and logical
operations on these elements. Again, the complete details of properly formed
expressions are given below.
The camment field contains arbitrary characters following the ";" symbol
until the next real or logical end-of-line. These characters are read,
listed, and otherwise ignored by the assembler, In order to maintain
compatability with the Processor Technology assembler, the CP/M assembler also
treat statements which begin with a "*" in column one as comment statements,
which are listed and ignored in the assembly process, Note that the Processor
Technology assembler has the side effect in its operation of ignoring the
characters after the operand field has been scanned. This causes an ambiguous
situation when attempting to be compatible with Intel’s language, since
arbitrary expressions are allowed in this case. Hence, programs which use
this side effect to introduce comments, must be edited to place a ";" before
these fields in order to assemble correctly.
The assembly language program is formulated as a sequence of statements of
the above form, terminated optionally by an END statement. All statements
following the END are ignored by the assembler.
3. FORMING THE OPERAND,
In order to completely describe the operation codes and pseudo operations,
ft is necessary to first present the form of the operand field, since it is
used in nearly all statements, Expressions in the operand field consist of
simple operands (labels, constants, and reserved words), combined in properly
formed subexpressions by arithmetic and logical operators. The expression
computation is carried out by the assembler as the assembly proceeds. Each
expression must produce a 16-bit value during the assembly. Further, the
number of significant digits in the result must not exceed the intended use.
That is, if an expression is to be used in a byte move immediate instruction,
then the most significant 8 bits of the expression must be zero. The
restrictions on the expression significance is given with the individual
instructions,
3.1. Labels.
As discussed above, a label is an identifier which occurs on a particular
statement. In general, the label is given a value determined by the type of
statement which it precedes. If the label occurs on a statement which
generates machine code or reserves memory space (e.g, a MOV instruction, or a
DS pseudo operation), then the label is given the value of the program address
which it labels. If the label precedes an EQU or SET, then the label is given
the value which results from evaluating the operand field. Except for the SET
statement, an identifier can label only one statement,
When a label appears in the operand field, its value is substituted by the
assembler. This value can then be combined with other operands and operators
to form the operand field for a particular instruction.
3.2. Numeric Constants.
A numeric constant is a 16-bit value in one of several bases. The base,
called the radix of the constant, is denoted by a trailing radix indicator.
The radix indicators are
B binary constant (base 2)
O octal constant (base 8)
Q octal constant (base 8)
D decimal constant (base 10)
H hexadecimal constant (base 16)
О is an alternate radix indicator for octal numbers since the letter O is
easily confused with the digit 0. Any numeric constant which does not
terminate with a radix indicator is assumed to be a decimal constant.
A constant is thus composed as a sequence of digits, followed by an
optional radix indicator, where the digits are in the appropriate range for
the radix. That is binary constants must be composed of @ and 1 digits, octal
constants can contain digits in the range 0 - 7, while decimal constants
contain decimal digits. Hexadecimal constants contain decimal digits as well
as hexadecimal digits A (10D), B (11D), C (12D), D (13D), E (14D), and F
(15D). Note that the leading digit of a hexadecimal constant must be a
decimal digit in order to avoid confusing a hexadecimal constant with an
identifier (a leading 9 will always suffice). A constant composed in this
manner must evaluate to a binary number which can be contained within a 16-bit
counter, otherwise it is truncated on the right by the assembler. Similar to
identifiers, imbedded "$" are allowed within constants to improve their
readability. Finally, the radix indicator is translated to upper case if a
lower case letter is encountered. The following are all valid instances of
numeric constants
1234 1234D 1100B 1111$0000$1111$0000B
1234H OFFEH 33770 3358775220
33770 Bfe3h 1234d Offffh
3.3. Reserved Words.
There are several reserved character sequences which have predefined
meanings in the operand field of a statement. The names of 8080 registers are
given below, which, when encountered, produce the value shown to the right
ON SN AU WN © —]
VSErEMUAW Y
=
(again, lower case names have the same values as their upper case
equivalents), Machine instructions can also be used in the operand field, and
evaluate to their internal codes. In the case of instructions which require
operands, where the specific operand becomes a part of the binary bit pattern
oF the instruction (e.g, MOV A,B), the value of the instruction (in this case
MOV) is the bit pattern of the instruction with zeroes in the optional fields
(e.g, MOV produces 40H).
When the symbol "$" occurs in the operand field (not imbedded within
identifiers and numeric constants) its value becomes the address of the next
instruction to generate, not including the instruction contained withing the
current logical line.
3.4. String Constants.
String constants represent sequences of ASCII characters, and are
represented by enclosing the characters within apostrophe symbols (7). All
strings must be fully contained within the current physical line (thus
allowing "!" symols within strings), and must not exceed 64 characters in
length. The apostrophe character itself can be included within a string by
representing it as a double apostrophe (the two keystrokes °°), which becomes
a single apostrophe when read by the assembler. In most cases, the string
length is restricted to either one or two characters (the DB pseudo operation
is an exception), in which case the string becomes an 8 or 16 bit value,
respectively. Two character strings become a 16-bit constant, with the second
character as the low order byte, and the first character as the high order
byte.
The value of a character is its corresponding ASCII code, There is no
case translation within strings, and thus both upper and lower case characters
can be represented, Note however, that only graphic (printing) ASCII
characters are allowed within strings, Valid strings are
” ”
A AB
‘Walla Walla Wash.’
“She said ” Hello” ” to me.
“I said "Hello" to her.”
” ”
3.5. Arithmetic and Logical Operators.
~ The operands described above can be combined in normal algebraic notation
using any combination of properly formed operands, operators, and
parenthesized expressions. The operators recognized in the operand field are
a+b unsigned arithmetic sum of a and b
a-b unsigned arithmetic difference between a and b
+b unary plus (produces b)
- b unary minus (identical to @ - b)
a*b unsigned magnitude multiplication of a and b
a/b unsigned magnitude division of a by b
a MODb remainder after a / b
NOT b logical inverse of b (all 8's become 1's, 1's
become 0's), where b is considered a 16-bit value
a AND b bit-by-bit logical and of a and b
a OR b bit-by-bit logical or of a and b
a XORb —bit-by-bit logicl exclusive or of a and b
a SHL b the value which results from shifting a to the
left by an amount b, with zero fill
a SHR b the value which results from shifting a to the
right by an amount b, with zero fill
In each case, a and b represent simple operands (labels, numeric
constants, reserved words, and one or two character strings), or fully
enclosed parenthesized subexpressions such as
10+20 10h+370 L] /3 (L2+4) SHR 3
(a” and 5fh) + 6 (B'+B) OR (PSW+M)
(1+(2+c)) shr (A-(B+1))
Note that all computations are performed at assembly time as 16-bit unsigned
operations. Thus, -1 is computed as @-1 which results in the value Offffh
(i.e., all ls). The resulting expression must fit the operation code in
which it is used. If, for example, the expression 1s used in a ADI (add
immediate) instruction, then the high order eight bits of the expression must
be zero. As a result, the operation "ADI -1" produces an error message (-l
becomes Gffffh which cannot be represented as an 8 bit value), while "ADI (-1)
AND @FFH" 1s accepted by the assembler since the "AND" operation zeroes the
high order bits of the expression.
3.6. Precedence of Operators.
As a convenience to the programmer, ASM assumes that operators have a
relative precedence of application which allows the programmer to write
expressions without nested levels of parentheses. The resulting expression
has assumed parentheses which are defined by the relative precedence. The
order of application of operators in unparenthesize expressions is listed
below. Operators listed first have highest precedence (they are applied first
in an unparenthesized expression), while operators listed last have lowest
precedence, Operators listed on the same line have equal precedence, and are
applied from left to right as they are encountered in an expression
* / MOD SHL SHR
- +
NOT
AND
OR XOR
Thus, the expressions shown to the left below are interpreted by the assembler
as the fully parenthesize expressions shown to the right below
a*b+c (a * b) +c
a+b*c a + (b * c)
a MOD b * c SHL d ((a MOD b) * c) SHL d
a OR b AND NOT c + d SHL e a OR (b AND (NOT (с + (d SHL e))))
Balanced parenthesized subexpressions can always be used to override the
assumed parentheses, and thus the last expression above could be rewritten to
force application of operators in a different order as
(a OR b) AND (NOT c) + d SHL e
resulting in the assumed parentheses
(a OR b) AND ( (NOT c) + (d SHL e))
Note that an unparenthesized expression is well-formed only if the expression
which results from inserting the assumed parentheses is well-formed,
4, ASSEMBLER DIRECTIVES,
Assembler directives are used to set labels to specific values during the
assmbly, perform conditional assembly, define storage areas, and specify
starting addresses in the program. Each assembler directive is denoted by a
"pseudo operation" which appears in the operation field of the line, The
acceptable pseudo operations are
ORG set the program or data origin
END end program, optional start address
EQU numeric "equate"
SET numeric "set"
IF begin conditional assembly
ENDIF end of conditional assembly
DB define data bytes
DW define data words
DS define data storage area
The individual pseudo operations are detailed below
4.1. The ORG directive.
The ORG statement takes the form
label ORG expression
where "label" is an optional program label, and expression is a 16-bit
expression, consisting of operands which are defined previous to the ORG
statement. The assembler begins machine code generation at the location
specified in the expression. There can be any number of ORG statements within
a particular program, and there are no checks to ensure that the programmer is
not defining overlapping memory areas. Note that most programs written for
the CP/M system begin with an ORG statement of the form
ORG 108H
which causes machine code generation to begin at the base of the CP/M
transient program area. If a label is specified in the ORG statement, then
the label is given the value of the expression (this label can then be used in
the operand field of other statements to represent this expression).
4.2. The END directive.
The END statement is optional in an assembly language program, but if it
is present it must be the last statement (all subsequent statements are
ignored in the assembly). The two forms of the END directive are
label END
label END expression
where the label is again optional. If the first form is used, the assembly
process stops, and the default starting address of the program is taken as
0000. Otherwise, the expression is evaluated, and becomes the program
starting address (this starting address is included in the last record of the
Intel formatted machine code "hex" file which results from the assembly).
Thus, most CP/M assembly language programs end with the statement
END 100H
resulting in the default starting address of 10@H (beginning of the transient
program area).
4.3. The EQU directive.
The EQU (equate) statement is used to set up synonyms for particular
numeric values. the form is
label EQU expression
where the label must be present, and must not label any other statement. The
assemler evaluates the expression, and assigns this value to the identifier
given in the label field. The identifier is usually a name which describes
the value in a more human-oriented manner. Further, this name is used
throughout the program to “"parameterize” certain functions. Suppose for
example, that data received from a Teletype appears on a particular input
port, and data is sent to the Teletype through the next output port in
sequence, The series of equate statements could be used to define these ports
for a particular hardware environment
TIYBASE EQU 10H BASE PORT NUMBER FOR TTY
TTYIN EQU TTYBASE ;TTY DATA IN
TTYOUT EQU TTYBASE+1;TTY DATA OUT
6 ..
At a later point in the program, the statements which access the Teletype
could appear as
IN TTYIN sREAD TTY DATA TO REG-A
our TTYOUT WRITE DATA TO TTY FROM REG-A
making the program more readable than if the absolute i/o ports had been
used. Further, if the hardware environment is redefined to start the Teletype
communications ports at 7FH instead of 10H, the first statement need only be
changed to
TIYBASE EQU 7FH «BASE PORT NUMBER FOR TTY
and the program can be reassembled without changing any other statements.
4,4, The SET Directive.
The SET statement is similar to the EQU, taking the form
label SET expression
except that the label can occur on other SET statements within the program,
The expression is evaluated and becomes the current value associated with the
label. Thus, the EQU statement defines a label with a single value, while the
SET statement defines a value which is valid from the current SET statement to
the point where the label occurs on the next SET statement. The use of the
SET is similar to the EQU statement, but is used most often in controlling
conditional assembly,
4,5. The IF and ENDIF directives,
The IF and ENDIF statements define a range of assembly language statements
which are to be included or excluded during the assembly process. The form is
IF expression
statement#1
statement#2
statement#n
ENDIF
Upon encountering the IF statement, the assembler evaluates the expression
following the IF (all operands in the expression must be defined ahead of the
IF statement). If the expression evaluates to a non-zero value, then
statement#1 through statement#n are assembled; if the expression evaluates to
zero, then the statements are listed but not assembled. Conditional assembly
is often used to write a single "generic" program which includes a number of
possible run-time environments, with only a few specific portions of the
program selected for any particular assembly. The following program segments
for example, might be part of a program which communicates with either a
Teletype or a CRT console (but not both) by selecting a particular value for
TTY before the assembly begins
10
TRUE — EQU OFFFFH :DEFINE VALUE OF TRUE
FALSE EQU NOT TRUE —;DEFINE VALUE OF FALSE
TY BQU TRUE TRUE IF TTY, FALSE IF CRT
TTYBASE EQU 10H .BASE OF TTY I/O PORTS
CRIBASE EQU 20H „BASE OF CRT 1/0 PORTS
IF IN . ASSEMBLE RELATIVE TO TTYBASE
CONIN EQU TTYBASE + ¡CONSOLE INPUT
CONOUT EQU TTYBASE+1 ¡CONSOLE OUTPUT
ENDIF
IP NOT TTY ;ASSEMBLE RELATIVE TO CRIBASE
CONIN EQU CRIBASE ‚CONSOLE INPUT
CONOUT EQU CRTBASE+l ¡CONSOLE OUTPUT
ENDIF
IN CONIN :READ CONSOLE DATA
OUI CONOUT WRITE CONSOLE DATA
In this case, the program would assemble for an environment where a Teletype
is connected, based at port 10H. The statement defining TTY could be changed
to
TTY
EQU FALSE
and, in this case, the program would assemble for a CRT based at port 20H.
4.6. The DB Directive.
The DB directive allows the programmer to define initialize storage areas
in single precision (byte) format. The statement form is
label DB е#1, е#2, ..., e#n
where e#l through en are either expressions which evaluate to 8-bit values
(the high order eight bits must be zero), or are ASCII strings of length no
greater than 64 characters. There is no practical restriction on the numer
of expressions included on a single source line. The expressions are
evaluated and placed sequentially into the machine code file following the
last program address generated by the assembler, String characters are
similarly placed into memory starting with the first character and ending with
the last character. Strings of length greater than two characters cannot be
used as operands in more complicated expressions (i.e., they must stand alone
between the commas). Note that ASCII characters are always placed in memory
with the parity bit reset (8). Further, recall that there is no translation
from lower to upper case within strings. The optional label can be used to
reference the data area throughout the remainder of the program. Examples of
valid DB statements are
data: DB 0,1,2,3,4,5
data and 6ffh,5,377Q,1+2+3+4
‘please type your name ‘,cr,l£,0
AB” SHR 8, °С’, ‘DE’ AND 7FH
signon:
E 0
4.7. The DW Directive,
The DW statement is similar to the DB statement except double precision
(two byte) words of storage are initialized. The form 1s
label DW e#l, e#2, ..., e#n
were ell through ein are expressions which evaluate to 16-bit results. Note
that ASCII strings of length one or two characters are allowed, but strings
longer than two characters disallowed. In all cases, the data storage is
consistent with the 8080 processor: the least significant byte of the
expression is stored forst in memory, followed by the most significant byte.
Examples are
doub: DW 1$2f£fefh,doub+4,signon-$,255+255
DW ‘a’, 5, ab”, CD, 6 shl 8 or 11b
4.8. The DS Directive.
The DS statement is used to reserve an area of uninitialized memory, and
takes the form
label DS expression
where the label is optional. The assembler begins subsequent code generation
after the area reserved by the DS. Thus, the DS statement given above has
exactly the same effect as the statement
label: EQU $ LABEL VALUE IS CURRENT CODE LOCATION
ORG S+expression =— ;MOVE PAST RESERVED AREA
5. OPERATION CODES,
Assembly language operation codes form the principal part of assembly
language programs, and form the operation field of the instruction. In
general, ASM accepts all the standard mnemonics for the Intel 8080
microcomputer, which are given in detail in the Intel manual "8080 Assembly
Language Programming Manual.” Labels are optional on each input line and, if
included, take the value of the instruction address immediately before the
instruction is issued. The individual operators are listed breifly in the
12
following sections for completeness, although it is understood that the Intel
manuals should be referenced for exact operator details, In each case,
ej represents a 3-bit value in the range 0-7
which can be one of the predefined registers
A, B, C, D, E, H, L, M, SP, Or PSW.
e8 represents an 8-bit value in the range 92-255
el6 represents a 16-bit value in the range 0-65535
which can themselves be formed from an arbitrary combination of operands and
operators. In some cases, the operands are restricted to particular values
within the allowable range, such as the PUSH instruction, These cases will be
noted as they are encountered.
In the sections which follow, each operation codes is listed in its most
general form, along with a specific example, with a short explanation and
special restrictions.
Sel. Jumps, Calls, and Returns,
The Jump, Call, and Return instructions allow several different forms
which test the condition flags set in the 8080 microcomputer CPU, The forms
are
JMP el6 JMP Ll Jump unconditionally to label
JNZ el6 JMP L2 Jump on non zero condition to label
JZ el6 JMP 100H Jump on zero condition to label
INC el6 UNC Ll+4 Jump no carry to label
JC el6 JC L3 Jump on carry to label
JPO el6 JPO $+8 Jump on parity odd to label
JPE el6 JPE L4 Jump on even parity to label
JP el6 JP GAMMA Jump on positive result to label
JM —el6 JM al Jump on minus to label
CALL el6 CALL Sl Call subroutine unconditionally
NZ el6 С№ S2 Call subroutine if non zero flag
CZ elé CZ 100H Call subroutine on zero flag
NC el6 CNC S1+4 Call subroutine if no carry set
CC el6 CC S3 Call subroutine if carry set
СРО el6 CRO $+8 Call subroutine if parity odd
CPE el6 CPE $4 Call subroutine if parity even
CP el6 CP GAMMA Call subroutine if positive result
CM el6 CM DblSc2 Call subroutine if minus flag
RST e3 RST @ Programmed "restart", equivalent to
CALL 8*e3, except one byte call
13
RNZ
ZE
RC
#553
Return from subroutine
Return if non zero flag set
Return if zero flag set
Return if no carry
Return if carry flag set
Return if parity is odd
Return if parity is even
Return if positive result
Return if minus flag is set
5.2. Immediate Operand Instructions,
Several instructions are available which load single or double precision
registers, or single precision memory cells, with constant values, along with
instructions which perform immediate arithmetic or logical operations on the
accumulator (register A).
MVI e3,e8
ADI e8
ACI e8
SUI e8
SBI e8
ANI e8
XRI e8
ORI e8
CPI e8
LXI e3,el6
MVI B,255
ADT 1
ACI @QFFH
SUI L + 3
SBI L AND 11B
ANI $ AND 7FH
XRI 1111S9000B
ORI L AND 1+1
CPI a
LXI B,100H
Move immediate data to register A, B,
C, D, E, H, L, or M (memory)
Add immediate operand to A without carry
Add immediate operand to A with carry
Subtract from A without borrow (carry)
Subtract from A with borrow (carry)
Logical "and" A with immediate data
"Exclusive or” A with immediate data
logical "or" A with immediate data
Compare A with immediate data (same
as SUI except register A not changed)
Load extended immediate to register pair
(e3 must be equivalent to B,D,H, or SP)
5.3. Increment and Decrement Instructions,
Instructions are provided
in the 8080 repetoire for incrementing or
decrementing single and double precision registers. The instructions are
INR e3
DCR e3
INX e3
DCX e3
INR E
DCR A
INX SP
DCX B
Single precision increment register (e3
produces one of A, B, C, D, E, H, L, M)
Single precision decrement register (e3
produces one of A, B, C, D, E, H, L, M)
Double precision increment register pair
(e3 must be equivalent to B,D,H, or SP)
Double precision decrement register pair
(e3 must be equivalent to B,D,H, or SP)
5.4. Data Movement Instructions.
14
Instructions which move data from memory to the CPU and from CPU to
memory are given below
MOV e3,e3
LDAX
STAX
LHLD
SHLD
LDA
STA
POP
PUSH
IN
our
XTHL
PCHL
SPHL
XCHG
e3
e3
el6
el6
el6
el6
e3
e3
e8
e8
MOV A,B
LDAX B
STAX D
LHLD Ll
SHLD L5+X
LDA Gamma
STA X35
POP PSW
PUSH B
IN
our 255
9
Move data to leftmost element from right-
most element (e3 produces one of A,B,C
D,E,H,L, or M), MOV M,M is disallowed
Load register A from computed address
(e3 must produce either B or D)
Store register À to computed address
(e3 must produce either B or D)
Load HL direct from location el6 (double
precision load to H and L)
Store HL direct to location el6 (double
precision store from H and L to memory)
Load register A from address el6
Store register A into memory at el6
Load register pair from stack, set SP
(e3 must produce one of B, D, H, or PSW)
Store register pair into stack, set SP
(e3 must produce one of B, D, H, or PSW)
Load register A with data from port e8
Send data from register A to port e8
Exchange data from top of stack with HL
Fill program counter with data from HL
Fill stack pointer with data from HL
Exchange DE pair with HL pair
5.5. Arithmetic Logic Unit Operations.
Instructions which act upon the single precision accumulator to perform
arithmetic and logic operations are
ADD
ADC
SUB
SBB
ANA
ORA
CMP
CMA
STC
e3
e3
e3
e3
e3
e3
e3
e3
ADD
ADC
SUB
SBB
ANA
ORA
B
Add register given by e3 to accumulator
without carry (e3 must produce one of A,
B, C, D, E, H, or L)
Add register to À with carry, e3 as above
Subtract reg e3 from A without carry,
e3 is defined as above
Subtract register e3 from A with carry,
e3 defined as above
Logical "and" reg with A, e3 as above
"Exclusive or” with A, e3 as above
Logical “or” with A, e3 defined as above
Compare register with A, e3 as above
Decimal adjust register A based upon last
arithmetic logic unit operation
Complement the bits in register A
Set the carry flag to 1
15
CMC
DAD e3
Complement the carry flag
Rotate bits left, (re)set carry as a side
effect (high order A bit becomes carry)
Rotate bits right, (re)set carry as side
effect (low order A bit becomes carry)
Rotate carry/A register to left (carry is
involved in the rotate)
Rotate carry/A register to right (carry
is involved in the rotate)
DAD B Double precision add register pair e3 to
HL (e3 must produce B, D, H, or SP)
5,6. Control Instructions.
The four remaining instructions are categorized as control instructions,
and are listed below
HLT
DI
El
NOP
6. ERROR MESSAGES.
Halt the 8080 processor
Disable the interrupt system
Enable the interrupt system
No operation
When errors occur within the assembly language program, they are listed as
single character flags in the leftmost position of the source listing. The
line in error is also echoed at the console so that the source listing need
not be examined to determine if errors are present. The error codes are
D
Data error: element in data statement cannot be
placed in the specified data area
Expression error: expression is ill-formed and
cannot be computed at assembly time
Label error: label cannot appear in this context
(may be duplicate label)
Not implemented: features which will appear in
future ASM versions (e.g., macros) are recognized,
but flagged in this version)
Overflow: expression is too complicated (i.e., too
many pending operators) to computed, simplify it
Phase error: label does not have the same value on
two subsequent passes through the program
16
7.
R Register error: the value specified as a register
is not compatible with the operation code
Vv Value error: operand encountered in expression is
improperly formed
Several error message are printed which are due to terminal error
conditions
NO SOURCE FILE PRESENT
NO DIRECTORY SPACE
SOURCE FILE NAME ERROR
SOURCE FILE READ ERROR
OUTPUT FILE WRITE ERROR
CANNOT CLOSE FILE
A SAMPLE SESSION.
The file specified in the ASM command does
not exist on disk
The disk directory is full, erase files
which are not needed, and retry
Improperly formed ASM file name (e.g., it
is specified with "?” fields)
Source file cannot be read properly by the
assembler, execute a TYPE to determine the
point of error
Output files cannot be written properly, most
likely cause is a full disk, erase and retry
Output file cannot be closed, check to see
if disk is write protected
The following session shows interaction with the assembler and debugger in
the development of a simple assembly language program.
[7
ASN SORT,
CP/M ASSEMBLER -
b15C vext tree addvess
803H USE FACTOR 04 of
assenble SopT. RSM
VER 1.8
alle used 00 To FF (hexadecimal )
END OF ASSEMBLY
DIR SORT. *,
SORT ASM source file at edit
SORT BAK © ram last ed:
SORT PRN print file (contains Tob characters)
SORT HEX wackme code file
A)>TYPE SORT. PRN,
Source (me
lus code. \ocahon + SORT PROGRAM IN CP/M ASSEMBLY LANGUAGE
we 0 ; START AT THE BEGINNING OF THE TRANSIENT PROGRAM AR
61080 “——— ORG 1 Вен
euanaled wachug Code
6100 21468014) SORT: LAI H, SU ¿ADDRESS SWITCH TOGGLE
0103 3601 MY 1 M, 1 ¿SET TO 1 FOR FIRST ITERATION
8165 214761 LEI Ho I ¿ADDRESS INDEX
01808 3600 MOI и, @ ;1 = 8
; COMPARE I WITH ARRAY SIZE
8100 7E COMP: MOV А, М ¿A REGISTER = I
918B FEG9 CPI N-1 ¿CY SET IF I € (N-1)
16D D21981 JNE CONT ; CONTINUE IF I <= (N-2)
; END OF ONE PASS THROUGH DATA
8110 214601 LEI H, SU ¿CHECK FOR ZERO SUITCHES
0113 7EB7C20001 MOV A, MI ORA A! JNZ SORT ¿END OF SORT IF SW=@
é
8118 FF RST ? ¿GO TO THE DEBUGGER INSTEAD NF RE
uncale ОНТ НОЕ THIS PASS
; ADDRESSING I, SO LOAD AYVCI) INTO REGISTERS
8119 5F16B02148CONT. MOV E,A! MYI D, 8! LXI H.AVI DAD D! DAD D
8121 4E792346 МОУ С, М! MOV B,C! INX H! МОУ В.М
LOW ORDER BYTE IN A AMD C, HIGH ORDER BYTE IN B
; MOY H AND L TO ADDRESS AYCI+1)
0125 23 INX H
j
; COMPARE VALUE WITH REGS CONTAINING AYCI)
0126 965778239E SUB M! MOV В, А! МОУ А, В! INX H! SEB M — ¡SUBTRACIT
; BORROW SET IF AVCI+1) > AYCID
0128 DAJ3FBi JE INCI ¿SKIP IF IN PROPER ORDER
à
; CHECK FOR EQUAL VALUES
12E B2CA3FO1 ORA D! JZ INCI SKIP IF AYCI) = AYCI+1) 18
6132
8136
013B
B13F
0146
8147
9148
BOOR
815C
86
567A2BSE
7128722873
21460134
i
¿
i
21478134C3INCI:
A
SU:
I :
0506064001EAV.
LS. equate value
e
A>TYPE SORT. НЕХ
Mov 1, М!
Moy M,C!
МОУ
М, В!
BCK HI
MOY
DCX HI
И, В!
INCREMENT SWITCH COUNT
LAI H,
sul
INCREMENT I
LXI H,
1!
INR M!
INR M
JMP
COMP
DATA DEFINITION SECTION
; RESERYE SPACE FOR SWITCH COUNT
¿SPACE FOR INDEX
5, 180, 36, «8, 28, 7 18998, 360. 196, -32767
; COMPUTE N INSTEAD OF PRE
DB
DS
DU
EQU
END
0
1
($-AV)/2
: 1601009021 4 60 1360121 4 78 136 9ВТЕРЕВ 302 198 149
‚ 1001100821 4 68 17ЕВ7 С2 9 ЯВ 1РЕР УР 16082 14 8 0 1 1983
: 10012800194E79234623965778239E DASFBIEZCAA?
: 190136003F015670285E712B7228B732146B13421C7
:07014606470134C306AB10806E
: 1001480060500648061E083200140080700E68832C018BB
: 040 158ABE400B1B8BBE
: 0900060008
A>DBT SORT. HEX, start debua run
16K DUT YER 1.0
NEXT PC
8150 0600 defautt
- ХР)
P=0000 160, Change PC +0 100
-UFFFF) Urtvace La 6553 Steps
COZOMBEOIO A=09 B=0000 D=3000
7718) “race 10 steps
COZOMBEAIO
COZaMBECIOA
CoOZaMBEOIO
COZAMBEOIA
COZOMBEGIO
COZOMBEOIO
C12Z0MIECIO
C1Z26M1E6IB
C1Z6M1E6I0O
C1Z6M1EBGIO
COZOMBEOIO
COZ20MBEOIA
COZBMBEGIO
COZBMBEOIEO
COZOMBEOIB
COZBOMBEOGIA
-A16D
0101 Ко 119, Change to a Juno ón Cary
A=01
A=01
A=01
A=01
A=01
A=00
A=00
A=00
A=00
A=01
A=01
A=01
R=01
A=81
A=01
A=B1
B=00600
B=0000
B=0086
B=0060
B=0086
B=68886
8=0080
B=8000
E=0000
B=0080
8=0080
B=00080
В = 8 908
В =й 009
B-=0000
B=80B-0
D=8000
D=8900
D=50090
D=8000
D=8000
D=080006
D=8000
D=0006
D=8000
D=00008
D=8000
D=8008
D=8006
D=8000
D=8006
D=80060
Н= 8@ 90
Н= 8146
Н= 8146
H=0146
H=0147
H=0147
H=0147
H=0147
H=0147
H=0146
H=0146
H=0146
H=0146
H=0146
H=0146
H=014?
Н= 90147
5= 0106
5=0100
Ss=0100
S=0109
€=0109
5= 6198
5= 01890
5= 9189
s=8100
5= 8106
5= 6108
5=0109
5= 8108
5= 91 09
5= 0108
5= 6108
s=0100
MOY Е, М
DCX H!
Moy М, Е
machume code in
Hex tard”
address (no address on BD stctemeit)
P=8140
P=8108
P=8103
P=-0165
P=0163
P=016
F=010B
P=010D
P0110
P=0113
Pr@114
P=8115
P=08100
P=0103
P=8105
P=01@8
РЕЙ 108
LA]
LX]
MVI
LXI
MYI
MOV
CPI
JNC
LXI
MOY
ОКА
JNZ
LXI
MVI
LXI
МУ!
Mov
sid
aba wdb
Yulo dut
Н, 6 146 +0 10
H,8146
4,61
H,6147
M, BO
A, M
a9
8113
H, 8146
я, М
a
6100
H, 8146
M,B1
H,8147
Mm, 00
A, M*B10B
|
1 96 H 7
- xP
я
P=010B 160, Yeset progam couter back To bes nina of Program
у Lor (OH Steps
-T18, “trace execution
м
COZeMBEOIO
COZOMBEOIO
COZeMBEOIA
COZOMBEGIEG
COZAMBEOIO
COZOMBEAIO
C1Z0MIEOIO
C120MIEGIO
CI1ZEMIEOIO
C120MIEOIO
CIZ0MIEOIO
COZOMIEGIA
COZeMIECIA
COZOMIECIOA
COZOAMIERIO
CoZ2aMIECIO
186,
8190
9193
8105
8198
919A
9108
810
8116
Bils
9114
8115
a;
8118
8119
8119
BIC
LX]
MVI
LXI
MVI
MOV
CPI
JC
LXI
MOV
ORA
JNZ
RST
MOV
MYI
LXI
- С, 1 18, srt progaux from
«0127 Stopped vta au external whew vupt 7 from pt PO
A=00
A=00
A=00
A=06
A=60
R=60
A=06
A=60
A=R0
A=00
A=00
A=00
A=G6
A=00
A=05
A=65
B=GOBO
В = 8 6809
B=0086
B=0000
B:0006
B=00B506
B=0080
B=00006
B=6000
B=0000
B=6000
8=0000
e=0004
e=8005
B=0005
8:=0005
H, 9146
M, 81
H.,8147
M, 60
A, H
69
6119
=B000
D=8000
D=B006
D=00006
n=B000
D=8000
D=8000
1=8000
D=0000
D=0000
D=8000
D=8008
D=4 000
D=8000
D=8000
L=8896
H=0147
H=0146
H=0146
H=0147
H=0147
H=014?7
H=014?
H=0147
H=0147
Н= 9147
Н= 91 48
Н= 91 48
Н= #148
Н= 2148
Н= #148
Н=@ 149
lok SOME code
Hom LOOK
H, 8146
я, М
A
8168
0?
E, A
D, 98
let more
H,0148
“= Govt lat oka rubast
“T42 look at loop my Program w vce mode 3
COZ20MBEOIO
COZUMBEOIA
COZOMBEGIA
CoOZaAMBEGIOA
-D148
6146 05 60
9150 32 60
8160 88 00
A=38 B=0064
R=38 B=0064
A=80 B=0064
A=80 B=0064
67 00 14 B6
64 00 64 60
80 980 08 DO
D=8006
D=3806
D=3806
D=3806
1E 09
H=0156
H=0156
H=0156
H=0157
P=8168
P=0103
P=8165
P=81@8
P=010A
P=616B
P=@1@D
P=8113
P=@11R
P=011C
P=B11F
P=0129
P=@121
F=ël22
P=0123
РЕВ 124
LX]
МУ]
LXI
MVI
Mov
CPI
JC
MOV
МУ]
LR]
DAD
DAD
MOV
40V
INK
MOV
Automatic
break pot
H, 0146 =>
H, 61 A
a, M
0s" J
8119
UD, 00
Н, 0 14 8
D
С, й
A. E
H
neo A
E, A
D
В, М* 8 125
curvext PC (01254) and vue (wn veal +me + | {BH
mel (Progmu wos
Locpma | mcely) |
S=0100 P=0127 MOV D.A
S=0100 P=81Z8 MOV A,B
S=0100 P=8129 INX Hi
S=0100 P=812ZA SEB M+612B
a data (© Sorted, but program doesnt Step -
20 81 ES 67 81 80 DA 08 06 80 2.D.D......
bo 00 Où
Liv
80 60 69 88 Vb BB
20
-67, return +o CP/M
DDT SORT. HEX, reload He memwy imag
16K DDT VER 1.0
NEXT PC
815C B606
- XP
P=0008 1607 Set PC o benny of program
-L18D, lat bad opcode
8190 JNE 01197
0118 LXI H, 9146
= dort let win rubout
-A18D) assewlole new opcode
H18D JC 119
a
Bila
-L169, List stertra sect of pea
6166 LXI H,8146
8183 MVI M,61
81053 LXI H- 0147
0198 MVI M,00
" aloovt list with rubsul ВЕ |
-AIES) clone “wea tub alization + 00
01233 MYI M, 0)
8105,
e return р CP/M with ell-e (GF woks as well)
SAVE 1 SORT.COM, save 1 роде (256 butes, rom. 1004 0 1FFH) en disk ws Case
, we have Yo reload later
AYDDT SORT, COM, restart DDT with
Saved memovy vna ®
16K DDT VER 1.
NEXT PC |
0200 0108 "CoN" fıle always Start? wrth address (00H
"67 run the proyau {ram PC=100H
“6118 Programmed stop (2577) enesuntered
-D148 deta Lo очей
00 a proper
2148 85 80 07 08 14 BO IE 2. |.
9150 32 80 64 AB ES DE 2C 91 ES 83 61 80 98 98 VE BB 2.D.D.......
81566 28 80 08 00 YB 80 00 DO OB GB UG UY DO BB VB BB
9170 94 00 94 VB UB BE DO B8 AB uve BO bY OU VB 08 DA
- GH) return do CPIM >|
ED SORT. ASH make Chano es Im on gual Pragraw
cH-2 çÇ
«N, 6 o( Jot, Jud ved Su
for
М, @ ¡1 = 6
H, I ; ADDRESS INDEX
* =) up another (me
MVI M, 1 ¡SET TO 1 FOR FIRST ITERATION
“KT, A lue and Type wed line
LXI Ho I i ADDRESS INDEX
«1, wee ww line
MVI M, 8 ¿ZERO SU
“y
LX] H, 1 ¿ADDRESS INDEX
«нонсб ет
JNC*T,
CONT ¿CONTINUE IF I <= (N-2>
«-2DICCQOLT
ve ” CONT ¿CONTINUE IF I <= (N-2)
* E [oe fron dk disk A
a fl
ASM SORT. AA 25 po
CP/M ASSEMBLER - VER 1.8
6150 wat address do asseulle
B63H USE FACTOR
END OF ASSEMBLY
DDT SORT. HEX, Test proyam charges
16K DDT VER 1.8
NEXT PC
8150 0000
- 6108)
* 118
- 3148)
74 data sort ed
0148 DS 80 07 06 14 BO 1E 00
9158 32 68 64 98 €4 BO 2C Bi EB 03 91 80 99 98 90 BO 2.D.D.....
8166 DO BO 98 9086 VB BO VS VO AB 08 VO BO BAY EY ME HB
- abort with rubat
“ce, retura to CP/M_- Preyaux Cheds OL.
22
">
Download
Advertisement
Key features
Assembly language translation
Intel HEX format output
Error reporting
Assembler directives
Operand expression evaluation
Source code listing
Frequently asked questions
The ORG directive sets the program or data origin, specifying the starting address for machine code generation.
The END directive signals the end of the assembly language program and can optionally specify the program starting address.
The EQU directive sets up synonyms for numeric values, allowing you to assign meaningful names to constants.
The DB directive defines and initializes storage areas in single-precision (byte) format.