EMAC PRIMER Instruction Manual page 21

Table of Contents

Advertisement

characters "dips" represents the value 12 hex, so line 7 which says "in dips" means, load the A register with the data from
input port 12 hex ( which is the DIP switch port ). As you can see, this is more readable than its assembly language
equivalent "in 12h". The value of a symbol is assigned using the EQU instruction. The symbol on the left of the instruction
is assigned the value on the right. As you can see in line 1 "dips" is assigned the value 12 hex and in line 2 "num" is
assigned the value 4 decimal which is the same as 04 hex. Most assemblers assume that a number is decimal unless it is
otherwise noted. Binary numbers are indicated by ending with a "b" or "B". Hex numbers must begin with a decimal
number and end with "h" or "H". If they don't begin with a decimal number, the assembler will think they are labels, as in
the case of the hex numbers DEAFh or BADh (they look like words instead of numbers). Start the hex numbers with 0 to
solve this problem (0DEAFh, 0BADh).
The ORG mnemonic tells the assembler the starting address in memory of the instructions that follow it. Line 3 shows that
the program is to be assembled starting at address FF01.
The DS mnemonic tells the assembler to set aside the number of bytes of memory specified by the value to the right of the
mnemonic. This memory is reserved for the storage of data instead of machine language.
The mnemonic DB takes the data that follows the mnemonic and stores the hex value(s) of the data in memory. The
values can be binary, hex or decimal numbers or a mixture of these but each number always uses one byte of memory. If
the number is too large to be stored in one byte of memory the assembler will give an error message. In line 17 of the
example program above, the first byte of data following the mnemonic is stored at the first memory location following the
four bytes reserved by the DS mnemonic. The rest of the data on the line follow it sequentially in memory.
When a symbol is in the label field of a certain line, and the mnemonic for that line isn't "equ", its value will be made the
memory address of the op code represented by the mnemonic. In line 7 of the program above, "loop" is assigned the value
of the memory address of the op code of the "in" mnemonic. Line 12 uses the value of the label "loop" to produce the
machine language for the "jnz" instruction. In line 15 the label "dtaspac" is assigned the value of the memory address of
the first byte of the bytes reserved by the DS mnemonic. In line 4 the value of "dtaspac" is used to produce the machine
language for the "LXI H" instruction.
Every character after a semicolon is considered a comment. Comments are used to describe the workings of a program to
a person who might be reading the assembly language. They have no effect on the program because when the assembler
encounters the ';' it ignores the rest of the characters on the current line.
The mnemonic END tells the assembler that this is the end of the program. The mnemonics END, EQU, ORG, DB and DS
are all called "pseudo-ops", which means they are not translated into machine language directly. These are used by the
assembler to aid in assembling the machine language. Lines 4 through 14 contain mnemonics that actually correlate
directly to machine language.
21

Advertisement

Table of Contents
loading

Table of Contents