Input/Output, DMA & Interrupts



Answer & solution
Answer: HL = number of gated clocks; width ≈ HL/f. (no official key was published)
Use the 8253 design in part (a), with pulse bit 0 readable at port 90h. Control byte 30h selects counter 0, low-byte then high-byte access, mode 0 and binary counting. Load FFFFh. After the falling edge, control byte 00h latches counter 0 without changing its mode; read low byte first.
WAITLOW: IN 90H
ANI 01H
JNZ WAITLOW
MVI A,30H
OUT 83H
MVI A,0FFH
OUT 80H
OUT 80H
WAITHIGH:IN 90H
ANI 01H
JZ WAITHIGH
WAITEND: IN 90H
ANI 01H
JNZ WAITEND
MVI A,00H
OUT 83H
IN 80H
MOV E,A
IN 80H
MOV D,A
MVI A,0FFH
SUB E
MOV L,A
MVI A,0FFH
SBB D
MOV H,A
HLTDE receives the frozen count N. SUB/SBB perform the 16-bit subtraction FFFFh−DE, leaving the elapsed clock count in HL. The SUB's borrow is retained across MOV and MVI, so SBB correctly handles the high byte. Divide this integer by the known clock frequency to obtain seconds; for f=1 MHz each count represents roughly 1 μs.
This is not an unrestricted pulse-capture instrument: the pulse must start only after both count bytes are written and the subsequent complete CLK rising-and-falling loading sequence has occurred. A source-side guard/ready handshake enforces this requirement; the software does not issue a timer-ready signal. Also allow at least one clock period plus the specified propagation margin after the falling edge before the latch command. Choose the external clock relative to the 8085 clock so the displayed polling/readout path already provides that settling interval, or insert a calibrated delay before OUT 83H. The pulse must last long enough to be seen by WAITHIGH, remain low during readout, and not exhaust the initial counter value. Otherwise missed pulses or wrap/terminal-count behavior invalidate the result. A ready handshake, external trigger latch and overflow indication are appropriate extensions. The answer explicitly uses a timer peripheral, whose gate capture avoids treating variable software latency as measured time.