Concurrent_CPM 86_Programmers_Utilities_Mar83 Concurrent CPM 86 Programmers Utilities Mar83

Concurrent_CPM-86_Programmers_Utilities_Mar83 Concurrent_CPM-86_Programmers_Utilities_Mar83

User Manual: Concurrent_CPM-86_Programmers_Utilities_Mar83

Open the PDF directly: View PDF PDF.
Page Count: 147

DownloadConcurrent_CPM-86_Programmers_Utilities_Mar83 Concurrent CPM-86 Programmers Utilities Mar83
Open PDF In BrowserView PDF
Concurrent CP /M-86™
Operating System

'

Programmer's Utilities Guide

[!ill

DIGITAL

RESfARCHTM

Concurrent CP /M-86 ™
Operating System

Programmer's Utilities Guide

COPYRIGHT
Copyright © 1983 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, 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.

TRADEMARKS
CP/M is a registered trademark of Digital Research. ASM-86, Concurrent CP/M-86,
DDT-86, and MAC are trademarks of Digital Research. Intel is a registered trademark
of Intel Corporation. MCS-86 is a trademark of Intel Corporation. Z80 is a registered
trademark of Zilog, Inc. IBM Personal Computer is a tradename of International
Business Machines.
The Concurrent CP/M-86 Programmer's Utilities Guide was prepared using the
Digital Research TEX Text Formatter and printed in the United States of America.

First Edition: March 1983

Foreword
The Concurrent CPIM-86™ Programmer's Utilities Guide documents the 8088 and
8086 assembly language instruction set, rules for use of the Digital Research ASM-86™
assembler, and rules for use of the Digital Research dynamic debugging tool, DDT-86 ™.
Section 1 contains an introduction to the Digital Research assembler, ASM-86, and
the various options that can be used with it. Through one of these options, ASM-86 can
generate 8086 machine code in either Intel ® or Digital Research format. Appendix A
describes these formats.
Section 2 discusses the elements of ASM-86 assembly language. It defines the ASM-86
character set, constants, variables, identifiers, operators, expressions, and statements.
Section 3 describes the ASM-86 housekeeping functions, such as conditional assembly, multiple source file inclusion, and control of the listing printout format.
Section 4 summarizes the 8086 instruction mnemonics accepted by ASM-86. These
mnemonics are the same as those used by the Intel assembler, except for four instructions:
the intrasegment short jump, intersegment jump, return, and call instructions. Appendix B
summarizes these differences.
Section 5 discusses the Code-macro facilities of ASM-86, including Code-macro
definition, specifiers, and modifiers, and nine special Code-macro directives. This information is also summarized in Appendix G.
Section 6 discusses DDT-86, the Dynamic Debugging Tool that allows the user to
test- and debug programs in the 8086 environment. The section includes a sample
debugging section.

iii

Concurrent CP/M-86 is supported and documented through four manuals:
• The Concurrent CPIM-86 User's Guide documents the user's interface to Concurrent CP/M-86, explaining the various features used to execute applications
programs and Digital Research utility programs.
• The Concurrent CPIM-86 Programmer's Reference Guide documents the applications programmer's interface to Concurrent CP/M-86, explaining the internal
file structure and system entry points, information essential to create applications
programs that run in the Concurrent CP/M-86 environment.
• The Concurrent CPIM-86 Programmer's Utilities Guide documents the Digital
Research utility programs programmers use to write, debug, and verify applications programs written for the Concurrent CP/M-86 environment.
• The Concurrent CPIM-86 System Guide documents the internal, hardwaredependent structures of Concurrent CP/M-86.

iv

T able of Contents
1 Introduction to ASM-S6
1.1 Assembler Operation . . . . .
1.2 Optional Run-time Parameters
1.3 Ending ASM -86 . . . . . . . . .
2

Elements of ASM-S6 Assembly Language
2.1 ASM-S6 Character Set
2.2 Tokens and Separators
2.3 Delimiters · .... · .
2.4 Constants
· .....
2.4.1 Numeric Constants
2.4.2 Character Strings
2.5 Identifiers
· ..... ..
2.5.1 Keywords .. · ..
2.5.2 Symbols and Their Attributes
2.6 Operators
· .... · .
2.6.1 Operator Examples
2.6.2 Operator Precedence
2.7 Expressions
.....
2.S Statements . · . ......

3

1-1
1-4
1-5

.....

......

.....

2-1
· . 2-1
· . 2-1
· 2-3
· . 2-3
· . 2-4
· 2-4
· . 2-5
· . 2-6
· . 2-8
2-12
2-14
2-16
2-16

Assembler Directives
3.1 Introduction . . . . . . . .
3.2 Segment Start Directives .. .
3.2.1 The CSEG Directive
3.2.2 The DSEG Directive
3.2.3 The SSEG Directive
3.2.4 The ESEG Directive
3.3 The ORG Directive . . . . .
3.4 The IF and END IF Directives
3.5 The INCLUDE Directive
3.6 The END Directive
3.7 The EQU Directive
3.S The DB Directive
3.9 The DW Directive
3.10 The DD Directive

· .
·
·
· .
· .
·
· .
....
·
.......
· .
.......
v

3-1
3-1
3-2
3-2
3-3
3-3
3-4
3-4
3-5
3-5
3-5
3-6
3-7
3-S

Table of Contents
3.11
3.12
3.13
3.14
3.15
3.16
3.17
3.18
3.19
3.20

(continued)

The RS Directive
The RB Directive
The RW Directive
The TITLE Directive
The PAGESIZE Directive
The PAGEWIDTH Directive
The EJECT Directive . . . .
The SIMFORM Directive .. .
The NO LIST and LIST Directives
The IFLIST and NOIFLIST Directives

· 3-8
. . . 3-9
. . . . 3-9
· 3-9
3-10
. . . . . . 3-10
. . . . . 3-10
3-10
3-11
3-11

4 The ASM-86 Instruction Set
4.1
4.2
4.3
4.4
4.5
4.6
4.7

Introduction . . . . . . . . . . . . . . . .
Data Transfer Instructions . . . . . . . . .
Arithmetic, Logical, and Shift Instructions
String Instructions . . . . . . .
Control Transfer Instructions . . .
Processor Control Instructions
Mnemonic Differences . . . . .

. . . . 4-1
. . . 4-3
· . 4-5
4-10
4-12
. . . . . 4-16
4-18

5 Code-macro Facilities
5.1
5.2
5.3
5.4
5.5

Introduction to Code-macros
Specifiers
Modifiers . . . . . . . .
Range Specifiers . . . . .
Code-macro Directives
5.5.1 SEGFIX ..
5.5.2 NOSEGFIX . . .
5.5.3 MODRM . . . .
5.5.4 RELB and RELW
5.5.5 DB, DWand DD
5.5.6 DBIT . . . . . .

· 5-1
· . 5-2
· . 5-4
· . 5-4
5-5
· 5-5
· 5-5
· . 5-6
· 5-7
· 5-8
· . 5-8

vi

Table of Contents (continued)
6 DDT-86
. . . . . . . . . . . . . . 6-1
DDT-86 Operation . . . . . . . . . . .
6.1.1 Starting DDT-86 . . . . . . . .
· . . . .
. . 6-1
6.1.2 DDT-86 Command Conventions
· . 6-1
6.1.3 Specifying a 20-Bit Address .. .
· . 6-3
. . . . . 6-3
6.1.4 Terminating DDT-86 . . . . . .
6.1.5 DDT-86 Operation with Interrupts
· . . . . . . . . . 6-3
6.2 DDT-86 Commands . . . . . . . . . . .
· . 6-4
6.2.1 The A (Assemble) Command . . . .
· . 6-4
. . . 6-4
6.2.2 The B (Block Compare) Command
6.2.3 The D (Display) Command . . . .
· . 6-5
. 6-6
6.2.4 The E (Load for Execution) Command
6.2.5 The F (Fill) Command . . . . . . . . . .
. 6-6
. . . . . . . . . 6-7
6.2.6 The G (Go) Command . . . . . . . .
6.2.7 The H (Hexadecimal Math) Command
. . . 6-8
. . . . . 6-8
6.2.8 The I (Input Command Tail) Command
. . . . 6-8
6.2.9 The L (List) Command . . . . . . . .
6.2.10 The M (Move) Command . . . . . . . .
· . 6-9
6.2.11 The QI, QO (Query 110) Commands
· . . . . . . . . . 6-9
6.2.12 The R (Read) Command
6-10
6.2.13 The S (Set) Command . . . .
. . . . . . . . . . . . . . . 6-11
6.2.14 The SR (Search) Command
6-12
6.2.15 The T (Trace) Command ..
6-12
6.2.16 The U (Untrace) Command
6-13
6.2.17 The V (Value) Command ..
6-13
6.2.18 The W (Write) Command ..
6-14
6.2.19 The X (Examine CPU State) Command
. . . . . 6-14
6-16
6.3 Default Segment Values . . . . . . . . . . . . . . . .
6-18
6.4 Assembly Language Syntax for A and L Commands
6.5 DDT-86 Sample Session . . . . . . . . . . . . . . . .
6-19
6.1

vii

Table of Contents (continued)
Appendixes
A Starting ASM-86 . • . . .

. . • . • . A-1

B

Mnemonic Differences from the Intel Assembler • • .

. .•.•• B-1

C

ASM-86 Hexadecimal Output Format . . . . • . . •

.•.•• C-1

D Reserved Words. . . . . . . . . . . . • . . . • . . • • . . • . .

. . • • D-1

E

ASM-86 Instruction Summary •.

. . • • E-1

F

Sample Program APPF.A86 . . . . . • . . . . • . . •

• . . • F-1

G Code-macro Definition Syntax • . • • . . . . • • • .

• • . . . . . • . • G-1

. • • . • • . . • • .

H ASM-86 Error Messages . . • . . . . . . . . • . . • . . . . . • . . • . • . H-1
I

DDT-86 Error Messages .. . . . • . . . • . • . . • . . . . . . . • . . • . 1-1

viii

Table of Contents (continued)
Tables
1-1.
1-2.

Run-time Parameter Summary
Run-time Parameter Examples

1-4
1-5

2-1. Separators and Delimiters
2-2. Radix Indicators for Constants
2-3. String' Constant Examples
2-4. Register Keywords . . . . . .
2-5. ASM-86 Operators . . . . . .
. ... .
2-6. Precedence of Operations in ASM-86 . . . . .

· 2-2
· 2-3
· . 2-4
· . 2-6
· 2-9
2-15

4-1.
4-2.
4-3.
4-4.
4-5.
4-6.
4-7.
4-8.
4-9.
4-10.
4-11.

Operand Type Symbols ..
Flag Register Symbols
Data Transfer Instructions
Effects of Arithmetic Instructions on Flags
..... .
Arithmetic Instructions . ..
Logical and Spift Instruct{ons
String Instructions . . . . . .
Prefix Instructions . . . . .
Control Transfer Instructions
Processor Control Instructions
Mnemonic Differences .. . . . . . . . . .

· . . . . 4-1
· . . . . 4-3
· 4-3
· . . . . 4-5
· . 4-6
· . 4-8
4-10
4-12
4-13
4-16
4-18

5-1.
5-2.

Code-macro Operand Specifiers
Code-macro Operand Modifiers

· . 5-3
· . . . . 5-2

6-1.
6-2.
6-3.

DDT-86 Command Summary
Flag Name Abbreviations
DDT-86 Default Segment Values

· . 6-2
6-15
6-17

ix

Table of Contents

(continued)

Tables
A-1.
A-2.
A-3.
A-4.

Parameter Types and Devices
Parameter Types ..
Device Types . . . .
Invocation Examples

B-1.

Mnemonic Differences

· . . . B-1

. C-1.
C-2.
C-3.

Hexadecimal Record Contents
Hexadecimal Record Formats
Segment Record Types . . . .

.. C-1
· C-2
· . . . C-3

D-1.

Keywords or Reserved Words

.. D-1

E-1.

ASM-86 Instruction Summary

· . . . E-1

H-1.

ASM-86 Diagnostic Error Messages

1-1.

DDT-86 Error Messages .

·
...
·
·

A-1
A-2
A-2
A-3

H-1
· 1-1

Figure
1-1. ASM-86 Source and Object Files . . . . . . . . . . . . . . . . . . . . 1-1

Listing
F-1.

Sample Program APPF.A86

. . . . . . . . . . . . . . . F-1

x

Section 1
Introduction to ASM-86
1.1

Assembler Operation

ASM-86 processes an 8086 assembly language source file in three passes and produces
three output files, including an 8086 machine language file in hexadecimal format. This
object file can be in either Intel or Digital Research hex formats, which are described in
Appendix C. ASM-86 is shipped in two forms: an 8086 cross-assembler designed to run
under CP/M® on the Intel 8080 or the Zilog Z80® based system, and an 8086 assembler
designed to run under Concurrent CP/M-86 on an Intel 8086 or 8088 based system.
ASM-86 typically produces three output files from one input file as shown in Figure 1-1:

I SOURCE I •

ASM-86

... 1
- 1

LIST FILE

I

:I

HEX FILE

I

'" 1 SYMBOL FILE
- 1

I

filename.A86 - contains source
filename.LST - contains listing
filename.H86 - contains assembled program in
hexadecimal format
filename.sYM - contains all user-defined symbols
Figure 1-1. ASM-86 Source and Object Files

[QJ DIGITAL RESEARCH'" - - - - - - - - - - - - - - - - - - - - - - - -

1-1

1.1 Assember Operation

Concurrent CP/M-86 Utilities Guide

Figure 1-1 also lists ASM-S6 filetypes. ASM-S6 accepts a source file with any threeletter extension, but if the filetype is omitted from the starting command, ASM-86 looks
for the specified filename with the filetype .AS6 in the directory. If the file has a filetype
other than .AS6 or has no filetype at all, ASM-S6 returns an error message.
The other filetypes listed in Figure 1-1 identify ASM-S6 output files. The .LST file
contains the assembly language listing with any error messages. The .HS6 file contains
the machine language program in either Digital Research or Intel hexadecimal format.
The .SYM file lists any user-defined symbols.
Start ASM-S6 by entering a command of the following form:
ASMS 6 source filespec [ $ parameters ]
Section 1.2 explains the optional parameters. Specify the source file using the following form:
[d:] filename [.type]
where
[d:]

is an optional valid drive letter specifying the source file's location.
Not needed if source is on current drive.

filename

is a valid CP/M filename of 1 to S characters.

[.type]

is an optional valid filetype of 1 to 3 characters (usually .AS6).

Some examples of valid ASM-S6 commands are

A)ASHBS 6:610588
I OS88 A8S $F I AA H6 P6
A)ASH8S D:TE5T

A )ASH8S 6

f

S6

Note that if you try to assemble an empty source file, ASM-S6 generates empty list, hex,
and symbol files.

- - - - - - - - - - - - - - - - - - - - - - - - - I ! Q J DIGITAL RESEARCH
1-2

TIl

Concurrent CP/M-86 Utilities Guide

1.1 Assember Operation

Once invoked, ASM-86 responds with the message:
CP/M 8086 ASSEMBLER VER X.x
where x.x is the ASM-86 version number. ASM-86 then attempts to open the source
file. If the file does not exist on the designated drive or does not have the correct filetype
as described above, the assembler displays the message:
NO FILE

If an invalid parameter is given in the optional parameter list, ASM-86 displays the
message:
PARAMETER ERROR

After opening the source, the assembler creates the output files. Usually these are
placed on the current disk drive, but they can be redirected by optional parameters or
by a drive specification in the source filename. In the latter case, ASM-86 directs the
output files to the drive specified in the source filename.
During assembly, ASM-86 halts if an error condition, such as disk full or symbol table
overflow, is detected. When ASM-86 detects an error in the source file, it places an
error-message line in the listing file in front of the line containing the error. Each error
message has a number and gives a brief explanation of the error. Appendix H lists
ASM-86 error messages. When the assembly is complete, ASM-86 displays the message:
END OF ASSEMBLY. NUMBER OF ERRORS: n

Ii]]

DIGITAL RESEARCH'" - - - - - - - - - - - - - - - - - - - - - - - - -

1-3

1.2 Optional Run-time Parameters

Concurrent CP/M-86 Utilities Guide

1.2 Optional Run-time Parameters
The dollar-sign character, $, flags an optional string of run-time parameters. A parameter is a single letter followed by a single-letter device name specification. Table 1-1 lists
the parameters.

Table 1-1. Run-time Parameter Summary
Parameter
A

H
P
S
F

I

To Specify

source file device
hex output file device
list file device
symbol file device
format of hex output file

I

Valid Arguments
A,B,C, ... P
A ... P,X, Y,Z
A ... P,X, Y,Z
A ... P,X, Y,Z
I,D

All parameters are optional and can be entered in the command line in any order.
Enter the dollar sign only once at the beginning of the parameter string. Spaces can
separate parameters but are not required. No space is permitted, however, between a
parameter and its device name.
A device name must follow parameters A, H, P, and S. The devices are labeled

A, B, C, ... P or X, Y, Z
Device names A through P, respectively, specify disk drives A through P. X specifies
the user console (CON:), Y specifies the line printer (LST:), and Z suppresses output
(NUL:).

If output is directed to the console, it can be temporarily stopped at any time by
entering a CTRL-S. Restart the output by entering a second CTRL-S or any other
character.

- - - - - - - - - - - - - - - - - - - - - - - - - I!ID DIGITALRESEARCHnI

1-4

1.2 Optional Run-time Parameters

Concurrent CP/M-86 Utilities Guide

The F parameter requires either an I or a D argument. When I is specified, ASM-86
produces an object file in Intel hex format. A D argument requests Digital Research hex
format. Appendix C details these formats. If the F parameter is not entered in the
command line, ASM-86 produces Digital Research hex format.

Table 1-2. Run-time Parameter Examples
Command Line

I

Result

ASM88 IO

Assemble file IO.A86, and produce IO.H86,
IO.LST, and IO.SYM, all on the default drive.

ASM88 IO. ASM $ AD SZ

Assemble file IO.ASM on device D, and produce
IO.LST and IO.H86. No symbol file.

ASM88 IO $ PY S}-{

Assemble file IO.A86, produce IO.H86, route
listing directly to printer, and output symbols on
console.

ASM88 IO $ FD

Produce Digital Research hex format.

ASM88 IO $ F I

Produce Intel hex format.

1.3

Ending ASM-86

You can halt ASM-86 execution at any time by pressing any key on the console
keyboard. When a key is pressed, ASM-86 responds with the question:
USER BREAK. OK(Y/N)?

A Y response stops the assembly and returns to the operating system. An N response
continues the assembly.

End of Section 1

i!IDDIGITAL RESEARCH'" - - - - - - - - - - - - - - - - - - - - - - - - -

1-5

Section 2
Elements of ASM-86 Assembly Language
2.1

ASM-86 Character Set

ASM-86 recognizes a subset of the ASCII character set. The valid characters are the
alphanumerics, special characters, and nonprinting characters shown below:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abc d e f g h
j kim n 0 p q r s t u v w x y z
o 1 2 3 4 5 678 9
+-*/= ()[];'.!,_:@$

space, tab, carriage return, and line-feed
Lower-case letters are treated as upper-case, except within strings. Only
alphanumerics, special characters, and spaces can appear in a string.

2.2

Tokens and Separators

A token is the smallest meaningful unit of an ASM-86 source program, much as a
word is the smallest meaningful unit of an English composition. Adjacent tokens are
commonly separated by a blank character or space. Any sequence of spaces can appear
wherever a single space is allowed. ASM-86 recognizes horizontal tabs as separators and
interprets them as spaces. Tabs are expanded to spaces in the list file. The tab stops are
at each eighth column.

2.3

Delimiters

Delimiters mark the end of a token and add special meaning to the instruction, as
opposed to separators, which merely mark the end of a token. When a delimiter is
present, separators need not be used. However, using separators after delimiters makes
your program easier to read.
The following table, Table 2-1, describes ASM-86 separators and delimiters. Some
delimiters are also operators and are explained in greater detail in Section 2.6.
!!ill DIGITAL RESEARCH TW

- - - - - - - - - - - - - - - - - - - - - - - - - -

2-1

2.3 Delimiters

Concurrent CP/M-86 Utilities Guide

Table 2-1.
Character

I

Separators and Delimiters
Name

20H

space

09H

tab

CR

carriage return

LF

line-feed

semicolon

Use

I
separator

legal in source files,
expanded in list files
terminate source lines
legal after CR if within
source lines, interpreted
as a space
starts comment field

colon

identifies a label,
used in segment override
specification

period

forms variables from
numbers ..

$

dollar sign

+

plus

arithmetic operator for
addition

minus

arithmetic operator for
subtraction

*

asterisk

arithmetic operator for
multiplication

/

slash

arithmetic operator for
division

@

"at" sign

legal in identifiers

underscore

legal in identifiers

exclamation
point

logically terminates a
statement, allowing
multiple statements on a
single source line

apostrophe

delimits string constants

notation for present value
oflocation pointer

- - - - - - - - - - - - - - - - - - - - - - - - - - - ! l I D DIGITAL RESEARCH'"
2-2

2.4 Constants

Concurrent CP/M-86 Utilities Guide

2.4

Constants

A constant is a value known at assembly time that does not change while the assembled
program is executed. A constant can be either' an integer or a character string.
2.4.1

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 shown
in Table 2-2:

Table 2-2.
Indicator

B
0
Q
D
H

Radix Indicators for Constants

I

Constant Type

binary
octal
octal
decimal
hexadecimal

I

Base

2
8
8
10
16

ASM-86 assumes that any numeric constant not terminated with a radix indicator is
a decimal constant. Radix indicators can be upper- or lower-case.
A constant is thus a sequence of digits followed by an optional radix indicator, where
the digits are in the range for the radix. Binary constants must be composed of Os and
ls. Octal digits range from 0 to 7; decimal digits range from 0 to 9. Hexadecimal
constants contain decimal digits and the hexadecimal digits A (10D), B (llD), C (12D),
D (13D), E (14D), and F (15D). Notethatthe leadingcharacterofa hexadecimal constant
must be a decimal digit, so that ASM-86 cannot confuse a hex constant with an identifier.
The following are valid numeric constants:

1234
1234H
33770

[!ID

12340
OFFEH
OFE3H

1100B
33770
1234d

1111000011110000B
13772Q
Offffh

DIGITAL RESEARCH'" - - - - - - - - - - - - - - - - - - - - - - - - - -

2-3

Concurrent CP/M-86 Utilities Guide

2.4 Constants

2.4.2

Character Strings

ASM-86 treats an ASCII character string delimited by apostrophes as a string constant.
All instructions accept only one- or two-character constants as valid arguments. Instructions treat a one-character string as a 8-bit number. A two-character string is treated as
a 16-bit number with the value of the second character in the low-order byte, and the
value of the first character in the high-order byte.
The numeric value of a character is its ASCII code. ASM-86 does not translate case
in character strings, so it accepts both upper- and lower-case letters. Note that only
alphanumerics, special characters, and spaces are allowed in strings.
A DB assembler directive is the only ASM-86 statement that can contain strings longer
than two characters. The string cannot exceed 255 bytes. Include any apostrophe you
want printed in the string by entering it twice. ASM-86 interprets the two keystrokes" as
a single apostrophe. Table 2-3 shows valid strings and how they appear after processing:

Table 2-3.

String Constant Examples

String in Source Text

I AfterProcessingbyASM-86

,a '

a

'Ab"Cd'

Ab'Cd

,,,,

'ONLYUPPERCASE'

ONLY UPPERCASE

'onlYJowercase'

only lower case

2.5 Identifiers
Identifiers are character sequences that have special symbolic meaning to the assembler. All identifiers in ASM-86 must obey the following rules:

1. The first character must be alphabetic (A, ... Z, a, ... z).
2. Any subsequent characters can be either alphabetic or a numeral (0,1, ..... 9).
ASM-86 ignores the special characters @ and _ but they are still legal. For
example,  b,
otherwise 0

a, b = unsigned
number

a GE b

returns 0 FFFFH if a > = b
otherwise 0

a, b = unsigned
number

a NE b

returns OFFFFH if a < > b,
otherwise 0

a, b = unsigned
number

~DIGITAL~EARCH~-------------------------------------------------

2-9

2.6 Operators

Concurrent CP/M-86 Utilities Guide

Table 2-5.

Syntax

(continued)

Result

1

I

Validity

Arithmetic Operators
a+b

arithmetic sum of a and b

a = variable,
label or number
b = number

a-b

arithmetic difference of
aandb

a = variable,
label or number
b = number

a"'b

does unsigned multiplication
ofaandb

a,b = number

alb

does unsigned division of a
andb

a,b = number

a MOD b

returns remainder of a I b

a, b = number

a SHL b

returns the value which
results from shifting a to
left by an amount b

a,b = number

a SHR b

returns the value which
results from shifting a to
the right by an amount b

a,b = number

+a

gives a

a = number

-a

givesO-a

a = number

Segment Override
:


overrides assembler's choice
of segment register.

 =
CS,DS,SS
orES

- - - - - - - - - - - - - - - - - - - - - - - - - - [lID

2-10

DIGITAL RESEARCH'"

Concurrent CP/M-86 Utilities Guide

2.6 Operators

Table 2-5.

Syntax

I

(continued)

Result

I

Validity

Variable Manipulators, Creators
SEG a

creates a number whose value is the
segment value of the variable or
label a. The variable or label
must be declared in an absolute
segment (i.e. CSEG 1234H);
otherwise the SEG operator is
undefined.

a = label Ivariable

OFFSET a

creates a number whose value
is the offset value of the
variable or label a.

.a = label Ivariable

TYPE a

creates a number. Ifthevariableais of type BYTE, WORD
or DWORD, the value of the numberis 1,2, or4, respectively.

a = label Ivariable

LENGTH a

creates a number whose value
is the length attribute of the
variable a. The length attribute
is the number of bytes associated
with the variable.

a = label Ivariable

LAST a

if LENGTH a > 0, then LAST
a = LENGTH a-1;ifLENGTH
a = 0, then LAST a = 0.

a = label Ivariable

a PTR b

creates virtual variable or label with
type of a and attributes of b.

a = BYTE I
WORD, IDWORD
b = 

.a

creates variable with an offset attribute of a; segment attribute is
current segment.

a = number

$

creates label with offset
equal to current value of
location counter; segment
attribute is current segment.

no argument

~DIGITAL~EARCH~--------------------------------------------------------------------------

2-11

2.6 Operators

2.6.1

Concurrent CP/M-86 Utilities Guide

Operator Examples

Logical operators accept only numbers as operands. They perform the Boolean logic
operations AND, OR, XOR, and NOT. For example,

OOFC
0080
0000 B180
0002 B003

MASK
SIGNBIT

EQU
EQU
MOV
MOl.'

OFCH
80H
CL ,MASK AND SIGNBIT
AL , NOT MASK

Relational operators treat all operands as unsigned numbers. The relational operators
are EQ (equal), LT (less than), LE (less than or equal), GT (greater than), GE (greater
than or equal), and NE (not equal). Each operator compares two operands and returns
all ones (OFFFFH) if the specified relation is true, and all zeros if it is not. For example,

000 A
0018

LIMIT1
LIMIT2

0004 B8FFFF
0007 B80000

EQU
EQU

10
25

MOV
MOl.'

A>{ ,LIMIT1 LT LIMIT2
A>{ ,LIMIT1 GT LIMIT2

Addition and subtraction operators compute the arithmetic sum and difference of two
operands. The first operand can be a variable, label, or number, but the second operand
must be a number. When a number is added to a variable or label, the result is a variable
or label, the offset of which is the numeric value of the second operand plus the offset
of the first operand. Subtraction from a variable or label returns a variable or label, the
offset of which is that of first operand decremented by the number specified in the second
operand. For example,

0002
0005
OOOA FF

0006 2EAOOBOO
OOOF 2E8AOEOFOO
0014 B303

COUNT
DISP1
FLAG

EQU
EQU
DB

2
5

MOV
MOV
MOV

AL,FLAG+1
CL,FLAG+DISPl
BL,DISP1-COUNT

OFFH

- - - - - - - - - - - - - - - - - - - - - - - - [j]]

2-12

DIGITAL RESEARCH'"

Concurrent CP/M-86 Utilities Guide

2.6 Operators

The multiplication and division operators *, /, MOD, SHL, and SHR accept only
numbers as operands. ,~ and / treat all operands as unsigned numbers. For example,
MOI.1
MOI.1

0018 6E5500
0019 6310
0050
016 68AOOO

6UFFER81ZE
MOI.1

81 t2S8/3
BLt8Ll/4

EQU
80
AXtBUFFER81ZE

*

2

Unary operators accept both signed and unsigned operators, as shown in the following
example:
.
CLt+35
ALt2--S
DLt-12

001E 6123
0020 6007
0022 62F4

When manipulating variables, the assembler decides which segment register to use.
You can override the assembler's choice by specifying a different register with the
segment override operator. The syntax for the override operator is
 : 
where the is CS, DS, SS, or ES. For example, 0024 3886472D 0028 28860E5600 AXt88:WORD6UFFER[BXJ C)-{ tE8: ARRAY A variable manipulator creates a number equal to one attribute of its variable operand. SEG extracts the variable's segment value; OFFSET, its offset value; TYPE, its type value (1, 2, or 4); and LENGTH, the number of bytes associated with the variable. LAST compares the variable's LENGTH with 0 and, if greater, then decrements LENGTH by one. If LENGTH equals 0, LAST leaves it unchanged. Variable manipulators accept only variables as operators. For example, I!ID DIGITAL RESEARCH TN - - - - - - - - - - - - - - - - - - - - - - - - - 2-13 2.6 Operators 1234 002D 000000000000 0033 0102030405 0038 003B 003E 0041 0044 B80500 B80400 B80100 B80200 B83412 Concurrent CP/M-86 Utilities Guide WORDBUFFER BUFFER Mol,1 MOl) Mol,1 Mol,1 Mol,1 DSEG DW DB A}-{ A}-{ A}-{ A}-{ A}-{ 1234H OtOtO lt2t3t4t5 t LENGTH BUFFER t LAST BUFFER t TYPE BUFFER t TYPE WORDBUFFER t SEG BUFFER The PTR operator creates a virtual variable or label that is valid only during the execution of the instruction. It makes no changes to either of its operands. The temporary symbol has the same Type attribute as the left operator and all other attributes of the right operator as shown in the following example: 0044 C80705 0047 8A07 0048 FF04 BYTE PTR [BX] t 5 AL tBYTE PTR [B}-{] WORD PTR [SI] The period operator creates a variable in the current data segment. The new variable has a segment attribute equal to the current data segment and an offset attribute equal to its operand. The operand of the new variable must be a number. For example, 004B A10000 004E 288B1E0040 A}-{ t .0 B}-{ t ES: .4000H The dollar-sign operator, $, creates a label with an offset attribute equal to the current value of the location counter. The label's segment value is the same as the current segment. This operator takes no operand. For example, 0053 E8FDFF 0058 EBFE 0058 E8FD2F JMP JMPS JMP $ $ $+3000H 2.6.2 Operator Precedence Expressions combine variables, labels, or numbers with operators. ASM-86 allows several kinds of expressions. See Section 2.7. This section defines the order in which operations are executed if more than one operator appears in an expression. - - - - - - - - - - - - - - - - - - - - - - - - - i!IDDIGITAL RESEARCH™ 2-14 Concurrent CP/M-86 Utilities Guide 2.6 Operators ASM-86 evaluates expressions left to right, but operators with higher precedence are evaluated before operators with lower precedence. When two operators have equal precedence, the leftmost is evaluated first. Table 2-6 presents ASM-86 operators in order of increasing precedence. Parentheses can override rules of precedence. The part of an expression enclosed in parentheses is evaluated first. If parentheses are nested, the innermost expressions are evaluated first. Only five levels of nested parentheses are legal. For example, 15/3 + 18/8 = 5 + 2 = 7 15/ (3 + 18/8) = 15/ (3 + 2) = 15/5 = 3 Table 2-6. Order I Precedence of Operations in ASM-86 Operator Type I Operators 1 Logical XOR,OR 2 Logical AND 3 Logical NOT 4 Relational EQ,LT,LE,GT, GE,NE 5 Addition/subtraction +,- 6 Multiplication/division *, /, MOD, SHL, SHR [!Q) 7 Unary +,- 8 Segment override < segment override>: 9 Variable manipulators, SEG, OFFSET, PTR, creators TYPE, LENGTH, LAST 10 Parentheses/brackets (), [] 11 Period and Dollar .,$ DIGITAL RESEARCH'" - - - - - - - - - - - - - - - - - - - - - - - - - - 2-15 2.7 Expressions 2.7 Concurrent CP/M-86 Utilities Guide Expressions ASM-86 allows address, numeric, and bracketed expressions. An address expression evaluates to a memory address and has three components: • segment value • offset value • type Both variables and labels are address expressions. An address expression is not a number, hut its components are numbers. Numbers can be combined with operators such as PTR to make an address expression. A numeric expression evaluates to a number. It does not contain any variables or labels, only numbers and operands. Bracketed expressions specify base- and index-addressing modes. The base registers are BX and BP, and the index registers are DI and SI. A bracketed expression can consist of a base register, an index register, or both a base register and an index register. Use the + operator between a base register and an index register to specify both base- and index-register addressing. For example, MOV MOl.! 2.8 A}-{ , [B}-{+D I J A}-{,[SIJ Statements Just as tokens in this assembly language correspond to words in English, statements are analogous to sentences. A statement tells ASM-86 what action to perform. Statements can be instructions or directives. Instructions are translated by the assembler into 8086 machine language instructions. Directives are not translated into machine code, but instead direct the assembler to perform certain clerical functions. Terminate each assembly language statement with a carriage return, CR, and line-feed, LF, or with an exclamation point, !. ASM-86 treats these as an end-of-line. Multiple assembly language statements can be written on the same physical line if separated by exclamation points. - - - - - - - - - - - - - - - - - - - - - - - - - - - I ! I D DIGITAL RESEARCH'" 2-16 Concurrent CP/M-86 Utilities Guide 2.8 Statements The ASM-86 instruction set is defined in Section 4. The syntax for an instruction statement is [label:] [prefix] mnemonic [ operand(s)] [;comment] where the fields are defined as • label A symbol followed by : defines a label at the current value of the location counter in the current segment. This field is optional. • prefix Certain machine instructions such as LOCK and REP can prefix other instructions. This field is optional. • mnemonic A symbol defined as a machine instruction, either by the assembler or by an EQU directive. This field is optional unless preceded by a prefix instruction. If it is omitted, no operands can be present, although the other fields can appear. ASM-86 mnemonics are defined in Section 4. • operands An instruction mnemonic can require other symbols to represent operands to the instruction. Instructions can have zero, one, or two operands. • comment Any semicolon appearing outside a character string begins a comment. A comment ends with a carriage return. Comments improve the readability of programs. This field is optional. I .. [j] DIGITAL RESEARCH .... - - - - - - - - - - - - - - - - - - - - - - - - - - - 2-17 2.8 Statements Concurrent CP/M-86 Utilities Guide ASM-86 directives are described in Section 3. The syntax for a directive statement is [name] directive operand(s) [;comment] where the fields are defined as • name • directive • operands • comment Unlike the label field of an instruction, the name field of a directive is never terminated with a colon. Directive names are legal only for DB, DW, DD, RB, RS, RW, and EQU. For DB, DW, DD, and RS, the name is optional; for EQU, it is required. One of the directive keywords defined in Section 3. Analogous to the operands for instruction mnemonics. Some directives, such as DB, DW, and DD, allow any operand; others have special requirements. Exactly as defined for instruction statements. End of Section 2 - - - - - - - - - - - - - - - - - - - - - - - - - - I ! I D D I G I T A L R E S E A R C HTII 2-18 Section 3 Assembler Directives 3.1 Introduction Directive statements cause ASM-S6 to perform housekeeping functions, such as assigning portions of code to logical segments, requesting conditional assembly, defining data items, and specifying listing file format. General syntax for directive statements appears in Section 2.S. In the sections that follow, the specific syntax for each directive statement is given under the heading and before the explanation. These syntax lines use special symbols to represent possible arguments and other alternatives. Square brackets, [], enclose optional arguments. 3.2 Segment Start Directives At run-time, every SOS6 memory reference must have a 16-bit segment base value and a 16-bit offset value. These are combined to produce the 20-bit effective address needed by the CPU to physically address the location. The 16-bit segment base value or boundary is contained in one of the segment registers CS, DS, SS, or ES. The offset value gives the offset of the memory reference from the segment boundary. A 16-byte physical segment is the smallest relocatable unit of memory. ASM-S6 predefines four logical segments: the Code Segment, Data Segment, Stack Segment, and Extra Segments, which are addressed respectively by the CS, DS, SS, and ES registers. Future versions of ASM-S6 will support additional segments, such as multiple data or code segments. All ASM-S6 statements must be assigned to one of the four currently supported segments so that they can be referenced by the CPU. A segment directive statement, CSEG, DSEG, SSEG, or ESEG, specifies that the statements following it belong to a specific segment. The statements are then addressed by the corresponding segment register. ASM-S6 assigns statements to the specified segment until it encounters another segment directive. I!ID DIGITAL RESEARCH™ - - - - - - - - - - - - - - - - - - - - - - - - - - 3-1 3.2 Segment Start Directives Concurrent CP/M-86 Utilities Guide Instruction statements must be assigned to the Code Segment. Directive statements can be assigned to any segment. ASM-86 uses these assignments to change from one segment register to another. For example, when an instruction accesses a memory variable, ASM-86 must know which segment contains the variable so it can generate a segment-override prefix byte if necessary. 3.2.1 The CSEG Directive Syntax: CSEG CSEG CSEG numeric expression $ This directive tells the assembler that the following statements belong in the Code Segment. All instruction statements must be assigned to the Code Segment. All directive statements are legal in the Code Segment. Use the first form when the location of the segment is known at assembly time; the code generated is not relocatable. Use the second form when the segment location is not known at assembly time; the code generated is relocatable. Use the third form to continue the Code Segment after it has been interrupted by a DSEG, SSEG, or ESEG directive. The continuing Code Segment starts with the same attributes, such as location and instruction pointer, as the previous Code Segment. 3.2.2 The DSEG Directive Syntax: DSEG DSEG DSEG numeric expression $ This directive specifies that the following statements belong to the Data Segment. The Data Segment contains the data allocation directives DB, DW, DD, and RS, but all other directive statements are also legal. Instruction statements are illegal in the Data Segment. Use the first form when the location of the segment is known at assembly time; the code generated is not relocatable. Use the second form when the segment location is not known at assembly time; the code generated is relocatable. Use the third form to continue the Data Segment after it has been interrupted by a CSEG, SSEG, or ESEG directive. The continuing Data Segment starts with the same attributes as the previous Data Segment. ---------------------------------------------------------------------------------------------------~DIGITALRESEARCH~ 3-2 Concurrent CP/M-86 Utilities Guide 3.2.3 3.2 Segment Start Directives The SSEG Directive Syntax: SSEG SSEG SSEG numeric expression $ The SSEG directive indicates the beginning of source lines for the Stack Segment. Use the Stack Segment for all stack operations. All directive statements are legal in the Stack Segment, but instruction statements are illegal. Use the first form when the location of the segment is known at assembly time; the code generated is not relocatable. Use the second form when the segment location is not known at assembly time; the code generated is relocatable. Use the third form to continue the Stack Segment after it has been interrupted by a CSEG, DSEG, or ESEG directive. The continuing Stack Segment starts with the same attributes as the previous Stack Segment. 3.2.4 The ESEG Directive Syntax: ESEG ESEG ESEG numeric expression $ This directive initiates the Extra Segment. Instruction statements are not legal in this segment, but all directive statements are legal. Use the first form when the location of the segment is known at assembly time; the code generated is not relocatable. Use the second form when the segment location is not known at assembly time; the code generated is relocatable. Use the third form to continue the Extra Segment after it has been interrupted by a DSEG, SSEG, or CSEG directive. The continuing Extra Segment starts with the same attributes as the previous Extra Segment. I!ID DIGITAL RESEARCH'" - - - - - - - - - - - - - - - - - - - - - - - - - - 3-3 3.3 The ORG Directive 3.3 Concurrent CP/M-86 Utilities Guide The ORG Directive Syntax: ORG numeric expression The ORG directive sets the offset of the location counter in the current segment to the value specified in the numeric expression. Define all elements of the expression before the ORG directive because forward references can be ambiguous. In most segments, an ORG directive is unnecessary. If no ORG is included before the first instruction or data byte in a segment, assembly begins at location zero relative to the beginning of the segment. A segment can have any number of ORG directives. 3.4 The IF and ENDIF Directives Syntax: IF numeric expression source line 1 source line 2 source line n END IF The IF and ENDIF directives allow a group of source lines to be included or excluded from the assembly. Use conditional directives to assemble several different versions of a single source program. When the assembler finds an IF directive, it evaluates the numeric expression following the IF keyword. If the expression evaluates to a nonzero value, then source line 1 through source line n are assembled. If the expression evaluates to zero, the lines are not assembled, but are listed unless a NOIFLIST directive is active. All elements in the numeric expression must be defined before they appear in the IF directive. IF directives can be nested to a maximum depth of five levels. - - - - - - - - - - - - - - - - - - - - - - - - - - I ! I D DIGITAL RESEARCH'" 3-4 Concurrent CP/M-86 Utilities Guide 3.5 3.5 The INCLUDE Directive The INCLUDE Directive Syntax: INCLUDE filespec This directive includes another ASM-86 file in the source text. For example, INCLUDE EQUALS.A86 Use INCLUDE when the source program resides in several different files. INCLUDE directives cannot be nested; a source file called by an INCLUDE directive cannot contain another INCLUDE statement. If filespec does not contain a filetype, the filetype is assumed to be .A86. If the file specification does not include a drive specification, ASM-86 assumes that the file resides on the drive containing the source file. 3.6 The END Directive Syntax: END An END directive marks the end of a source file. Any subsequent lines are ignored by the assembler. END is optional. If not present, ASM-86 processes the source until it finds an end-of-file character (lAH). 3.7 The EQU Directive Syntax: symbol symbol symbol symbol EQU EQU EQU EQU numeric expression address expression register instruction mnemonic The EQU, equate, directive assigns values and attributes to user-defined symbols. The required symbol name cannot terminate with a colon. The symbol cannot be redefined by a subsequent EQU or another directive. Any elements used in numeric or address expressions must be defined before the EQU directive appears. I!IDDIGITAL RESEARCH TN - - - - - - - - - - - - - - - - - - - - - - - - - 3-5 Concurrent CP/M-86 Utilities Guide 3.7 The EQU Directive The first form assigns a numeric value to the symbol. The second assigns a memory address. The third form assigns a new name to an 8086 register. The fourth form defines a new instruction (sub )set. The following are examples of these four forms: 0005 0033 0001 005D 8BC3 FIt.JE NEXT COUNTER MOI)I)I) EQU EQU EQU EQU BUFFER MOt.J MOt.JI.Jt.J 3.8 The DB Directive Syntax: [symbol] DB numeric expression[,numeric expression ... ] [symbol] DB string constant[,string constant... ] The DB directive defines initialized storage areas in byte format. Numeric expressions are evaluated to 8-bit values and sequentially placed in the hex output file. String constants are placed in the output file according to the rules defined in Section 2.4.2. A DB directive is the only ASM-86 statement that accepts a string constant longer than two bytes. There is no translation from lower- to upper-case within strings. Multiple expressions or constants, separated by commas, can be added to the definition, but cannot exceed the physical line length. Use an optional symbol to reference the defined data area throughout the program. The symbol has four attributes: the segment and offset attributes determine the symbol's memory reference, the type attribute specifies single bytes, and the length attribute tells the number of bytes (allocation units) reserved. - - - - - - - - - - - - - - - - - - - - - - - - - - I ! I D D I G I T A L RESEARCH'" 3-6 3.8 The DB Directive Concurrent CP/M-86 Utilities Guide The following statements show DB directives with symbols: 005F 43502F4D2073 79737485DOO 008B El 008C 0102030405 TE}{T DB 'CP/M AA DB DB 'a' + SOH lt2t3tllt5 MOI,I C}·{ tLENGTH TE}type sort.aBS silTlPle sort pro!1ralTl SO r t : ITIO V MOV ITIOV s i ,0 bx ,offset nlist ITIOV CMP Jna xch!1 ITIOV MOV al,[bx+siJ al,Hbx+siJ inci al,Hbx+siJ [bx+siJ,al sw t1 i!1et b}'te froM list ;COITIPare with next byte idon't switch if in order ;do fi rst part of switch ;do second part iset switch fla!1 inc CMP Jnz test Jnz si si ,count COMP Sr...I ,1 sort iincrelTlent index iend of list? ;no, .'eep !1oin!1 ;done - an}' sr...dtches? i }'es, so rt SOllIe MO re JMP done ;!1et here when list ordered dseq or!1 100h ileave space for base pa9'e ;initialize index ;bx = base of list iclear switch fla!1 sw,O C OITlP: inci: done: nlist count db equ 3,8,a,8 ,31,8,a t1 offset $ - offset nlist sw db end o Assemble program. A>asmBS sort CP/M 8088 ASSEMBLER VER 1.1 END OF PASS 1 END OF PASS 2 END OF ASSEMBL Y. NUMBER OF ERRORS: 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [!ill 6-20 DIGITAL RESEARCH Tli Concurrent CP/M-86 Utilities Guide 6.5 DDT-86 Sample Session Type listing file generated by ASM-86. A)type sort.1st CP/M ASM88 1.1 SOURCE: Sort.A88 PAGE 1 sitllPle sort pro!1ratrl so r t : trIO v ITlOV 0008 C806080100 s i ,0 ;initialize index bx ,offsetibx = base of list nlist sw,O iclear switch fla!1 0006 0000 0010 0012 0015 0017 al,[bx+siJ al li[bx+siJ inci al ,1[bx+siJ [bx+siJ,al sw Ii i!1et byte frotll list icolTlPare with next byte idon 't switch if in orde r ida fi rst part of switch ida second part iset switch fla!1 si si ,count c OtllP sw Ii 5 art iincretllent index iend of list? ina, .~eep !1oin!1 idone - any switches? iYes, sort Sotlle trlore done i!1et here when list ordered 0000 6EOOOO 0003 660001 001C 0010 0020 0022 0027 0029 ITlOV COITlP: 8AOO ITlOV CMP 3A4001 jna 760A xch!1 864001 8800 ITlOV C606080101 til a v in c i : 46 inc 83FE08 CtrlP jnz 75E9 F606080101 test jnz 7507 done: jlrlP E9FOFF dse!1 or!1 100h [iID DIGITAL RESEARCH TW Heave space for base pa!1e ----------------------------- 6-21 6.5 DDT-86 Sample Session 0100 030S040G1FOG 0401 OOOS 010S 00 Concurrent CP/M-86 Utilities Guide nlist db count offset $ - offset nlist o end END OF ASSEMBL Y. NUMBER OF ERRORS: 0 Type symbol table file generated by ASM-86. A>t>'pe sort.SYfI1 0000 l..'AR I ABLES 0100 NLIST 010S SW 0000 NUMBERS OOOS COUNT 0000 LABELS OOOB COMP 0028 DONE 001C INCI 0000 SORT Type hex file generated by ASM-86. A>type sort.hBB :0400000300000000F8 :lBOOOOS1BEOOOOBB0001CGOGOS0100SA003A40017GOASG4001SS0OCGOGOS01GC :11001BS1014GS3FEOS75E8FGOGOS010175D7E8FDFFEE :080100S2030S040G1FOG04010035 :OOOOOOOlFF Generate CMD file from .H86 file; A>dencfI1d sort BYTES READ 0038 RECORDS WRITTEN 04 Invoke DDT-86 and load SORT.CMD. A>ddtBB sort DDTSS 1.0 START END CS 047D:0000 047D:002F DS 04S0:0000 04S0:010F - - - - - - - - - - - - - - - - - - - - - - - - - - I!IDDIGITAL RESEARCkii 6-22 Concurrent CP/M-86 Utilities Guide 6.5 DDT-86 Sample Session Display initial register values. -x A){ B)-( C){ D){ 8P BP 81 DI C8 D8 88 E8 IP - - - - - - - - - 0000 0000 0000 0000 11SE 0000 0000 0000 OLl7D OLl80 OLiSl OLl80 0000 MDI,' 8 I ,0000 Disassemble the beginning of the code segment. -J OLl7D:0000 OLl7D:0003 OLl7D:000G OLl7D:000B OLl7D:000D OLl7D:0010 OLl7D:0012 OLl7D:0015 OLl7D:0017 OLl70:001C OLl7D:001D OLl7D:0020 MDI,' MDI) MDI) MOl,' CMP JBE )-(CHG MOV MOV INC CMP JNZ 81 ,0000 B)-(,0100 BYTE [0108] ,0(. AL,[B)-(+8I] AL,01[B)-(+8I] 001C AL ,01 [B)-(+8I] [B){+8I] ,AL BYTE [0108] ,01 81 81,0008 OOOB Display the start of the data segment. -dJOO dOf Oll80: 0100 03 08 OLi 08 IF 08 Oll 01 00 00 00 00 00 00 00 ••••••••••••••• I!ID DIGITAL RESEARCH'" - - - - - - - - - - - - - - - - - - - - - - - - - - - 6-23 Concurrent CP/M-86 Utilities Guide 6.S DDT-86 Sample Session Disassemble the rest of the code. -1 047D:0022 047D:0027 047D:0028 047D:002C 047D:002E 047D:0030 047D:0031 047D:0033 047D:0034 047D:0035 047D:0037 047D:0038 TEST JNZ JMP ADD ADD DAS ADD ??= POP ADD AD ??= BYTE [0108] ,01 0000 0028 [B}'(+SI] ,AL [B}(+SI],AL [B}{+SI] ,AL GC ES [B}(],CL [B}{+SI] ,M( GF Execute program from IP (= 0) setting breakpoint at 29H -!J,29 * 0 47 0 : 0028 Breakpoint encountered. Display sorted list. -d10Q,OOf 0480:0100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 •••••••••••• Doesn't look good; reload file eso rt START CS 047D: 0000 DS 0480: 0000 END 047D: 002F 0480: 0 1 OF Trace 3 instructions. - t3 AX BX C}( DX SP BP SI DI IP - - - --Z - P- 0000 0100 0000 0000 118E 0000 0008 0000 0000 MoV -----Z-P- 00000100 0000 0000 118E 0000 0000 00000003 MQl..J -----Z-P- 0000 0100 0000 0000 118E 0000 0000 0000 OOOG MoV *0470:000B - - - - - - - - - - - - - - - - - - - - - - - - - - - [i]) 6-24 S I ,0000 BX ,0100 BYTE [0108J ,00 DIGITAL RESEARCH TII Concurrent CP/M-86 Utilities Guide 6.5 DDT-86 Sample Session Trace some more. -t3 AX BX CX OX SP BP SI 01 IP -----Z-P- 0000 0100 0000 0000 118E 0000 0000 0000 OOOB MOV -----Z-P- 0003 0100 0000 0000 118E 0000 0000 0000 0000 CMP ----S-A-C 0003 0100 0000 0000 118E 0000 0000 0000 0010 JBE *0470:001C ALtCBX+SI] ALt01CBX+SI] 001C Display unsorted list -d100t10f 0480:0100 03 08 04 08 lF 08 04 01 00 00 00 00 00 00 00 00 •••••••••••• Display next instructions to be executed. -1 0470:001C 0470:0010 0470:0020 0470:0022 0470:0027 0470:0028 0470:002C 0470:002E 0470:0030 0470:0031 0470:0033 0470:0034 INC CMP JNZ TEST JNZ JMP ADD ADD OAS ADD ??= POP SI SI tOO08 OOOB BYTE C0108] tOl 0000 0028 CBX+SI] tAL CBX+SI] tAL CBX+SI] tAL 8C ES Trace some more -t3 AX BX CX OX SP BP SI 01 IP ----S-A-C 0003 0100 0000 0000 118E 0000 0000 0000 001C INC --------C 0003 0100 0000 0000 118E 0000 0001 0000 0010 CMP - - - -S-APC 0003 0100 0000 0000 118E 0000 0001 0000 0020 JNZ *0470:000B SI SI t0008 OOOB I!IDDIGITAL RESEARCH'" - - - - - - - - - - - - - - - - - - - - - - - - - - - 6-25 6.5 DDT-86 Sample Session Concurrent CP/M-86 Utilities Guide Display instructions from current IP. -1 0470: OOOB 0470: 0000 0470:0010 0470:0012 0470:0015 0470:0017 0470:001C 0470:0010 0470: 0020 0470: 0022 0470: 0027 0470: 0028 MOV CMP JBE XCHG MOV MOV INC CMP JNZ TEST JNZ JMP AL.[BX+SI] AL.Ol[BX+SI] 001C .AL.Ol[BX+SI] [BX+SI] .AL BYTE [0108] .01 SI . SI .0003 OOOB BYTE [0108] .01 0000 0028 -t3 AX BX CX OX SP BP SI 01 IP ----S-APC 0003 01000000 0000 118E 0000 0001 0000 OOOB MOV ----S-APC 0008 0100 0000 0000 118E 00000001 0000 0000 CMP --------- 0008 0100 0000 0000 118E 00000001 00000010 JBE *0470:0012 -1 0470:0012 0470:0015 0470:0017 0470:001C 0470:0010 0470:0020 0470:0022 0470:0027 0470:0028 0470:002C 0470:002E 0470:0030 XCHG MOV MOV INC CMP JNZ TEST JNZ JMP ADD ADO OAS AL.[BX+SI] AL.Ol[BX+SIJ 001C AL .OlC6X+SIJ [BX+SI] .AL BYTE [0108] .01 SI SI .0008 0006 BYTE [0108] .01 0000 0028 [BX+SI] .AL [BX+SI] .AL Go until switch has been performed. - !I,20 *0470:0020 Display list. -d1 0011 Of 0480: 0100 03 04 08 08 1 F 08 04 01 01 00 00 00 00 00 00 00 •••••••••••••••• - - - - - - - - - - - - - - - - - - - - - - - - - - - I!ID DIGITAL RESEARCH'" 6-26 Concurrent CP/M-86 Utilities Guide 6.5 DDT-86 Sample Session Looks like 4 and 8 were switched okay. (And toggle is true.) -to AX 6X CX OX SP 6P SI 01 IP - - - -S-APC 0004 0100 0000 0000 118E 0000 0002 0000 0020 JNZ 0006 *0470:0006 Display next instructions. -1 OLl70: 0006 OLl70: 0000 OLl70:0010 OLl70:0012 OLl70:0015 OLl70:0017 OLl70:001C OLl70:0010 OLl70: 0020 OLl70: 0022 OLl70: 0027 OLl70: 0028 AL,[6}{+SI] AL,01[6X+Sl] 001C AL ,01 [6){+SI] [6X+Sl] ,AL 6YTE [0108] ,01 SI SI,0008 0006 6YTE [0108] ,01 0000 0028 MOV CMP J6E XCHG MOV MOV INC CMP JNZ TEST JNZ JMP Since switch worked, let's reload and check boundary conditions. -esort START END CS OLl70: 0000 OLl70: 002F OS 0480: 0000 0480: 01 OF I!ID DIGITAL RESEARCH TIoI - - - - - - - - - - - - - - - - - - - - - - - - - - - 6-27 6.5 DDT-86 Sample Session Concurrent CP/M-86 Utilities Guide Make it quicker by setting list length to 3. (Could also have used s47d to patch.) = Ie -ald 0470:0010 0470:0020 CITIP si,3 Display unsorted list. -dl00 0480: 0100 03 08 04 08 1 F 06 04 01 00 00 00 00 00 00 00 00 •••••••••••••••• 0480: 0110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 •••••••••••••••• 0480: 0 120 00 00 00 00 00 00 00 00 00 00 00 ')0 00 20 20 20 ••••••••••••• Set breakpoint when first 3 elements of list should be sorted. -~/29 *0470:0029 See if list is sorted. -dl00 d Of 0480: 0100 03 04 08 08 1 F 06 04 01 00 00 00 00 00 00 00 00 •••••••••••••••• Interesting, the fourth element seems to have been sorted in. -esort START END CS 01l70: 0000 01l70: 002F OS 0480: 0000 0480: 01 OF Let's try again with some tracing. -ald 0470:001D 0470:0020 CITIP si,3 - - - - - - - - - - - - - - - - - - - - - - - - - - I ! I D DIGITAL RESEARCH'" 6-28 Concurrent CP/M-86 Utilities Guide 6.5 DDT-86 Sample Session -t9 AX BX - - - - - Z- P - 0008 0100 - - - - -Z- P - 0008 0100 - - - - -Z- P - 0008 0100 - - - - -Z- P - 0008 0100 -----Z-P- 00030100 ----8-A-C 0003 0100 ----8-A-C 00030100 --------C 0003 0100 - - - -8-A-C 0003 0100 *O£l70:000B C}{ 0000 0000 0000 0000 0000 0000 0000 0000 0000 OX 0000 0000 0000 0000 0000 0000 0000 0000 0000 8P 118E 118E 118E 118E 118E 118E 118E 118E 118E BP 0000 0000 0000 0000 0000 0000 0000 0000 0000 81 0003 0000 0000 0000 0000 0000 0000 0001 0001 01 0000 0000 0000 0000 0000 0000 0000 0000 0000 IP 0000 0003 0008 OOOB 0000 0010 001C 0010 0020 MOV MOV MOV MOV CMP JBE INC CMP JNZ 8 I ,0000 B}{,0100 BYTE [0108] ,00 AL,[BX+8I] AL,01[BX+8I] 001C 81 81 ,0003 OOOB -1 O£l70: OOOB O£l70: 0000 O£l70:0010 O£l70: 00 12 O£l70:0015 O£l70: 0017 O£l70:001C O£l70:0010 O£l70: 0020 O£l70: 0022 O£l70: 0027 O£l70: 0028 MOV CMP JBE XCHG MOV MOV INC CMP JNZ TE8T JNZ JMP AL ,[ B}{+8 I] AL,01[BX+8I] 001C AL ,01 [B}{+8I] [B}(+8I] ,AL BYTE [0108] ,01 81 81 ,0003 OOOB BYTE [0108] ,01 0000 0028 -t3 AX BX CX OX 8P BP 81 01 IP -.- - -8-A- C 0003 0100 0000 0000 118E 0000 0001 0000 OOOB MOV ----8-A-C 00080100 0000 0000 118E 0000 0001 00000000 CMP --------- 00080100 0000 0000 118E 0000 0001 0000 0010 JBE *0£170:0012 AL,[BX+8I] AL ,01 [B}(+8I] 001C -1 O£l70: 0012 O£l70:0015 O£l70: 0017 O£l70:001C O£l70:0010 O£l70: 0020 O£l70: 0022 I!ID XCHG MOV MOV INC CMP JNZ TE8T AL ,01 [B}-(+8I] [B}(+8I] ,AL BYTE [0108] ,01 81 81 ,0003 OOOB BYTE [0108] ,01 DIGITAL RESEARCHTW - - - - - - - - - - - - - - - - - - - - - - - - - - - 6-29 6.5 DDT-86 Sample Session Concurrent CP/M-86 Utilities Guide -t3 AX BX CX OX 8P BP 81 01 IP --------- 0008010000000000 119E 0000 0001 00000012 XCHG --------- 0004 0100 0000 0000 119E 0000 0001 0000 0015 MoV --------- 0004 010000000000 l19E 0000 0001 00000017 MoV *0470:001C -dl00tlOf 0480: 0100 03 04 08 06 1 F 06 04 01 01 00 00 00 00 00 00 00 t t t t AL ,01 [BX+8I] [BX+8I] ,AL BYTE [0108] ,01 t t t t t t t t t t t t So far, so good. -t3 AX BH C}( OX 8P BP 81 01 IP --------- 0004 0100 0000 0000 119E 0000 0001 0000 001C INC --------- 0004 0100 0000 0000 119E 0000 0002 0000 0010 CMP - - - - - - - - - 0004 0100 0000 0000 119E 0000 0002 0000 0020 JNZ *0470:000B 81 81 ,0003 OOOB -1 0470: OOOB 0470 :0000 0470:0010 0470:0012 0470:0015 0470:0017 0470:001C 0470:0010 0470: 0020 0470:0022 0470: 0027 0470: 0029 MoV CMP JBE }(CHG MOl,! MOl,! INC CMP JNZ TE8T JNZ JMP AL, [B}(+8 I] AL ,01 [B}(+8I] 001C AL ,01 [B}(+8I] [B'-(+8IJ ,AL BYTE [0108] ,01 81 81,0003 OOOB BYTE [0108] ,01 0000 0029 -t3 AH B}( CH O}( 8P BP 81 01 IP ----8-APC 0004 0100 0000 0000 119E 0000 00020000 OOOB MoV ----8-APC 0008 0100 0000 0000 119E 0000 00020000 0000 CMP --------- 00080100 0000 0000 119E 0000 000200000010 JBE *0470:0012 AL , [B}(+8 IJ AL,Ol[BH+8I] 001C - - - - - - - - - - - - - - - - - - - - - - - - - - - [(IDDIGITAL RESEARCH"' 6-30 Concurrent CP/M-86 Utilities Guide 6.5 DDT-86 Sample Session Sure enough, it's comparing the third and fourth elements of the list. Reload program. -esort START END CS 0470: 0000 0470: 002F OS 0480: 0000 0480: 01 OF -1 0470: 0000 0470: 0003 0470: 0006 0470: OOOB 0470: 0000 0470:0010 0470: 0012 0470:0015 0470: 00 17 0470:001C 0470:0010 0470: 0020 MDV MDV MDV MDV CMP JBE HCHG MDV MDV INC CMP JNZ SI,OOOO Bl<,0100 BYTE [0108J ,00 AL , [Bl<+S I J AL,Ol[Bl<+SIJ 001C AL,Ol[B}(+SIJ [B}{+SIJ,AL BYTE [0108J ,01 SI SI,0008 OOOB Patch length. -ald 0470:0010 0470:0020 ChiP si,7 Try it out. -!l,28 *0470:0028 [ij] DIGITAL RESEARCH'" - - - - - - - - - - - - - - - - - - - - - - - - - - - 6-31 6.5 DDT-86 Sample Session Concurrent CP/M-86 Utilities Guide See if list is sorted. -dl 00 t1 Of 0480:010001 030404060608 1F 00 00 00 00 00 00 00 00 •••••••••••••••• Looks better; let's install patch in disk file. To do this, we must read CMD file including header, so we use R command. -rsort.CIIICI START 2000:0000 END 2000:01FF First BOh bytes contain header, so code starts at BOh. -180 2000:0080 2000:0083 2000:0086 2000:008B 2000:0080 2000:0080 2000:0082 2000:0085 2000:0087 2000:008C 2000:0080 2000:00AO MOV MOV MOV MOV CMP JBE XCHG MOV MOV INC CMP JNZ 5I,OOOO BX,0100 BYTE [0108J ,00 AL,[BX+SIJ AL,Ol[BX+5IJ 008C AL,Ol[BX+5IJ [BX+5IJ ,AL BYTE [0108J ,01 5I 5I,0008 008B Install patch. -a8d 2000:0080 CMP si,7 Write file back to disk. (Length of file assumed to be unchanged since no length specified.) -IJsort.cllld - - - - - - - - - - - - - - - - - - - - - - - - - - ! I I D DIGITALRESEARCH™ 6-32 6.5 DDT-86 Sample Session Concurrent CP/M-86 Utilities Guide Reload file. -esort START CS Oll7D:0000 DS Oll80:0000 END Oll7D:002F Oll80:010F Verify that patch was installed. Oll7D:0000 Oll7D:0003 Oll70:0006 Oll7D:000B Oll70:000D Oll7D:00I0 Oll70:0012 Oll7D:0015 Oll7D:0017 Oll7D:00IC Oll7D:00ID Oll7D:0020 MOV MOV MOV MOV CMP JBE XCHG MOV MOV (NC CMP JNZ SI,OOOO BX,0100 BYTE [0108J ,00 AL,[BX=SIJ AL,Ol(BX=SIJ 001C AL,Ol[BX=SIJ [BX=SIJ ,AL BYTE [0108J ,01 51 SI,0007 OOOB Run it. -!l,28 Still looks good. Ship it! -d100 dOr 0480:0100 0103 04 04 08 08 08 IF 00 00 00 00 00 00 00 00 ••••• ••••••••••• -!l,28 *Oll7D:0028 -d100 dOF Oll80:0100 03 08 Oll 06 IF 06 Oll 01 00 00 00 00 00 00 00 00 •••••••••••• _hC A> End of Section 6 [QJ DIGITAL RESEARCHTl. - - - - - - - - - - - - - - - - - - - - - - - - - - - 6-33 Appendix A Starting ASM-86 Command: A >A5MBB Syntax: ASM86 filespec [ $ parameters] where filespec is the 8086 assembly source file (drive and filetype are optional). parameters is a one-letter type followed by a one-letter device from the table below. Default filetype: .A86 Parameters: $Td where T = type and d Table A-1. = device Parameter Types and Devices A H P S x x x x X x x x y x x x Z x x x TYPES: F DEV/CES: A-P x D x [!ill DIGITAL RESEARCH T• = d valid, d = default ----------~------------- A-I A Starting ASM-86 Concurrent CP/M-86 Utilities Guide Valid Parameters Except for the F type, the default device is the current default drive. Table A-2. Type I Parameter Types Function A H P S F controls location of ASSEMBLER source file. controls location of HEX file. controls location of PRINT file. controls location of SYMBOL file. controls type of hex output FORMAT. Table A-3. Name A-P X Y Z I D I Device Types Meaning DrivesA-P console device printer device byte bucket Intel hex format Digital Research hex format - - - - - - - - - - - - - - - - - - - - - - - - - [l]] A-2 DIGITAL RESEARCH'" A Starting ASM-86 Concurrent CP/M-86 Utilities Guide Table A-4. I Example ) Invocation Examples Result ASMBG IO Assembles' file IO.A86 and produces IO.H86 IO.LST and IO.SYM. ASMBG IO. ASM $ AD SZ Assembles file IO.ASM on device D and produces IO.LST and IO.H86. No symbol file. ASMBG IO $ PY S}-( Assembles file IO.A86, produces IO.H86, routes listing directly to printer, and outputs symbols on console. ASMBG IO $ FD Produces Digital Research hex format. ASMBG IO $FI Produces Intel hex format. End of Appendix A ) i!IDDIGITAL RESEARCH TlI - - - - - - - - - - - - - - - - - - - - - - - - A-3 ) Appendix B Mnemonic Differences from the Intel Assembler The CP/M 8086 assembler uses the same instruction mnemonics as the Intel 8086 assembler except for explicitly specifying far and short jumps, calls, and returns. The following table shows the four differences. Table B-l. Mnemonic Differences Mnemonic Function J CP/M I Intel Intrasegment short jump: JMPS JMP Intersegment jump: JMPF JMP Intersegmentreturn: RETF RET Intersegment call: CALLF CALL End of Appendix B ) I!IDDIGITAL RESEARCHTII - - - - - - - - - - - - - - - - - - - - - - - - B-1 Appendix C ASM-86 Hexadecimal Output Format ASM-86 produces machine code in either Intel or Digital Research hexadecimal format. The Intel format is identical to the format defined by Intel for the 8086. The Digital Research format is nearly identical to the Intel format, but Digital adds segment information to hexadecimal records. Output of either format can be input to the GENCMD, but the Digital Research format automatically provides segment identification. A segment is the smallest unit of a program that can be relocated. Table C-1 defines the sequence and contents of bytes in a hexadecimal record. Each hexadecimal record has one of the four formats shown in Table C-2. An example of a hexadecimal record is shown below: Byte number = > 0 1 2 3 4 5 6 7 8 9 .............. n Contents = > : 11 a a a a t t d d d ......... c c CR LF Table C-1. Byte 0 1-2 3-6 7-8 9-(n-1) n-(n + 1) n+2 n+3 I Hexadecimal Record Contents Contents record mark record length load address record type data bytes checksum carriage return line-feed I Symbol 11 aaaa tt dd ..... d cc CR LF ~DIGITAL~EARCH~----------------------------------------~-------------------------------------------------------- C-l C ASM-86 Output Format Concurrent CP/M-86 Utilities Guide Table C-2. Hexadecimal Record Formats Type I Content I Format 00 Data record : 11 aaaa DT cc 01 End-of-file : 00000001 FF 02 Extended address mark : 020000 ST ssss cc 03 Start address : 040000 03 ssss iiii cc 11 cc aaaa ssss iiii DT ST => => => => => => => record length - number of data bytes checksum - sum of all record bytes 16-bit address 16-bit segment value offset value of start address data record type segment address record type It is in the definition of record type (DT and ST) that Digital Research hexadecimal format differs from Intel. Intel defines one value each for the data record type and the segment address type. Digital Research identifies each record with the segment that contains it, as shown in Table C-3. - - - - - - - - - - - - - - - - - - - - - - - - - l!]JDlGITAL RESEARCH'" C-2 Concurrent CP/M-86 Utilities Guide C ASM-86 Output Format Table C-3. Symbol Intel Value DT 00 ST Digital Value Segment Record Types Meaning for data belonging to a1l8086 segments 81H for data belonging to the CODE segment 82H for data belonging to the DATA segment 83H for data belonging to the STACK segment 84H for data belonging to the EXTRA segment 02 for all segment address records 85H for a CODE absolute segment address 86H for a DATA segment address 87H for a STACK segment address 88H for a EXTRA segment address End of Appendix C i!ruDIGITAL RESEARCH TW - - - - - - - - - - - - - - - - - - - - - - - - C-3 Appendix D Reserved Words Table D-l. Keywords or Reserved Words Predefined Numbers BYTE WORD DWORD Operators AND EQ GE GT LAST LE LENGTH LT MOD NE NOT PTR OFFSET OR SEG SHL SHR TYPE XOR NO LIST ORG PAGESIZE PAGEWIDTH RS RW SIMFORM SSEG TITLE Assembler Directives CODEMACRO CSEG DB DD DSEG DW EJECT END ENDIF ENDM ESEG EQ IF IFLIST INCLUDE LIST NOIFLIST RB Code-macro Directives DB DBIT DD DW MODRM NOSEGFIX SEGFIX RELB RELW DI DL DS DX ES SI SP SS 8086 Registers AH AL AX BH BL BP BX CH CL CS CX DH Instruction Mnemonics - See Appendix E. End of Appendix D !lID DIGITAL RESEARCH'" - - - - - - - - - - - - - - - - - - - - - D-l Appendix E ASM-86 Instruction Summary Table E-1. Mnemonic AAA AAD AAM AAS ADC ADD AND CALL CALLF CBW CLC CLD CLI CMC CMP CMPS CMPSB CMPSW CWD DAA DAS DEC DIV ESC HLT IDIV IMUL IN INC INT INTO IRET I ASM-86 Instruction Summary Description ASCII adjust for Addition ASCII adjust for Division ASCII adjust for Multiplication ASCII adjust for Subtraction Add with Carry Add And Call (intrasegment) Call (intersegment) Convert Byte to Word Clear Carry Clear Direction Clear Interrupt Complement Carry Compare Compare Byte or Word (of string) Compare Byte of string Compare Word of string Convert Word to Double Word Decimal Adjust for Addition Decimal Adjust for Subtraction Decrement Divide Escape Halt Integer Divide Integer Multiply Input Byte or Word Increment Interrupt Interrupt on Overflow Interrupt Return I Section 4.3 4.3 4.3 4.3 4.3 4.3 4.3 4.5 4.5 4.3 4.6 4.6 4.6 4.6 4.3 4.4 4.4 4.4 4.3 4.3 4.3 4.3 4.3 4.6 4.6 4.3 4.3 4.2 4.3 4.5 4.5 4.5 !!ill DIGITAL RESEARCH Tli E-1 Concurrent CP/M-86 Utilities Guide E Instruction Summary Table E-1. Mnemonic JA JAE JB JBE JC JCXZ JE JG JGE JL JLE JMP JMPF JMPS JNA JNAE JNB JNBE JNC JNE JNG JNGE JNL JNLE JNO JNP JNS JNZ JO JP JPE JPO JS JZ LAHF LDS LEA LES I (continued) Description Jump on Above Jump on Above or Equal Jump on Below Jump on Below or Equal Jump on Carry Jump on CX Zero Jump on Equal Jump on Greater Jump on Greater or Equal Jump on Less Jump on Less or Equal Jump (intrasegment) Jump (intersegment) Jump (8-bit displacement) Jump on Not Above Jump on Not Above or Equal Jump on Not Below Jump on Not Below or Equal Jump on Not Carry Jump on Not Equal Jump on Not Greater Jump on Not Greater or Equal Jump on Not Less Jump on Not Less or Equal Jump on Not Overflow Jump on Not Parity Jump on Not Sign Jump on Not Zero Jump on Overflow Jump on Parity Jump on Parity Even Jump on Parity Odd Jump on Sign Jump on Zero Load AH with Flags Load Pointer into DS Load Effective Address Load Pointer into ES I Section 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.2 4.2 4.2 4.2 - - - - - - - - - - - - - - - - - - - - - - - t!ID DIGITAL RESEARCH™ E-2 E Instruction Summary Concurrent CP/M-86 Utilities Guide Table E-l. Mnemonic LOCK LODS LODSB LODSW LOOP LOOPE LOOPNE LOOPNZ LOOPZ MOV MOVS MOVSB MOVSW MUL NEG NOT OR OUT POP POPF PUSH PUSHF RCL RCR REP RET RETF ROL ROR SAHF SAL SAR SBB SCAS SCASB SCASW SHL SHR [lID I (continued) Description Lock Bus Load Byte or Word (of string) Load Byte of string Load Word of string Loop Loop While Equal Loop While Not Equal Loop While Not Zero Loop While Zero Move Move Byte or Word (of string) Move Byte of string Move Word of string Multiply Negate Not Or Output Byte or Word Pop Pop Flags Push Push Flags Rotate through Carry Left Rotate through Carry Right Repeat Return (intrasegment) Return (intersegment) Rotate Left Rotate Right Store AH into Flags Shift Arithmetic Left Shift Arithmetic Right Subtract with Borrow Scan Byte or Word (of string) Scan Byte of string Scan Word of string Shift Left Shift Right I Section 4.6 4.4 4.4 4.4 4.5 4.5 4.5 4.5 4.5 4.2 4.4 4.4 4.4 4.3 4.3 4.3 4.3 4.2 4.2 4.2 4.2 4.2 4.3 4.3 4.4 4.5 4.5 4.3 4.3 4.2 4.3 4.3 4.3 4.4 4.4 4.4 4.3 4.3 DIGITAL RESEARCH'" E-3 Concurrent CP/M-86.Utilities Guide E Instruction Summary Table E-1. Mnemonic STC STD STI STOS STOSB STOSW SUB TEST WAIT XCHG XLAT XOR I (continued) Description Set Carry Set Direction Set Interrupt Store Byte or Word (of string) Store Byte of string Store Word of string Subtract Test Wait Exchange Translate Exclusive Or I Section 4.6 4.6 4.6 4.4 4.4 4.4 4.3 4.3 4.6 4.2 4.2 4.3 End of Appendix E - - - - - - - - - - - - - - - - - - - - - - - - i!IDDIGITAL RESEARCH"" E-4 Appendix F Sample Program APPF.A86 CP/M ASM86 1.08 SOURCE: APPF.A86 TerMinal Input/Output PAGE title 'TerMinal Input/Output' pa!l'esize 50 pa!l'ewidth 78 siMforM '****** TerMinal I/O subroutines ******** The followins subroutines are included: CONSTAT CoNIN CON OUT console status console input console output Each routine requires CONSOLE NUMBER in the BL reSister. ***************** * JUMP table: * **************** SEG ; start of code seSMent 0000 E80600 0003 E81800 0006 E82BOO constat conin con out *********************** * I/O port nUMbers * *********************** Listing F-1. Sample Program APPF.A86 I!IDDIGITAL RESEARCH™ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - F-l F Sample Program CP/M ASM86 1.08 Concurrent CP/M-86 Utilities Guide Terminal Input/Output SOURCE: APPF.A86 PAGE· 2 Terminal 1: 0010 0011 0011 0001 0002 instatl indatal outdatal readYinmaskl readyoutmaskl equ equ equ equ equ 10h llh llh 01h 02h input status port input po rt output port input ready mask output ready mask 12h 13h 13h oah 08h input status po rt input po rt output po rt input ready mask output ready mask Te rminal 2: 0012 0013 0013 oooa 0008 instat2 indata2 outdata2 readYinmask2 readyoutmask2 equ equ equ equ equ *********** * CONSTAT * *********** EntrY: BL - relt Exit: AL - relt = terminal no = 0 if not ready Offh if ready 0009 53E83FOO 0000 OOOE 0010 0012 0013 0016 0018 52 B600 8A17 EC 22a706 7a02 BOFF constat: push bx ! call okterminal constatl: push dx mov dh,O read status port mov dl tinstatustab [BX] in al,dx and al,readyinmasktab [bx] jz constatout mov al,Offh Listing F-l. (continued) - - - - - - - - - - - - - - - - - - - - - - - - - - - - l!ID DIGITAL RESEARCH TII F-2 Concurrent CP/M-86 Utilities Guide CP/M ASM86 1.09 001A 5A5BOACOC3 F Sample Program SOURCE: APPF.A86 TerMinal Input/Output constatout: pop dx POP bx or al,al PAGE 3 ret ********* * CONIN * ********* EntrY: BL Exit: AL 001F 0023 0026 0028 0029 002B 002E 002F 0031 53E82900 E8E7FF 74FB 52 6600 BA5702 EC Z47F 5A5BC3 re~ re~ = terMinal no = read character onin: push bx ! call oKterMinal conin1: call constat1 jz conin1 push dx MOV dh ,0 MOV dl tindatatab [BX] al ,dx in and al,7th pOP dx ! pOP bx ret test status read character strip parity bit ********** * CONOUT * ********** EntrY: 0034 0038 0039 003A 003C 53E81400 52 50 6600 BAl7 003E EC onout: push push push MOV MOV conout1: in BL AL - re~ = terMinal no = character to print bx ! call oKterMinal dx ax dh,O dl tinstatustab [BX] test status al ,d x Listing F-l. I!ID re~ (continued) DIGITAL RESEARCH"" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - F-3 F Sample Program CP/M ASM86 1.09 003F 0042 0044 0045 0048 0049 Concurrent CP/M-86 Utilities Guide TerMinal Input/Output SOURCE: APPF.A86 and jz pop MOV out pop 224708 74FA 58 8A5704 EE 5A5BC3 PAGE 4 al,readYoutMasKtab CBX] conoutl j wr it e byte ax dl,outdatatab CBX] dx ,al dx ! pOP bx ! ret ++++++++++++++ + OKTERMINAL + ++++++++++++++ EntrY: 004C 004E 0050 0053 0055 0057 0059 OADB 740A 80FB03 7305 FECB B700 C3 005A 5B5BC3 oKterMinal: or jz CMP jae dec MOV ret error: BL - re~ = terMinal no bl,bl error bl tlenHh instatustab + 1 error bl bh,O pop bx ! pOP bx ! ret j************** end of code do se~Ment nothin~ *************** **************** * Data se~Ment * **************** dse~ ************************** * Data for each terMinal * ************************** Listing F-l. (continued) - - - - - - - - - - - - - - - - - - - - - - - - - - - - I I I D DIGITAL RESEARCH TN F-4 F Sample Program Concurrent CP/M-86 Utilities Guide CP/M ASM88 1.09 0000 1012 0002 1113 oooa 1113 0008 010a 0008 0208 SOURCE: APPF.A86 instatustab indatatab outdatatab readYinMasKtab readyoutMasKtab i*************** TerMinal Input/Output db db db db db PAGE 5 instat1 tinstat2 indata1 tindata2 outdata1,outdata2 readyinMasK1,readyinMasK2 readYoutMasK1,readYQutMasK2 end of file ********************** end END OF ASSEMBLY, NUMBER OF ERRORS: 0 Listing F-1. (continued) End of Appendix F ~DIGITAL~EARCH~--------------------------------------------------------- F-S Appendix G Code-macro Definition Syntax :: = CODEMACRO [] ] ENDM :: = IDENTIFIER :: = [{,}] :: = : [( :: = A I C I DIE I M I R I S I X :: = b I wid I sb :: = l :: = REGISTER I NUMBERB :: = NUMBERB,NUMBERB I NUMBERB,REGISTER I REGISTER,NUMBERB I REGISTER, REGISTER :: = {} :: = I I
I < segfix > I I I I I f!ID DIGITAL RESEARCH'" - - - - - - - - - - - - - - - - - - - - - - - G-l G Code-macro Syntax Concurrent CP/M-86 Utilities Guide :: = DB NUMBERB I DB :: = DW NUMBERW I DW
:: = DD :: = SEGFIX :: = NOSEGFIX :: = MODRM NUMBER7, I MODRM , :: = RELB :: = RELW :: = DBIT {,} :: = NUMBER15 (NUMBERB) I NUMBER15 ( ( NUMBERB ) ) :: = IDENTIFIER NUMBERB is 8 bits NUMBERW is 16 bits NUMBER? are the values 0, 1, .. , ? NUMBER15 are the values 0, 1, .. , 15 End of Appendix G - - - - - - - - - - - - - - - - - - - - - - - i ! I D DIGITAL RESEARCH'" G-2 AppendixH ASM-86 Error Messages ASM-86 produces two types of error messages: fatal errors and diagnostics. Fatal errors occur when ASM-86 is unable to continue assembling. Diagnostics messages report problems with the syntax and semantics of the program being assembled. The following messages indicate fatal errors ASM-86 encounters during assembly: NO FILE DISKETTE FULL D I RECTORY FULL DISKETTE READ ERROR CANNOT CLOSE SYMBOL TABLE Ot.'ERFLOW PARAMETER ERROR ASM-86 reports semantic and syntax errors by placing a numbered ASCII message in front of the erroneous source line. If there is more than one error in the line, only the first one is reported. Table H-l summarizes ASM-86 diagnostic error messages. Table H-1. Number o I ASM-86 Diagnostic Error Messages Meaning ILLEGAL FIRST ITEM 1 MISSING PSEUDO INSTRUCTION 2 ILLEGAL PSEUDO INSTRUCTION 3 DOUBLE DEFINED VARIABLE 4 DOUBLE DEFINED LABEL 5 UNDEFINED INSTRUCTION 6 GARBAGEATENDOFLINE-IGNORED 7 OPERANDS MISMATCH INSTRUCTION 8 ILLEGAL INSTRUCTION OPERANDS [!QJ DIGITAL RESEARCH TW - - - - - - - - - - - - - - - - - - - - - - - - H-l Concurrent CP/M-86 Utilities Guide H ASM-86 Error Messages Table H-1. Number I (continued) Meaning 9 10 11 12 13 14 15 MISSING INSTRUCTION 16 DOUBLE DEFINED SYMBOL - TREATED AS UNDEFINED 17 18 19 20 21 22 23 INSTRUCTION NOT IN CODE SEGMENT 24 UNDEFINED ELEMENT OF EXPRESSION ILLEGAL PSEUDO OPERAND NESTED IF ILLEGAL - IF IGNORED ILLEGAL IF OPERAND - IF IGNORED NO MATCHING IF FOR ENDIF SYMBOL ILLEGALLY FORWARD REFERENCEDNEGLECTED FILE NAME SYNTAX ERROR NESTED INCLUDE NOT ALLOWED ILLEGAL EXPRESSION ELEMENT MISSING TYPE INFORMATION IN OPERAND(S) LABEL OUT OF RANGE MISSING SEGMENT INFORMATION IN OPERAND ERROR IN CODEMACRO BUILDING End of Appendix H - - - - - - - - - - - - - - - - - - - - O C I D DIGITALRESEARCH TII H-2 Appendix I DDT-86 Error Messages Table 1-1. DDT-86 Error Messages J Error Message Meaning AMBIGUOUS OPERAND An attempt was made to assemble a command with an ambiguous operand. Precede the operand with the prefix BYTE or WORD. CANNOT CLOSE The disk file written by a W command cannot be closed. This is a fatal error that terminates DDT-86 execution. Take appropriate action after checking to see if the correct disk is in the drive and that the disk is not write-protected. DISK READ ERROR The disk file specified in an R command could not be read properly. This is usually the result of an unexpected end-of-file. Correct the problem by regenerating the H86 file. DISK WRITE ERROR A disk write operation could not be successfully performed during a W command, probably due to a full disk. Erase files or obtain a disk with greater capacity. I NSUFF I C I ENT MEMORY There is not enough memory to load the file specified in an R or E command. MEMORY REQUEST DEN I ED A request for memory during an R command could not be fulfilled. Up to eight blocks of memory can be allocated at a given time. !!ill DIGITAL RESEARCH TW - - - - - - - - - - - - - - - - - - - - - - - - 1-1 I DDT-86 Error Messages Concurrent CP/M-86 Utilities Guide Table 1-1. Error Message (continued) Meaning I NO FILE The file specified in an R or E command could not be found on the disk. NO SPACE There is no space in the directory for the file being written by a W command. VERIFY ERROR AT 5:0 The value placed in memory by a Fill, Set, Move, or Assemble command could not be read back correctly, indicating bad RAM or attempting to write to ROM or nonexistent memory at the indicated location. End of Appendix I - - - - - - - - - - - - - - - - - - - - - - - - - r!ID DIGITAL RESEARCH TII 1-2 Index "at" sign, 2-2 20-Bit Address specification of in DDT-86, 6-3 8086 Registers, D-1 A A (Assemble) Command (DDT-86), 6-4, 6-16, 6-18 AAA,4-6 AAD,4-6 AAM, 4-6 AAS,4-6 ADC, 4-6 ADD, 4-6 address conventions in ASM-86, 3-1 address expression, 2-16 allocating storage, 3-8 alphanumerics, 2-1 AND, 4-8 apostrophe, 2-2 arithmetic instructions, 4-5 arithmetic operators, 2-8, 2-10 ASCII character set, 2-1 ASM-86 character set, 2-1 ASM-86 error messages, 1-3, H-1 ASM-86 filetypes, 1-2 ASM-86 instruction set, 4-1, E-1 ASM-86 operators, 2-8 ASM-86 output files, 1-1 assembler directives, D-1 assembler operation, 1-1 assembly language source file, 1-1 assembly language statements, 2-16 assembly language syntax, 6-18 asterisk, 2-2 B B (Block Compare) Command (DDT-86), 6-4 BDOS interrupt instruction, 6-13 binary constant, 2-3 bracketed expressions, 2-16 BYTE, 2-5, 2-7, 6-18 c CALL, 4-13 carriage return, 2-2 CBW, 4-6 character string, 2-3 CLC, 4-16 CLD, 4-16 CLI, 4-16 CMC, 4-16 CMP, 4-6 CMPS, 4-10 Code Segment, 2-7, 3-2, 6-16 code-macro directives, 5-1, 5-2, 5-5, D-1 CodeMacro directive, 5-2 colon, 2-2 conditional assembly, 3-4 console output, 1-4 constants, 2-3 control transfer instructions, 4-13 creation of output files, 1-3 CSEG directive, 3-2 CWD,4-6 !lID DIGITAL RESEARCH™ - - - - - - - - - - - - - - - - - - - - - - - Index-l D E D (Display) Command (DDT-86), 6-5, 6-17 DAA,4-6 DAS, 4-6 data allocation directives (ASM-86), 3-2 data segment, 2-7, 3-1, 3-2, 6-16 data transfer instructions, 4-3 DB directive (ASM-86), 2-7, 3-8 DB directive (code-macro), 5-8 DBIT directive, 5-8 DD directive (ASM-86), 2-7, 3-8 DD directive (code-macro), 5-8 DDT-86 command summary, 6-2 DDT-86 error messages, 1-1 DDT-86 operation, 6-1, 6-3 DDT-86 termination of, 6-3 DEC, 4-7 default segment values, 6-16, 6-17 delimiters, 2-1 device name, 1-4 device types (ASM-86), A-2 D I register, 4-10 diagnostic error messages, H-1 Digital Research hex format, 1-2, C-1 directive statement, 2-18, 3-1 directives (ASM-86), 2-16 DIV, 4-7 dollar-sign character $, 1-4, 2-2 dollar-sign operator, 2-14 DSEG Directive (ASM-86), 3-2 DW Directive (ASM-86), 2-7, 3-7 DW directive (Code-Macro), 5-8 DWORD, 2-5, 2-7 E (Load for Execution) Command (DDT-86), 6-6, 6-16 effective address, 3-1 EJECT directive, 3-10 END directive, 3-5 end-of-line, 2-16 ENDIF directive, 3-4 Ending ASM-86, 1-5 EndM directive, 5-2 EQ,2-9 EQU directive (ASM-86), 2-7, 3-5 error condition, 1-3 ESC, 4-16 ESEG Directive (ASM-86), 3-3 exclamation point, 2-2 expressions, 2-16 extra segment (ES), 2-7, 3-1, 3-3, 4-10 F F (Fill) Command (DDT-86), 6-6, 6-17 F parameter, 1-5 fatal error, H-1 file name extensions, 1-2 flag bits, 4-2, 4-5 Flag Name Abbreviations, 6-15 flag registers, 4-2 formal parameters, 5-1 G G (Go) Command (DDT-86), 6-7, 6-17 GT,2-9 - - - - - - - - - - - - - - - - - - - - - - - I!IDDIGITAL RESEARCH™ Index-2 H H (Hexadecimal Math) Command (DDT-86), 6-8 hexadecimal format, 1-1 HLT, 4-16 I I (Input Command Tail) Command (DDT-86), 6-8 identifiers, 2-4 IDIV, 4-7 IF Directive, (ASM-86), 3-4 IFLIST, 3-11 IMUL, 4-7 IN, 4-3 INC, 4-7 INCLUDE Directive, (ASM-86), 3-5 initialized storage, 3-6 instruction statement, 2-16, 2-17, 3-2 INT,4-13 Intel hex format, 1-5 INTO, 4-13 invalid parameter, 1-3 invocation examples (ASM-86), A-3 invoking ASM-86, 1-2 lRET, 4-13 J JA,4-13 JB,4-13 JCXZ, 4-14 JE,4-14 JG,4-14 JL,4-14 JLE, 4-14 JMP, 4-14 [!ill JNA, 4-14 JNB, 4-14 JNE, 4-15 JNG, 4-15 JNL, 4-15 JNO, 4-15 JNP, 4-15 JNS, 4-15 JNZ, 4-15 JO,4-15 JP,4-15 JS,4-15 JZ,4-15 K keywords, 2-5, 2-6, D-1 L L (List) Command (DDT-86), 6-8, 6-16, 6-18 labels, 2-7, 2-17 LAHF, 4-3 LDS, 4-3 LE,2-9 LEA, 4-3 LES, 4-3 line-feed, 2-2 LIST, 3-11 . location counter, 3-4 LOCK, 4-17 LaDS, 4-10 logical instructions, 4-5 logical operators, 2-8, 2-9 logical segments, 3-1 LOOP, 4-15 LT,2-9 DIGITAL RESEARCH™ - - - - - - - - - - - - - - - - - - - - - - Index-3 M M (Move) Command (DDT-86), 6-9,6-17 MAC, 5-1 macros, 5 -1 . minus, 2-2 mnemonic, 2-17 mnemonic differences, 4-18 mnemonic differences from the Intel assembler, B-1 mnemonics, 4-1 mod field, 5-6 modifiers, 5-4 MODRM directive (code-macro), 5-6 MOV, 4-4 MOVS, 4-11 MUL, 4-7 N name field, 2-18 NEG, 4-7 NOIFLIST, 3-11 NOLIST, 3·11 nonprinting characters, 2-1 NOT, 4-8 number symbols, 2-8 numbers, 2-8 numeric constants, 2-3 numeric expressions, 2-16 o operator precedence, 2-14 operators, 2-8 optional run-time parameters, 1-3, 1-4 OR, 4-8 order of operations, 2-14 ORG Directive (ASM-86), 3-4 OUT, 4-4 output files, 1-1, 1-2 p PAGESIZE directive (ASM-86), 3-10 PAGEWIDTH directive (ASM-86), 3-10 parameter list, 1-3 parameter types (ASM-86), A-2 period, 2-2 period operator, 2-14 plus, 2-2 POP, 4-4 predefined numbers, 2-5 prefix, 2-17, 4-11 Prefix instructions, 2-17, 4-12 prefix mnemonics, 4-11 printer output, 1-5 PTR operator, 2-14 PUSH, 4-4 Q QI and QO (Query 1/0) Commands (DDT-86), 6-9 offset, 2-7 offset value, 3-1 operands, 4-1 - - - - - - - - - - - - - - - - - - - - - - - - i ! I D DIGITAL RESEARCHTM Index-4 R R (Read) Command (DDT-86), 6-10, 6-16 radix indicators, 2-3 range specifiers (code-macro), 5-4 RB directive (ASM-86), 3-9 RCL, 4-8 RCR, 4-8 register memory field, 5-6 registers, 2-5 relational operators, 2-8, 2-10 RELB directive (code-macro), 5-7 RELW directive (code-macro), 5-7 REP, 4-12 reserved words, D-1 ROL, 4-8 ROR, 4-8 RS directive (ASM-86), 3-8 run-time options, 1-4 run-time parameters, 1-4 RW directive (ASM-86), 3-9 s S (Set) Command (DDT-86), 6-11, 6-17 SAHF, 4-4 SAL, 4-8, 4-9 SAR, 4-9 SBB, 4-7 SCAS, 4-11 SEGFIX directive (code-macro), 5-5 segment, 2-7 segment base values, 3-1 segment directive statement, 3-1 segment override, 2-8, 2-10, 2-13 segment record types, C-3 segment start directives 3-1 [!QJ semicolon, 2-2 separators, 2-1 shift instructions, 4-5 SHL, 4-9 SHR, 4-9 SI register, 4-1 SIMFORM directive (ASM-86), 3-10 slash, 2-2 space, 2-2 special characters, 2-1 specifiers, 5-3 SR (Search) Command (DDT-86), 6-12 SSEG Directive, 3-3 stack segment, 2-7, 3-1, 3-3 starting ASM-86, 1-2, A-I starting DDT-86, 6-1 statements, 2-16 STC, 4-17 STD, 4-17 STI, 4-17 STOS, 4-11 string constant, 2-4 string operations, 4-10 SUB, 4-7 symbol table, 5-1 symbols, 2-4, 2-6, 3-5 ° T T (Trace) Command (DDT-86), 6-12, 6-16 tabs, 2-1 TEST, 4-9 TITLE directive (ASM-86), 3-9 tokens, 2-1 type, 2-7 type2 segment value, 6-16 DIGITAL RESEARCH™ - - - - - - - - - - - - - - - - - - - - - - - Index-S u U (Untrace) Command (DDT-86), 6-13, 6-16 unary operators, 2-13 underscore, 2-2 v V (Value) Command (DDT-86), 6-13 variable manipulators, 2-8, 2-10, 2-13 variables, 2-7 w W (Write) Command (DDT-86), 6-14, 6-16 WAIT, 4-17 WORD, 2-5, 2-7, 6-18 x X (Examine CPU State) Command (DDT-86), 6-14, 6-16 XCHG, 4-4 XLAT, 4-4 - - - - - - - - - - - - - - - - - - - - - - [lID Index-6 DIGITAL RESEARCH™ Reader Comment Card We welcome your comments and suggestions. They help us provide you with better product documentation. Date _ _ _ _ _ First Edition: March 1983 1. What sections of this manual are especially helpful? 2. What suggestions do you have for improving this manual? What information is missing or incomplete? Where are examples needed? 3. Did you find errors in this manual? (Specify section and page number.) Concurrent CP / M-8(YM Operating System Programmer's Utilities Guide COMMENTS AND SUGGESTIONS BECOME THE PROPERlY OF DIGITAL RESEARCH. ------ ---:-~--~--~-.:--------- ----- -~ -.~-- --- -~--:o-'--------- From:----------------------- ~------- NO POSTAGE NECESSARY IF MAILED IN THE UNITED STATES BUSINESS REPL V MAIL FIRST CLASS / PERMIT NO. 182 / PACIFIC GROVE, CA POSTAGE WILL BE PAID BY ADDRESSEE [!ill DIGITAL RESEARCHTW P.o. Box 579 Pacific Grove, California 93950 Attn: Publications Production -

Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.3
Linearized                      : No
XMP Toolkit                     : Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:56:37
Producer                        : Adobe Acrobat 9.2 Paper Capture Plug-in
Modify Date                     : 2010:01:05 14:37:20-08:00
Create Date                     : 2010:01:05 14:37:20-08:00
Metadata Date                   : 2010:01:05 14:37:20-08:00
Format                          : application/pdf
Document ID                     : uuid:200ee2eb-7797-48b8-9a65-382cec57de0a
Instance ID                     : uuid:e1e4d547-788b-419b-af47-c9d630b40b21
Page Layout                     : SinglePage
Page Mode                       : UseNone
Page Count                      : 147
EXIF Metadata provided by EXIF.tools

Navigation menu