GATE / CS ARCHIVE

GATE CSE 1997 / QUESTION 7(b)

Generate a seven-cycle square wave

Computer Organization & Architecture · Input/Output, DMA & Interrupts · Full GATE CSE 1997 paper

GATE 1997, Q7(b) 2 marks · Descriptive
Report issue

Input/Output, DMA & Interrupts

Question 7(b), GATE 1997: An 8085 must drive a one-bit output port at I/O address FF hexadecimal through a D flip-flop. The transferred bit is D3, and the output must clear at power-on. Write an 8085 program producing equal ON and OFF intervals of seven bus/machine cycles each.
Question 7(b), GATE 1997: An 8085 must drive a one-bit output port at I/O address FF hexadecimal through a D flip-flop. The transferred bit is D3, and the output must clear at power-on. Write an 8085 program producing equal ON and OFF intervals of seven bus/machine cycles each.
Tap to enlarge
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 LOOP

CMA 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.

Original paper, page 6