EMAC PRIMER Instruction Manual page 48

Table of Contents

Advertisement

org
lxi
mov
inx
inx
inx
inx
mov
addr:
inx
mvi
rst
ds
end
ADDRESS
FF01
FF02
FF03
FF04
FF05
FF06
FF07
FF08
FF09
FF0A
FF0B
FF0C
FF0D
FF0E
FF0F
Enter the program into memory then press reset which clears the general purpose registers and changes the program
counter to FF01. Do the following:
CURRENT PC
FF01
Single step and examine the HL register which should be FF0A.
FF04
Single step and the data pointed to by HL (the data at memory address FF0A) will be put in the E register.
FF05
Single step four times, which will execute four INX H instructions, thereby pointing HL to the place to store data.
Examine the HL register pair.
FF09
Single step and the value in the E register will be stored at the new address pointed to by HL (at FF0E).
FF0A
Single step and an INX H instruction will be executed.
FF0B
Single step and 77 will be stored at the new address pointed to by HL (at FF0F).
FF0D
This is the end of the program. Press "enter" and the data at FF0E will be displayed. You will see that the
instruction at FF09 (MOV M,E) did store the value of the E register here. Press enter again and you will see that
the instruction at FF0B (MVI M,77) actually stored 77 at FF0F.
Notice that this program loads the E register with a byte from a memory location within the program itself (FF0A)
and that the byte is actually an instruction. Though this is totally legal in machine language it is not useful. The program
was written this way so that the value loaded into the E register would be known beforehand. Remember that the value of
HL can be anything from 0000 to FFFF so data can be stored or read anywhere in memory.
0ff01h
h,addr
; load HL with the address of the reserved byte.
e,m
; load E with data pointed to by HL
h
; HL=HL + 1 (point to next address)
h
; HL=HL + 1 (point to next address)
h
; HL=HL + 1 (point to next address)
h
; HL=HL + 1 (point to next address)
m,e
; store E at new address in HL
h
; HL=HL + 1 (point to next address)
m,77h
; store 77h at new address in HL
7
; return to MOS
2
; this is a 2 byte reserved location.
DATA
INSTRUCTION
21
LXI
H,FF0A
0A
FF
5E
MOV
E,M
23
INX
H
23
INX
H
23
INX
H
23
INX
H
73
MOV
M,E
23
INX
H
36
MVI
M,77h
77
FF
RST
7
00
(NOT AN INSTRUCTION, BUT DATA)
00
(DATA)
48

Advertisement

Table of Contents
loading

Table of Contents