Input/Output, DMA & Interrupts


Answer & solution
Answer: MVI A,00H; LOOP: CMA; OUT FFH; JMP LOOP. Each steady-state half-period is 1+3+3=7 machine cycles. (no official key was published)
Only accumulator bit 3 affects this one-bit port. Complementing the entire accumulator is therefore enough to toggle the output: bit 3 alternates between 0 and 1. One program is
MVI A,00H
LOOP: CMA
OUT FFH
JMP LOOPCMA takes one machine cycle, OUT takes three, and an unconditional JMP takes three. Between the end of one OUT and the end of the next OUT, the processor executes JMP, CMA and OUT. The total is 3+1+3=7 machine cycles. The same instruction path is used whether D3 is changing from 0 to 1 or from 1 to 0, so both steady-state half-periods are equal. At the FFH output port, values FFH and 00H alternate, but only their D3 bits are stored.
The initialization MVI is outside the loop and does not contribute to repeated periods. Power-on clearing ensures the initial output is low; the interval from reset release to the very first transition need not equal a later half-period. Interrupts and inserted wait states must be absent if exact timing is required.
Here “bus cycles” is interpreted as the 8085 machine-cycle count, not seven clock T-states. The instructions take 4+10+10=24 T-states in a normal execution, so a complete square-wave period is 14 machine cycles, or 48 T-states. Counting instruction bytes or taking “7” as seven T-states would give the wrong timing model.