EMAC PRIMER Instruction Manual page 79

Table of Contents

Advertisement

org
mos
equ
keyin
equ
ledhex
equ
start:
lxi
rdkey:
mvi
call
mvi
cmp
jc
mvi
dad
xchg
jmp
dsplay:
mvi
call
jmp
end
To change the assembly language program to machine language, get some ruled paper and on the top line put the
headings:
ADDRESS
On the first line under the address heading, put the hex address of the start of the program (in this case FF01). The
instruction LXI D,0 will go under the heading "INSTRUCTION" and the op code for the instruction (11) will go under the
heading
"data". According to the instruction's definition, the data that will be loaded in the DE register pair will follow the op code in
the next two memory addresses. Since the data that is to be loaded into DE is 00, put on the next line the address FF02
and put 00 under the "DATA" heading. Do the same on the next line except put FF03 under the "ADDRESS" heading. You
see that each line represents a memory address just as in the machine language listings in the previous lessons. Your list
should look like this so far.
ADDRESS
FF01
FF02
FF03
To convert the rest of the program to machine language it will probably be easier to get the op codes from appendix C than
to search for them in the previous lessons. The op code for the instruction MVI C,KEYIN can be found in the first
mnemonic column and its op code (0E) can be found in the column to the left of it. You will notice that the mnemonic in the
table is MVI C,D8. The D8 is not hex number D8, it means that the 8085 expects 8 bits (a byte) of data to follow the op
code. In the case of the instruction we are now translating, the data following the op code is the value assigned to "keyin"
by instruction EQU, which is 0B hex.
In the same mnemonic column, below MVI C,D8 is the instruction LXI D,D16 which we already translated to machine
language. The D16 means that the 8085 will expect 16 bits (two bytes) to follow the op code of the instruction. Also within
the table you will see instructions that have the abbreviation "Adr" in them (like JMP Adr). These instructions also expect
two bytes of data to follow the op code, but in this case the data represents an address. The byte following the op code is
the least significant byte of the address and the one after that is the most significant byte. If you encounter "Adr" as part of
an instruction, most of the time it is necessary to wait until the program is almost completely translated before you can
know the values to use for "Adr". Go ahead and put addresses in the address field, but leave the data field blank until later.
Below is a listing of the machine language version of the program with the unknown "Adr"s left blank.
ADDRESS
FF01
FF02
FF03
FF04
FF05
FF06
FF07
FF08
FF09
FF0A
FF0B
continued on next page...
0ff01h
1000h
; start address of MOS subroutines
0bh
; service # of keyin
12h
; service # of ledhex
d,0
; clear the total in DE
c,keyin
; C = keyin service number
mos
; load L with key from keypad
a,0fh
; max value of keys
l
; compare to key from keypad
dsplay
; display the value if L>F
h,0
; clear the H register
d
; add total to HL
; put HL in DE
rdkey
; get another key
c,ledhex
; c = keyin service number
mos
; display total in DE
start
; go to start again
DATA
INSTRUCTION
DATA
INSTRUCTION
11
LXI
00
00
DATA
INSTRUCTION
11
LXI D,0
00
00
0E
MVI
0B
CD
CALL
00
10
3E
MVI
0F
BD
CMP
D,0
C,0B
1000
A,0F
L
79

Advertisement

Table of Contents
loading

Table of Contents