Реклама
Реклама
Table of Contents
D
Section qe
1. INTRODUCTION S20 0080000 80 BROS OCDE всоееов ева вез ево
2. PROGRAM FORMAT 016040000000 CoOoOUNCG EM CACA CCGO CE OEP EPOSUCEIONO
3. FORMING THE CPERAND SAN cNC OCHO EG COACALCO AN OU ESO PNUAEA
3.1. Labels > AIN íOCNCACI ODIO еее весовое ево
3.2. Numeric Constants 606060060894. еее ево а
3.3. Reserved Words eancacceC A GCACSCOCGOCCLI AO AO EEES
3.4. String Constants ,..ecssscccocsosocvosecsecocecaso
3.5. Arithmetic and Logical Operators esse...
3.6. Precedence of OperatOrS 2000000020000000000000
4. ASSEMBLER DIRECTIVES 0000000000000000000000000000008
4.1. The ORG Directive етот еее ево еее
4.2. The END Directive етот еее тез ево вова N
4.3. The EQU Directive еее еее ев ее аа ее вова ет
4.4. The SET Directive еее еее еее еее еее
4.5. The IF and ENDIF Directives C02 DOPOD I PEE OS SS
4.6. The DB Directive [3 ON ON ON NON NON NN NN NN NNN NN NNN NN
4.7. The DW Directive воет фев еее вова ев 12
Se OPERATION CODES . LOGRO ROOADOICCR вооон ев 12
5.1. dJumps, Calls, and Returns ....scccscscccocscococo 13
5.2. Immediate Operand Instructions ‚......0..00.000000 14
5.3. Increment and Decrement Instructions ...e..e.m... l4
5.4. Data Movement Instructions ..0...002000000200000 14
5.5. Arithmetic Logic Unit Operations .essscacasocoa 15
5.6. Control Instructions sesevosoeCSECCTOCACaAACACACECS 16
6. ERROR MESSAGES 000857090905 GO NRQONCHOCRO CA LAPUEOCOS. CCCSZLNUEOICUOOS 16
7. A SAMPLE SESSION > 1CcOlcCccCOCTI CCA CE COCAN CG A OO —ACANCONCAOS 17
LO (D CO CO JA MU >> NH
HH HH
os
CP/M Assembler User 's Guide
1. INTRODUCTION.
The CP/M assembler reads assembly language source files from the diskette,
and produces 8080 machine language in Intel hex format. The CP/M assembler is
initiated by typing
AM filename
or
AM filename.parms
In both cases, the assembler assumes there is a file on the diskette with the
name
filename ,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 form
is
£ilename.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-
ceive the hex file
2 skips the generation of the hex file
p3: A,B, «se, ¥Y designates the disk name which will re-
ceive the print file
X places the listing at the console
Z skips generation of the print file
Thus, the command
ASM Х.ААА
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
is equivalent to
AM X
The command
ASM 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
AM 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
line label operation operand ;comment
where any or all of the fields may be present in a particular instance. Each
assembly 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 "1!" which is a treated as an end-of-line by the assembler (thus,
multiple assemly 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 mnumer, 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 XY long$name
X: yx1: longer SnamedSdata:
X1Y2 X1x2 х234$5678$9012$3456:
The operation field contains either an assembler directive, or pseudo
operation, or an 80809 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 comment 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,
it 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)
4
Q octal constant (base 8)
D decimal constant (base 10)
H hexadecimal constant (base 16)
Q is an alternate radix indicator for octal numbers since the letter O is
easily confused with the digit 9. 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 Y - 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 0 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$900051111$08000B
12348 OFFEH 33770 7338775220
33770 dd fe3h 12340 @ffffh
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
A 7
B
C 1
D 2
E 3
H 4
L 5
M 6
SP 6
PSW 6
(again, lower case names have the same values as their upper case
eguivalents). 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 +he instruction (e.g, MOV A,B), the value of the instruction (in this case
MOV) 1s 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 "!" symbols 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” ‘ab’ Cc
‘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
a
unsigned arithmetic sum of a and b
unsigned arithmetic difference between a and b
unary plus (produces b)
unary minus (identical to 8 - b)
unsigned magnitude multiplication of a and b
unsigned magnitude division of a by b
remainder after a / b
logical inverse of b (all @'s become 1’s, 1’s
become 0's), where b is considered a 16-bit value
* 1 + | +
сос
= 09 à 9
ЗЕ
©
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 mich 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 16h+370 Ll /3 (L2+4) SHR 3
(a” and 5fh) + Y” (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 l's). The resulting expression must fit the operation code in
which it is used. If, for example, the expression is 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 (-l1
becomes @ffffh 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 egual 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 а + (5 * с)
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 (c + (d SAL 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 ¢) + d SHL e
resulting in the assumed parentheses
(a OR b) AND ( (NOT ec) + (d SHL e))
Note that an inparenthesized 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 100H
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 1s 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 160H (beginning of the transient
program area).
4.3. The EQU directive.
The EQU (eguate) 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
assembler 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
TTY IN EQU TTYBASE ;TTY DATA IN
TTYOUT EQU TTYBASE+] ;TTY DATA OUT
> =)
At a later point in the program, the statements which access the Teletype
could appear as
IN TTYIN sREAD TTY DATA TO REG-A
OUT 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 FH ¡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#l 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 sDEFINE VALUE OF FALSE
.
,
TTY EQU TRUE TRUE IF TTY, FALSE IF CRT
TTYBASE EQU 10H BASE OF TTY I/O PORTS
CRIBASE EQU 20H «BASE OF CRT I/O FORTS
IF TTY +ASSEMBLE RELATIVE TO TTYBASE
CONIN EQU TTYBASE CONSOLE INPUT
CONOUT EQU TTYBASE+l ¡CONSOLE OUTPUT
ENDIF
IF NOT TTY ;ASSEMBLE RELATIVE TO CRTBASE
CONIN EQU CRIBASE CONSOLE INPUT
CONOUT EQU CRIBASE+1 ¡CONSOLE OUTPUT
ENDIF
IN CONIN READ CONSOLE DATA
OUT 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 e#l, e#2, ..., €#n
where e#l through e#n 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 number
of expressions inciuded on a single source line. The expressions are
evaluated and placed seguentially 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 cammas). 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 $6,1,2,3,4,5
DB data and Gffh,5,3770,1+2+3+4
signon: DB ‘please type your name ,cr,lf,0
Ld ”
DB “AB” SHR 8, °С”, DE” AND 7FH
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 is
label DW е#1, e#2, ..., ein
where e#l through e#n 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 =70offefh,doub+4,signon-$,255+255
DN ‘a, 5, ‘ab’, CD, 6 shl 8 or 1lb
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 S ¡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 “8089 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,
e3 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 08-255
el6 represents a 16-bit value in the range 8-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 Li Jump unconditionally to label
JNZ el6 JMP L2 Jump on non zero condition to label
JZ el6 МР 100H Jump on zero condition to label
INC el6 JNC L1+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
CNZ el6 CNZ 2 Call subroutine if non zero flag
CZ el6 CZ 1004 Call subroutine on zero flag
CNC el6 CNC 51+4 Call subroutine if no carry set
CC el6 CC 3 Call subroutine if carry set
СРО el6 СРО $+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 blsc2 Call subroutine if minus flag
RST e3 RST @ Programmed "restart", eguivalent to
CALL 8*e3, except one byte call
13
5.2.
RNZ
AS
RC
2553
from subroutine
if non zero flag set
if zero flag set
if no carry
if carry flag set
if parity 15 odd
if parity is even
if positive result
if minus flag is set
Return
Return
Return
Return
Return
Return
Return
Return
Return
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).
5.3.
MVI
ADI
ACI
SUI
SBI
ANI
XRI
ORI
CPI
ХТ
e3,e8
e8
e8
e8
e8
e8
e8
e8
e8
e3,el6
MVI
ADI
ACI
SUI
SBI
ANI
XRI
ORI
CPI
LXI
B,255 Move immediate data to register À, B,
C, D, E, H, L, or M (memory)
1 Add immediate operand to À without carry
OF FH Add immediate operand to A with carry
LL + 3 Subtract from A without borrow (carry)
L AND 11B Subtract from A with borrow (carry)
$ AND 7FH Logical "and" A with immediate data
1111$0000В "Exclusive or" A with immediate data
L AND 1+1 Logical "or" A with immediate data
a Compare A with immediate data (same
as SUI except register A not changed)
B,190H Load extended immediate to register pair
(e3 must be equivalent to B,D,H, or SP)
Increment and Decrement Instructions,
Instructions are provided
decrementing single and double precision registers,
5.4.
INR e3
DCR
INX
DCX
e3
e3
e3
INR E
DCR A
INX
SP
DCX B
incrementing or
The instructions are
in the 8080 repetoire for
Single precision increment register (e3
produces one of A, B, C, D, E, H, L, М)
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)
Data Movement Instructions.
14
Instructions which move data from memory to the CPU and from CPU to
memory are given below
MOV e3,e3 MOV A,B 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
LDAX e3 LDAX B Load register À from computed address
(e3 must produce either B or D)
STAX e3 STAX D Store register A to computed address
(e3 must produce either B or D)
LHLD el6 LHLD Ll Load HL direct from location el6 (double
precision load to H and 1)
SHLD el6 SHLD L5+x Store HL direct to location el6 (double
precision store from H and L to memory)
LDA el6 LDA Gamma Load register A from address el6
STA el6 STA X35 Store register A into memory at el6
POP e3 POP PSW Load register pair from stack, set SP
(e3 must produce one of B, D, H, or PSW)
PUSH e3 PUSH B Store register pair into stack, set SP
(e3 must produce one of B, D, H, or PSW)
IN es IN © Load register A with data from port e8
OUT eS OUT 255 Send data from register A to port e8
XTHL Exchange data from top of stack with HL
PCHL Fill program counter with data from HL
SPHL Fill stack pointer with data from HL
XCHG 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 e3 ADD B Add register given by e3 to accumulator
without carry (e3 must produce one of A,
B, C, D, E, H, or L)
ADC e3 ADC L Add register to A with carry, e3 as above
SUB e3 SUB H Subtract reg e3 from A without carry,
e3 is defined as above
SBB e3 SBB 2 Subtract register e3 from A with carry,
e3 defined as above
ANA e3 ANA 141 [Logical "and” reg with A, e3 as above
XRA e3 XRA A "Exclusive or” with A, e3 as above
ORA e3 ORA B | Logical “or” with A, e3 defined as above
CMP e3 CMP H Compare register with A, e3 as above
DAA Decimal adjust register A based upon last
arithmetic logic unit operation
CMA Complement the bits in register A
STC 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 8, D, H, or SP)
5.6. Control Instructions.
The four remaining instructions are categorized as control instructions,
and are listed below
HLT
DI
El
МОР
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 subseguent passes through the program
16
R Register error: the value specified as a register
is not compatible with the operation code
\ 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 The file specified in the ASM command does
not exist on disk
NO DIRECTORY SPACE The disk directory is full, erase files
which are not needed, and retry
SOURCE FILE NAME ERROR Improperly formed ASM file name (e.g., it
is specified with "2?" fields)
SOURCE FILE READ ERROR Source file cannot be read properly by the
assembler, execute a TYPE to determine the
point of error
OUTPUT FILE WRITE ERROR. Output files cannot be written properly, most
likely cause is a full disk, erase and retry
CANNOT CLOSE FILE Output file cannot be closed, check to see
if disk is write protected
7. A SAMPLE SESSION.
The following session shows interaction with the assembler and debugger in
the development of a simple assembly language program.
[7
ASH SORT, assemble SopT ASM
CP/M ASSEMBLER - VER 1.8
B15C ext free address |
G03H USE FACTOR 0% Table used 00 To FF (bexadecuissd )
END OF ASSEMBLY
DIR SORT. #2
SORT ASM Source file a
SORT BAK lockup nm last ed:
SORT PRN prit file (contains Tab Characters)
SORT HEX wacko code file
A>TYPE SORT. PRN,
Source (me
Waclume Code. locaton > SORT PROGRAM IN CP/M ASSEMBLY LANGUAGE
; START AT THE BEGINNING OF THE TRANSIENT PROGRAM AK
6109 & . ORG (60H
gewanated wachmg Code
8100 21460147 SORT: LAI H, SU ;ADDRESS SWITCH TOGGLE
0143 3601 MY 1 M, 1 ¿SET TA t FOR FIRST ITERATION
0105 214781 LAI H, I ADDRESS INDEX
0108 3600 MY 1 м, 6 ¡1 = B
; COMPARE I WITH ARRAY SIZE
8100 7E COMP: MO Y А, М ; 66 REGISTER = I
919В FEB9 CPI N-1 ¿EY SET IF I € €N-1)
GiBD b21981 JNC CONT ; CONTINUE 1F I <= (N-2)>
; END OF ONE PASS THROUGH DATA
8110 214601 EXI H, SU ¡CHECK FOR ZERO SWITCHES
0113 7EB7C20001 MOV A, MI ORA A! JNZ SORT END OF SORT IF Su=8
8118 FF RST 7 ¿CO TO THE DEBUGGER INSTEAD MF REF
uncated ОНТ} НОЕ THIS PASS
; ADDRESSING I, SO LOAD AYVCIS INTO REGISTERS
0119 S5SF16B82148CONT: MOV E.A! MYI D, 8! LXI H. A! DAR В! DAR D
B121 4E792346 MOY C,f! MOV fA, CY IHX HY МОУ В. М |
; LOU ORDER BYTE IN A AND ©, HIGH ORDER BYTE IN В
; MOY H AND L TQ RBDRESS AYCI+1)
8125 23 Id H
i
i COMPARE VALUE WITH REGS CONTAINING AY C(ID
0126 965773239E SUB M! MOV D,A! MOY A,B! INX HI SEB MM i SUBTRACT
; BORROW SET IF AYCI+1) > AYKI)
9128 DA:3F01 ЧЁ INCI ¿SKIP IF IN PROPER ORDER
; CHECK FOr ERUAL VALUES
012E B2CAJFEOI ORA DI JZ INCI ¿SKIP IF AVCI) = AYCI+1) 18
6132
wo?
0136 712
a
B
0138
A13F
8146
8147
8145
BGOR
O15C
Bo
2BSE
722673
21460134
i
$
i
21478134C3INCI:
2
Su:
I :
OIBUEdABIEAY:
X— equale value
ВУТУРЕ SORT. HER,
:19010606214601360121478136007EFE69D219G148
МОУ п, М! MOY М. В! DCX HY МОУ Е, М
MOY М, С! DCK HI MOV H,D! DCX H! MOV M, E
INCREMENT SUITCH COUNT
LAI НН, ЗЫ! INR M
INCREMENT I
LAI H.11!1 INR MI JMP COMP
DATA DEFINITION SECTION
DB 9 ; RESERVE SPACE FOR SWITCH COUNT |
DS 1 ¿SPACE FOR INDES
Du 5: 180,36, 56, 28, 7, 19868, 358. 106, -32767
EQU ($-AVY)72 i COMPUTE N INSTEAD OF PRE
END
: 1QO110002146B17/EBD7C20081FFSFI6E60BCT148011993
: 190 12806194E7923462392557783239E DASFOIBACARAA?
: 198 1300B3FBINSG7AZ2RSE7 12B722B732146013421C?
: 07014000470134C 30AB1B06E
:100148000500664801E08320014000700E8B32C018BB
: 0481580064060 18B68BE
0900606006000
A>DUT SORT. HEX, start debu, run
16K DPT VER
NEXT PC
815¢ pees default a
- XP)
1.0
P=00080 180, Change ТС. +o (00
-UFFFF) urdvace Las 65539 Steps
COZOMBESIO A=0D B=0000 D=B009
COZOMBEOIO
COZOMBEOIB
COZOMBEOIO
COZAMBECIO
COZOMBEOIO
COZONMBERIO
CIZ0MIEGIO
C1Z0MIEGIO
C1Z6M1EG18
CIZOMIEGIO
COZOMBEOIO
COZeMBEATEO
COZUMBEEOIO
COZ0MBEGIEO
COZOMBEAIEO
COZOMBEEGIO
-A1GD
019D
0110 7
R=81
R=01
A=01
A=01
R=01
A=00
A=08
A=66
A=08
A=01
A=81
A=01
A=81
A=B1
A=01
A=01
B:=8900
B=ADDO
E=B000
B=0000
B=0886
66-0986
5:=00880
B=0000
В = ево
B=0000
В= 8986
B=0000
B=00080
B=0000
B=6080
В = 6 08.9
D=8000
D=8006
0= 60 98
D=8000
1 = 9 89
D=090006
D=80RO
D=6606
В= Ве 08
D=0000
D=8000
D=0008
D=B006
N=B900
D-40800
D=-8 080
H=0490
H=8146
H=6146
H=6146
H=0147
H=0147
H=0147
H=81 49
H=@1 47
H=G146
H=0146
H=0146
H=0146
H=0146
H=0146
H=0147
H=0147
de 119, Change to a jus? on Carey
01u6
co
S=0100
s=0106
с= 9108
с =@ 188
5=t198
5= 91 08
s=0100
5=@ 100
5=8100
5=9100
5=0198
S=0180
S=0168
5=8108
s=8100
s=0100
machi we еже. in
Hex Tarma
Adress (vo address on BID sheet)
P=0100
P=0100
P=8103
P=G165
P:01048
P=-BIER
F=@10B
P=810D
F:0110
P=&113
PROI14
P=B115
P=0108
P=0163
PF=81&85
P=01U8
P=016R
LX]
LA]
MVI
LX!
MY 1
MOY
CPI
JNE
Lal
MOY
DORA
JNZ
LXI
MY I
LXI
МУ!
MOV
Ag à À
abort ой
f about
НН, Я 145 +В 108
H, 8146
M, 81
М, 68
RH. HM
83
8113
H. 6146
A, M
A
6160
H.B146
M, 81
H, 8147
1,86
A: M*B1V6
|
UBH 7
- xP
7
P=8108 186 veset Prosyaux our back b bes inning Í prosram.
y
-T16, trace execution Lor (OH 5*р5 ди”
COZOMBEGIA A=00 B:=6806 D=LG006 Н=014? S=0810@ P=8166 LX] H, 8146 A
COZOMBEGIÓO A=86 B=0000 D=8008 H=9146 S=0166 P=0183 MYI H,61 A
COZOMBEGIO A=00 B=0000 D=B000 H=G146 S=0186 P=01A5 LXI H, 6147 ¿y
COZAMBEGIÓO A=00 B=B006 D=B0AN H=0147 S=014@6 P=B1aS MYI M,G@ A
CAZAMBEOIO A=09 B:0086 N=0000 H=0147 S=0100 P=G10A MOV A.M
COZOMBEUIO A=60 B=0008 D=0000 H=0147 S=0100 P:0105 CPI 853 „
C120MIEGIO A=200 B=00080 D=06080 H=0147 S=0180 P:B1aD JC 8119
CIZOMIEGIO A=40 E=0008 D=B000 H=6147 S=0100 P=8119 MOV E.A
CIZEMIEGIO A=80 B=0080 D=DO00 H=0147 S=0100 P=@11A MVI В, #0
CIZOMIEGIO A=88 B=0080 D=0000 H=0147 S=0190 P=O11C LXI H.0148
CIZOMIEGIO A=60 B=@000 D:0008 H=0148 S:0100 P=G11F DAD ED
COZOMIEGIO A=08 B=0008 10-0008 Н=0148 S=9109 P=01289 DAN D
QZAMIECIA A=06 B=G000 П-йй0й H=2142 S=018%A P=a1721 HOY CM
COZOMIEGIO A=80 B=80085 D=0006 H=8148 S=8186 P=El122 MOY В.С
COZOMÍEGIO A=05 B=6005 D=8008 H=6148 S=0108 P=6123 INX HH
COZBMIEVIO A=B5 B=0005 DU=B008 H=01439 S:=8100 P=G124 MOV B,M»D125
-L188
a)
0108 LXI H,B146 Automatic
92183 MYI mM.al wt
8165 LX] Н, 9147 breakpe
9198 MYI M.66
8108 MOV A,M Lok some code
2198 CPI 69
Bien JC 6119 from 100K
2118 LX] H,@e146
9113 MOV A.M
9114 ORA A
8115 JNZ 00168
“Lo
B118 RST @7 let wore
8119 HOV E.A
BILA MYI D,00
BLiC LXI H.,B148
- abovt Let wdlk rabart
-G, 1185 start Proyanı from
+9127 pr md au exderval interpt 7 Lroa tod one (progam wes
43 ot ch. loops Pra debe male y Loup нев)
curveut PC (125) and тиц. wn veal time —+o 18H
COZBaMBEOIO A=38 B=0064 D:=B006 H=0156 S=8168 P=0127 MOV D.A
COZOMBEGIO A=38 B=0064 D=3306 H=0156 S=0100 P=81723 МОУ A.B
COZAMBEDIA A=0B B=0064 D=3306 H=0156 S=91060 P=0129 INX H
COZAMBEGIAO A=0B E=0064 D=3806 H=6157 S=U100 P=B1ZA SEB Мжё12В
-Di4g .
LS dela (© Sated, but program does wi Step 0
6148 85 66 07 68 14 BO IE 086 ......
B150 32 80 64 68 64 VE 2C B1 ES 6: Di 89 DO 60 66 BG 2.D.D.... .
8160 48 060 00 90 06 DO UB VA 98 LU 00 06 88 BY BU VO 70
"67, return “to CP/M
DDT SORT. HEX
7 reload +ae memory imag
16K DOT YER 1.0
NEXT PC
815C PO
- ХР
P=9090 198) Set PC do besinnıng of Program
"LIEN, hat bad RCode
819GD JNE NELLA
6110 LXI H,8146
- Abort 1er wi Сорок
~A18D) assemble new opcode
kiop JC 119
a
9116
y |
-L160, list start sechon of program
9188 LXI H,8146
8183 MYI M,Bi
9195 LXI HH, 8147
9198 MYI M,B0
- Abovt list web rubsul ВЕ |
A103) chawe techn‘ tach oli tion $b oF
8183 MVI M, a,
9195)
-^ С returu + CP/M witha etl-c (GA wovks as well)
SAYE 1 SORT.COM Save 1 роде (256 bytes, From. 41004 do 1FFH) on disk 14 Case
we have Yo veload {ater
A>DDT SORT. COM, restort DPT we
Saved memo y um ane
16K DDT YER 1,6
NEXT PC - .
0200 BIOG COM" file always starts with address | OOH
75) rua the Proyrava Lom PC=100H
-D148
„sr dat proper a <orted
148 BS 00 67 08 14 88 1Е 66%.
8156 32 66 64 dB É4 BO 2C 21 ES 83 81 88 Ye 90 VO YO CT D.D..,. .. ..
BIEN BU bo AY 08 YB BY VU UN OY Sa bo bw ON GB DA VO
9178 DE 409 BU da AB DB VB 96 98 ИВ 98 EB DY HA VB VÖ
- СЁ, returu do CP/M
21
ED SORT. ASH, make chanaes A on gina program
cH-2 , ‘Ç
on. oldu, Load wat Hi"
MYI M. 8 ¡1 = 6
* up one me, = text
Н.Т ¿ADDRESS INVENX
¥ =) up another ie
MY] М, 1 ¡SET TU 1 FOR FIRST ITERATION
+КТ, Al We Grd {ype wad line
LXI | H, 1 iAUDRESS INDEX
* 1) ivatrt ww {ine
MY М. В ¡ZERO 54
*
LXI H, 1 ¡ADDRESS INDEX
«NUNCE ZOT,
INC*To
CONT ¿CONTINUE IF I <= (0N-2)
*-2D1CC26L 1,
JC CONT ¡CONTINUE IF I <= (N-2)
*Е ute from dish
у [ebd dıst A
ASM SORT. AR 125 y er file
CP/M ASSEMBLER - VER 1.0
8150 Wat addvecs lo asseudle
aUZH USE FACTOR
END OF ASSEMBLY
ODT SORT. HEX, test proj Clarges
16K DDT VER 1.0
NEXT PC
G15C BABE
76160)
«uilëg
-D148)
ков осей
9148 BS 86 97 08 14 90 1E 66
8158 32 88 64 98 64 BB 2C Bl ES 93 01 88 8% 8B 90 BA .Z2 D.D..... . .....
Ble YE EY VE BO CU BD 49 ABN YD AN YUU ES BY 08 986 HE
- abat with rub
766) relura ТО ее (к. - Prayaux Checks OL.
22.
">
/
Завантажити
Просто дружнє нагадування. Ви можете переглянути документ прямо тут. Але найголовніше, наш штучний інтелект вже прочитав його. Він може пояснити складні речі простими словами, відповісти на ваші запитання будь-якою мовою та допомогти вам швидко орієнтуватися навіть у найдовших або найскладніших документах.
Реклама