Sie sind auf Seite 1von 1

EED 3018 LABORATORY

EXPERIMENT 8:
NON-MASKABLE INTERRUPT and SIMPLE I/O with Z80 PIO
Preliminary Work

main program:

Read about non-maskable interrupt and Z80 PIO operation modes; mode 0
(byte output ) and mode 1(byte input)
Exercise : (a) Assume that an output port with I/O address 01H is connected
with 8 LEDs. Write a main program in which: initialize SP to 0105H and the
accumulator to 1, and then repeat steps 1-2 in an infinite loop,
1. send the contents of accumulator to the output port
2. rotate left one bit contents of the accumulator
to form a running light effect at the output port.
(b) Write a non-maskable interrupt service routine (NISR) for Z80 that flashes
all LEDs at the output port five times (one flash means first turn ON then turn
OFF). You must ensure (by assembler directives) that your NISR be located
in the correct memory location so that it will run when non-maskable
interrupts occur.

LOOP OUT(01H),A

Non-maskable interrupt service routine:

PUSH AF

Laboratory Work

1. Non-maskable interrupts: Type in the simulator all your program code


(written for the Exercise) for testing. Create an ouput port (with LEDs connected)
in the simulator using virtual machine tool: ViewVirtual MachineLatch.
Execute the program at full speed, and check if the running light effect is working.
Click on NMI button in the registers window to request a non-maskable interrupt,
and check if the LEDs have flashed five times. Check if the running light effect
continues later.
Fill in the table given below after running your program in single-step mode.
event

instruction at the time


of event

NMI has occurred (its buton


has been clicked)

OUT (01),A
(in M1 cycle)
1st instruction of NISR has PUSH AF
been fetched (in M1 cycle)
last instruction of NISR has
been executed (after M1 cycle)
- the NISR completed
Back to the main program

PC

POP AF

top of stack: SP

(SP) contents of the top of the stack

0105H

RETN
RLCA

2. Simple I/O for data echoing on PIO (without interrupt): Create a PIO in the simulator and check the Set box in Address Decoder
section when switches are at the initial position. This configuration sets I/O addresses 00H for Port A Data register, 01H for Port B Data
register, 02H for Port A Control register, and 03H for Port B Control register. Set port A as input port and port B as output port (write the
necessary instructions that send the correct mode control words to port registers).

You do not have to disable interrupts from the both ports because they are disabled (see the status INT Disabled) when the PIO is reset
(or powered on). The task is to send each incoming data at the port A to the port B (data echoing in an infinite loop):

Test your program by executing it at the highest clock rate in the simulator for each of the following connection choices (i) and (ii);
i) connecting an input line to port A, and a LED line to port B (set Ready Delay to zero); you have to press the 'Set' button in the Line
Input box to pass the entered data to the port data bus.
ii) connecting a keyboard to port A and a green screen to port B (set Ready Delay to zero). You have to make the Keyboard box
(window) active to be able to enter ASCII code of any pressed key.

Das könnte Ihnen auch gefallen