You are on page 1of 1

EED 3018 LABORATORY

EXPERIMENT 5:

Z80 I/O OPERATIONS

Preliminary Work
Read about IN and OUT instructions.
Exercise : Write a program to multiply by addition the contents of register B and register C. Assume that result is 8-bit long. The
result should be held in the accumulator: A = B x C

Laboratory Work

1. Write a program to test the I/O ports of the simulator. Get data
from PORT1 and send it to PORT2, and vice versa (from PORT2
to PORT1). Let the I/O addresses of PORT1 and PORT2 be 01H
and 02H, respectively, in your program. Dont forget to place
your code inside an infinite loop. Why? (think about it!)
Create PORT1 and PORT2 in the simulator using virtual machine
tool:
ViewVirtual MachineLatch
A latch window will open. Let it be PORT1, an input port such as
a buffer with its outputs connected to the Z80 data bus, and with
its inputs connected to a set of switches. Open a second latch
window for the output port PORT2, a latch with its inputs
connected to the Z80 data bus, and with its outputs connected to a
set of LEDs. Your program must reflect every number entered by
switches onto the LEDs. Next, exchange the roles of PORT1 and
PORT2 in your program and test it again.

switches

LEDs

PORT1

PORT2

2.

PORT1

.
.
.

0
7

PORT2

.
.
.

}Number 1
}Number 2

Result

Write a program to multiply the 4-bit most significant data, Number 1, by the 4-bit
least significant data, Number 2, of PORT1. Output the result from PORT2. Note that
PORT1 should be used as an input port whereas PORT2 as an output port. Place your
code inside an infinite loop. Test your program in the simulator by applying different
pairs of values for Number 1 and Number 2 (see the example below). Make use of the
program code you have written in the exercise of the preliminary work.
Number 1

Number 2

Result

0
Result = Number1 Number2

PORT1

PORT2

You might also like