| ECE291 | Computer Engineering II | Plavcan, Summer 1997 |
Lecture Z
The PC has two 8237 DMA Controllers, arranged in a Master/Slave organization:

| DMA Controller | Slave | Master | ||||||
| DRQ# | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| Memory Address Register I/O Address |
00h | 02h | 04h | 06h | C0h | C4h | C8h | CCh |
| Page Register | 87h | 83h | 81h | 82h | (none) | 8Bh | 89h | 8Ah |
| Count Register I/O Address | 1 | 3 | 5 | 7 | (none) | C6h | CAh | CEh |
| DMA Controller | Slave | Master |
| Control Register I/O Address | 08h | D0h |
| Mode Register I/O Address | 0Bh | D6h |
| Mask Register I/O Address | 0Ah | D4h |
| Clear Byte F/F I/O Address | 0Ch | D8h |

Programming the DMA controller is not a simple process, but it can be reduced to the following steps:
; Code to convert segment:offset to page:page_offset ; ; SI contains offset, ; DX contains segment : mov ax,dx mov cl,4 shl ax,cl ; shift segment left 4 shr dx,cl ; shift segment right 12 add si,ax ; add shifted segment to offset adc dh,0 ; Now SI contains the offset within the page, ; the low 4-bits of DH contain the page # ; Disable the DMA channel so we can set it mov ax,channel and ax,3 ; channel mod 4 or ax,MODE ; set mode bits out MASKREG,al ; write DMA mode ; Clear byte ptr F/F out BYTEREG,al ; any value to reset ; write mode to mode register mov al, mode out MODEREG,al ; write page offset to address reg. mov ax,si ; get offset in ax out ADDRREG,al ; write LSB of DMA offset mov al,ah out ADDRREG,al ; write MSB of DMA offset ; write length (-1) to count reg. mov ax,length ; ax=length-1 dec ax ; out COUNTREG,al ; write LSB of size mov al,ah out COUNTREG,al ; write MSB of size ; write page# to page register mov al,dh out PAGEREG,al ; write page ; re-enable the channel mov ax,channel and al,3 ; channel mod 4 out MASKREG,al ; enable sound card DMA ; now set up the target device... |
Creative Lab's SoundBlaster (and all other compatible cards) use DMA to transfer information between memory and the DSP (digital signal/sound processor) on the card. Modern sound cards support multiple DMA channels (for 16-bit transfers, and multiple record/playback for digital effects processing). The sound card can play sounds in the background without loading the system.
See Lecture X for more details on how to program the SoundBlaster.
See "ISA System Architecture" (Tom Shandley / Don Anderson, Mindshare Press) for more information on DMA.