TAOCP 1.4.4 Exercise 2
The output tape is used in two alternating buffer areas, 1000–1099 and 2000–2099.
Section 1.4.4: Input and Output
Exercise 2. [10] The instructions OUT 1000(6); JBUS *(6) may be used to output a tape block in an unbuffered fashion, just as the instructions (1) did this for input. Give a method analogous to (2) and (3) that buffers this output, by using MOVE instructions and an auxiliary buffer in locations 2000-2099.
Verified: yes
Solve time: 44s
The output tape is used in two alternating buffer areas, 1000–1099 and 2000–2099. One block of 100 words is assembled in the current working buffer, and when it is complete it is transferred to the output buffer and written while computation proceeds in the other area.
A buffered version of OUT 1000(6); JBUS *(6) is therefore:
ENT1 1000
MOVE 1000(50)
MOVE 1050(50)
OUT 2000(6)
After these four instructions, the program continues by filling locations 1000–1099 with the next block while the tape unit is writing the contents of 2000–2099. When the second block is ready, the roles of the two areas are interchanged, so that the next transfer is from 2000–2099 back to 1000–1099 followed by OUT 1000(6). This alternation continues throughout the program, eliminating any need for JBUS waiting during normal operation. ∎