home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
cpm
/
utils
/
asmutl
/
asmbly.tzt
/
ASMBLY.TXT
Wrap
Text File
|
1988-01-30
|
6KB
|
117 lines
CP/M - ASSEMBLY LANGUAGE
by Stanley M. Gee, PUGSKUG, August 1987
(Assembly language primer for CP/M)
Assembly language programing, while not difficult, is tedious and
slow for most beginners. You may wonder why, if assembly
programing is so tedious and slow, it is used almost universally
by the computer industry. Assembly language programs are written
in machine coding and run faster. Unlike a higher level language
like basic, the programmer in assembly language must have an
understanding of the computer architecture. Memory locations
which are taken care of by the basic software are the
responsibility of the assembly programmer.
There are several books written on assembly programming and I
would recommend that any one truly interested in learning
assembly language programming obtain any or all of the books
available and study them in earnest. Also there are courses
taught in assembly language programming which will assist the
neophyte in learning about this primitive language.
Assembly language programs can be written with the CP/M editor
(Ed. note: if you're a masochist!), a Word Processor like Perfect
Writer or with the CP/M Dynamic Debugger Tool (DDT). After the
program is written with a word processor or the editor, it must
be compiled with ASM.COM. If successful the HEX file generated
by the compiler must be loaded with LOAD.COM which generates the
machine coding. The program is then executable after it is
loaded.
If the program is written using the DDT.COM it must be saved with
the SAVE.COM. Simple programs can and should be written with the
DDT utility. However programs written with the DDT utility will
not have a comment field. Large programs should be written using
your word processor. The DDT utility must be used if you do not
have the source or original program listing.
The source file for an assembly language is normally divided into
five fields. Each field is separated by spaces or a tab
character. The separation of the fields makes for a more
readable source program. The first field contains program line
numbers. These line numbers are ignored by the Assembler and is
optional. The second field contains labels much like the labels
in a Fortran program. The labels can be 16 characters long (Ed
note: depending on the assembler) and must start with a letter.
A colon may follow the label. A label is optional except when it
is used in the operand field. A label should appear only once in
the label field; however it may appear in the operand field many
times.
The third field contains Mnemonics, which is a fancy term for
name and is not optional. The fourth field is the Operand field
which requires one or more operands, however some Mnemonics do
not require an operand. This field can be occupied by a label,
constant or an expression. The fifth column is for Comments and
begins with a semi-colon. This field is also optional; however,
it is good programming practice to comment your programs.
A numerical constant is a fixed number which can be binary,
octal, decimal or hexadecimal. Dollar signs can be used as
delimiters within the numerical constants. A string constant is
a series of characters delimited by apostrophe symbols.
Delimiter is a fancy programming term which means a special
character used to block off a series of characters or numbers,
much like the use of the apostrophe symbols. Delimiter is a
fancy programming term which means a special character used to
block off a series of characters or numbers, much like the use of
the apostrophe in marking of quotations.
Arithmetic and logical operators are also possible. A single
dollar sign, when used as an operand, causes the current value of
the location counter to be used.
Lastly there are the assembler directives. DB = define byte, DW
= define word and DS = define storage. These directives
initialize storage areas in memory. The DB statements are stored
as 8-bit values and the DW statement is stored as 16 bit values.
The low-order bit is stored first then the high-order bit. DS is
evaluated and the number of memory locations is reserved. ORG =
start address of the instructions following. End = end of source
program. EQU = assignment of a value to a label. IF and ENDIF =
conditional branching when IF is true.
The assembly language source file must have an .ASM extension.
Upon completion of the program it must be compiled with the ASSY
compiler. The correct syntax is "ASSY Filename.shp <cr>". SHP
breaks down as follows: "S" is the disc drive where the HEX file
will reside. "H" and "P" can be substituted with a "Z" to skip
the generation of the files. "X" can be substituted for the "P"
to send the PRN file to the lineprinter.
After entering the ASM command the computer will respond with
CP/M ASSEMBLER - VER 2.0 followed by any error message. When the
assembler is finished it will return a hexadecimal address of the
first free space following the assembly language program, a use
factor of the symbol table area and an end of assembly message in
the following format.
XXXX
yyyH USE FACTOR
END OF ASSEMBLY
If errors are encountered they must be corrected and the program
must be recompiled.
Upon successful compilation, the program must then be loaded with
the LOAD command. The correct syntax is A>LOAD B:PROGRAM<CR>
The computer will respond with
FIRST ADDRESS 0100
LAST ADDRESS 0345
BYTES READ 0244
RECORDS WRITTEN 02
If the load was successful the Program can now be executed.