🎓 BookMCQ
← Back to 12. Direct Memory Access Controller: 8257

📝 Programming of 8257 (16 MCQs)

Register Preparation Before Enabling a DMA Channel

Programming the 8257 requires software to load each selected channel's 16-bit starting address and terminal count register before enabling it. The terminal count contains a 14-bit value equal to the required number of bytes minus one, together with two operation bits. The controller also provides a mode set register for channel enabling and operating options.

Register Selection Through A0–A3 and the First/Last Flip-Flop

Address inputs A0–A3 select the required register. A3 = 0 selects channel registers, while A3 = 1 selects the mode set or status register. A2–A1 identify the channel and A0 distinguishes its address register from its terminal count register. The internal F/L flip-flop selects the low or high byte of a 16-bit register.

Low-Byte-First Programming and Operation Selection

After RESET, the F/L flip-flop is in its first-byte state. The processor writes the low-order byte first and the high-order byte second; the flip-flop toggles after each access. This paired sequence is required for both address and terminal count registers. The mode set register is programmed after the channel parameters are valid.

Example of Programming Channel 0 for a 256-Byte DMA Write

Assume port 80H selects channel 0 address, 81H selects its terminal count and 88H selects mode set. Write 00H then 40H to 80H for address 4000H, followed by FFH then 40H to 81H for count 255 and write operation. Finally, write 01H to 88H to enable channel 0.

Coordinating DMA Direction, Block Length and Channel Activation

The terminal count's D15–D14 bits select verify, write or read operation, while D13–D0 specify the count. For 256 bytes, the count is 00FFH; combining it with the write code 01 gives 40FFH. Only after both channel registers are loaded should software enable the channel through the mode set register.

Programming Errors Involving Byte Order and Register Selection

'The high byte must be written first' is incorrect because the F/L sequence requires the low byte first. 'The mode set register is selected by A0 alone' is incorrect because A3 selects the mode/status register area. 'A count of 256 is loaded directly' is incorrect because the 14-bit field receives 255 for a 256-cycle block.

Register Addressing and DMA Count Problems for Examinations

Practise decoding A3–A0, identifying each channel register and tracking the F/L flip-flop. Convert a 16-bit memory address into low and high bytes, calculate N minus one, and place the correct operation code in D15–D14. Check that the mode word is written only after channel parameters have been initialized.

Programming Sequence and Register Access Terms

  • F/L Flip-Flop - Selects successive register bytes.
  • A3 - Selects channel or mode/status register.
  • A0 - Selects address or count register.
  • LOB - Low-order register byte.
  • HOB - High-order register byte.
  • Count Field - Stores required cycles minus one.
  • Mode Word - Enables configured DMA channels.
4
Easy
6
Medium
6
Hard

📝 All Programming of 8257 MCQs

Q1. A peripheral requests a block transfer of 256 bytes using the 8257 DMA controller. Which register must be loaded with the value 256 to specify the number of bytes to transfer?

A.Address Register
B.Count Register ✅
C.Control Register
D.Status Register
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The count register stores the number of bytes remaining in a DMA block, so loading it with 256 tells the controller to move exactly that many bytes. The address register holds the start address, not the length, while the control register defines mode and the status register reports conditions. In a real system, setting the count correctly ensures the peripheral receives the full data block without overrunning memory.

Q2. What is the maximum number of independent DMA channels that the Intel 8257 can provide?

A.4 ✅
B.2
C.8
D.16
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The 8257 is designed with four separate channels, allowing four distinct peripheral devices to perform DMA transfers concurrently or sequentially. Options listing 2, 8, or 16 channels describe other controllers but not the 8257. Knowing the channel count helps engineers plan how many devices can be directly attached to the DMA controller without additional hardware.

Q3. Why does employing DMA generally increase data transfer speed compared with programmed I/O?

A.It uses higher clock frequency
B.It bypasses cache
C.It reduces memory latency
D.It frees the CPU from moving each byte ✅
💡 Difficulty: easy | ✅ Correct: D

📖 Explanation: DMA offloads the byte‑by‑byte movement from the CPU; the controller takes control of the bus and transfers whole blocks automatically. The other choices describe unrelated mechanisms: clock speed, cache, and latency are not changed by DMA. By freeing the CPU, a system can perform other tasks while data moves, leading to higher overall throughput.

Q4. The CPU sets the address register of channel 2 to 0x2000 and programs the count register for 1024 bytes. After the DMA block transfer completes, what value will the address register contain?

A.8192
B.9215
C.9216 ✅
D.10239
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: During a block transfer the address register increments by one for each byte transferred. Adding 1024 (0x400) to the start address 0x2000 yields 0x2400, which is the value stored after the transfer. The original address (0x2000) would remain unchanged only if the controller did not increment, and 0x23FF is one byte short of the correct final address. This behavior is essential when chaining multiple DMA blocks.

Q5. In the 8257 count register, the two most significant bits are used to indicate which of the following?

A.Interrupt priority
B.Read/write operation ✅
C.Auto‑initialization flag
D.Channel number
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The two most significant bits of the 14‑bit count field are reserved to specify whether the transfer is a read (memory‑to‑peripheral) or a write (peripheral‑to‑memory) operation. They do not control interrupt priority, auto‑initialization, or channel selection, which are handled by separate control bits. Understanding this encoding lets designers correctly set the direction for each DMA channel.

Q6. When the HRQ (Hold Request) line is asserted while the CPU is executing an interrupt service routine, what action does the 8257 take before beginning the DMA transfer?

A.It waits until the CPU releases the bus ✅
B.It forces the CPU to halt immediately
C.It aborts the transfer
D.It generates a bus error
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The 8257 follows a hand‑shaking protocol: HRQ signals a request for bus control, and the CPU must acknowledge with a HOLD acknowledgement before the DMA controller can assume the bus. The controller does not forcibly stop the CPU nor abort the transfer; it simply pauses until the CPU cooperates, preserving system stability during an ISR.

Q7. Which pin on the 8257 provides the DMA acknowledge signal to a peripheral device?

A.DACK0 ✅
B.DREQ0
C.HRQ
D.INTA
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: DACK0 (DMA Acknowledge) is the dedicated output that tells a peripheral its request has been granted and that the transfer may start. DREQ0 is the input request line, HRQ is the controller’s request to the CPU, and INTA is the CPU interrupt acknowledge line. Recognizing the correct pin is crucial for wiring the peripheral‑controller interface correctly.

Q8. Why does each DMA channel of the 8257 have its own 16‑bit address register instead of sharing a single address register among all channels?

A.To allow simultaneous transfers
B.To simplify hardware wiring
C.To keep track of independent source/destination addresses ✅
D.To reduce power consumption
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: Each channel may be moving data to or from different memory locations; a separate address register lets the controller maintain the correct pointer for each channel without interference. Sharing a single register would cause address collisions and incorrect data movement. The other options describe unrelated benefits that are not the primary reason for per‑channel registers.

Q9. Two devices share channel 1 using daisy‑chaining. Device A requests 300 bytes first, then Device B requests 500 bytes. The controller is programmed with a count of 800 bytes. Which device will finish its transfer first?

A.Device A ✅
B.Device B
C.Both finish at the same time
D.Transfer is aborted
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: In daisy‑chaining, the first request that reaches the controller gets service before later requests. Device A’s 300‑byte block will be transferred before Device B’s 500‑byte block, so Device A completes first. The controller does not interleave the two transfers, nor does it abort them, making the first‑in request the one that finishes earlier.

Q10. How does the 8257 cooperate with the CPU's bus arbitration signals to maintain data integrity during a block DMA operation?

A.It disables the CPU’s interrupts
B.It asserts HRQ and waits for the CPU’s HOLD acknowledgement before taking control of the bus ✅
C.It uses a separate data bus
D.It relies on error‑checking codes
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The 8257 follows the standard bus‑arbitration handshake: it raises HRQ, the CPU responds with a HOLD, and only after this acknowledgement does the DMA controller seize the address and data buses. This coordinated exchange prevents both the CPU and DMA controller from driving the bus simultaneously, thereby preserving data integrity. The other options describe mechanisms that are not part of the 8257 arbitration process.

Q11. When programming the 8257 to write data to a memory‑mapped I/O device located at address 0xFF00, how must the address register be set?

A.Load only the low byte 0x00
B.Load only the high byte 0xFF
C.Load the full 16‑bit value 0xFF00 ✅
D.No loading is required
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: The address register holds the full 16‑bit destination address for the DMA transfer; therefore the complete value 0xFF00 must be loaded. Supplying only the low or high byte would cause the controller to write to an incorrect location, and omitting the load would leave a stale address, leading to data being sent to the wrong peripheral.

Q12. What supply voltage is required for the proper operation of the 8257 DMA controller?

A.+3.3 V
B.+12 V
C.-5 V
D.+5 V ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: The 8257 is specified to operate from a standard +5 V DC supply, matching typical TTL logic levels used in 8085‑based systems. The other voltage options are incompatible and would either not power the chip or damage it. Knowing the correct supply voltage is essential for reliable hardware design and prevents premature failure of the controller.

Q13. What effect does setting the auto‑initialize (AI) bit in the 8257 control word have on a channel after the terminal count is reached?

A.The transfer stops permanently
B.The count and address registers are automatically reloaded for another transfer ✅
C.The CPU is interrupted after each byte
D.The DMA request line is disabled
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: When AI is set, reaching the terminal count triggers the controller to automatically reload the original count and address values, allowing the same block transfer to start again without CPU intervention. This is useful for repeated operations such as circular buffers. The other choices describe behaviors that are not produced by the AI feature.

Q14. During a DMA read cycle, the peripheral asserts DREQ, the controller asserts HRQ, and the CPU acknowledges. If the CPU fails to release the bus, what is the most likely system behavior?

A.DMA continues regardless
B.CPU completes its task and DMA starts later
C.The system enters a deadlock condition ✅
D.An error interrupt is generated
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: The DMA controller cannot take control of the bus until the CPU relinquishes it after acknowledging HRQ. If the CPU holds the bus, both the CPU and DMA controller wait for each other, creating a deadlock where no further progress occurs. The controller does not bypass the CPU, nor does it automatically generate an error; the system simply stalls.

Q15. What does the terminal count (TC) signal indicate in the operation of the 8257?

A.Start of a DMA transfer
B.Completion of the programmed block transfer ✅
C.Overflow of the address register
D.Change of transfer direction
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The terminal count line goes active when the count register reaches zero, signalling that the programmed number of bytes has been transferred. It does not indicate the start of a transfer, address overflow, or a direction change. Systems often use TC to generate an interrupt or to trigger auto‑initialization for the next block.

Q16. A programmer loads the control word 0x58 into the 8257 for channel 3 to perform a write operation of 1024 bytes. Which bits in the control word determine the transfer direction?

A.Bits 0‑1
B.Bits 2‑3
C.Bits 4‑5 ✅
D.Bits 6‑7
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: In the 8257 control word, bits 4 and 5 specify the D/A (direction) setting, where a particular combination selects a write (peripheral‑to‑memory) or read (memory‑to‑peripheral) operation. Bits 0‑1 identify the channel number, bits 2‑3 define the transfer mode, and bits 6‑7 are reserved for other functions. Correctly setting bits 4‑5 ensures the controller moves data in the intended direction.

🔗 Related Topics (MCQs)