Input/Output, DMA & Interrupts


Answer & solution
Answer: Decode I/O address 40H, use an output latch, handshake flags and status tri-state buffer; poll bit 7 before each of 512 OUT operations. (no official key was published)
Use an 8-bit equality decoder for address 40H gated by IO/M=1. Let SEL denote that I/O decode. Form /W=NOT(SEL AND NOT /WR) and /R=NOT(SEL AND NOT /RD). Thus memory access at 0040H cannot accidentally activate the port. The shared address is safe because read and write select different circuitry.
Schematic
A[7:0],IO/M → address decoder → SEL → /W, /R gating.
CPU D[7:0] → 8-bit latch (transparent while /W=0) → DEVICE DATA.
/W falling → clear INTERRUPT; /W rising → close data latch, set BUFFULL.
/STROBE falling → clear BUFFULL; /STROBE rising → set INTERRUPT.
{INTERRUPT,0,0,0,0,0,0,BUFFULL} → tri-state buffer, enabled only by /R=0 → CPU data bus.
One implementation uses a BUFFULL D flip-flop with D=1 clocked by rising /W and asynchronously cleared while /STROBE=0. INTERRUPT uses D=1 clocked by rising /STROBE and asynchronously cleared while /W=0. Initialize BUFFULL=0 and INTERRUPT=1 when the device is ready. The external handshake must avoid overlapping write/acknowledge pulses that violate the flip-flops’ recovery times. Device data is stable after write completion and held until a later write. The timing diagram’s arrows refer to these separate leading/trailing edges, not merely inverse full/empty flags.
8085 program (hexadecimal literals):
LXI H,3400H
LXI B,0200H
WAIT_READY:
IN 40H
ANI 80H
JZ WAIT_READY
MOV A,M
OUT 40H
INX H
DCX B
MOV A,B
ORA C
JNZ WAIT_READY
WAIT_LAST:
IN 40H
ANI 80H
JZ WAIT_LASTBC counts 512 bytes; HL visits 3400H through 35FFH. The source RAM region for this subproblem must exist; it is independent of the smaller RAM map specified in part (a). Testing bit 7 waits for completion of the device strobe, whereas bit 0 can clear earlier at strobe assertion. The final loop waits for the last acknowledgement rather than returning with the final byte merely buffered. There is no timeout in this minimal program, so a nonresponsive device blocks indefinitely. Reading the status port does not clear either flag.