DMA

How do I do a DMA memory-to-memory transfer in ASM?

I'm trying to get it to work under plain MSDOS. I have it on a bootable floppy.

I got this snippet of code from Intel's site, but I don't know what ports D0CON, D0SRCL, D0SRCH, D0DSTL, & D0DSTH are. I figure this code might be for MASM and those variables are pre-initialized ones. HELP!




$MOD186

NAME DMA_EXAMPLE_1


CODE_SEG SEGMENT

ASSUME CS:CODE_SEG


START: MOV AX, DATA_SEG ; DATA SEGMENT POINTER


MOV DS, AX

ASSUME DS:DATA_SEG


; First we must initialize DMA channel 0. DMA0 will

; an unsynchronized transfer from SOURCE_DATA_1 to

; DEST_DATA_1. The first step is to calculate the

; proper values for the source and destination

; pointers.


MOV AX, SEG SOURCE_DATA_1


ROL AX, 4 ; GET HIGH 4 BITS

MOV BX, AX ; SAVE ROTATED VALUE

AND AX, 0FFF0H ; GET SHIFTED LOW 4


; NIBBLES


ADD AX, OFFSET SOURCE_DATA_1


; NOW LOW BYTES OF

; POINTER ARE IN AX


ADC BX, 0 ; ADD IN THE CARRY

; TO THE HIGH NIBBLE

AND BX, 000FH ; GET JUST THE HIGH

; NIBBLE

MOV DX, D0SRCL

OUT DX, AX ; AX=LOW 4 BYTES


MOV DX, D0SRCH

MOV AX, BX ; GET HIGH NIBBLE

OUT DX, AX


; SOURCE POINTER DONE. REPEAT FOR DEST.


MOV AX, SEG DEST_DATA_1


ROL AX, 4 ; GET HIGH 4 BITS

MOV BX, AX ; SAVE ROTATED VALUE

AND AX, 0FFF0H ; GET SHIFTED LOW 4

; NIBBLES


ADD AX, OFFSET DEST_DATA_1


; NOW LOW BYTES OF

; POINTER ARE IN AX


ADC BX, 0 ; ADD IN THE CARRY

; TO THE HIGH NIBBLE

AND BX, 000FH ; GET JUST THE HIGH

; NIBBLE

MOV DX, D0DSTL

OUT DX, AX ; AX=LOW 4 BYTES


MOV DX, D0DSTH

MOV AX, BX ; GET HIGH NIBBLE


OUT DX, AX


; THE POINTER ADDRESSES HAVE BEEN SET UP. NOW

; WE SET UP THE TRANSFER COUNT.


MOV AX, 29 ; THE MESSAGE IS

; 29 BYTES LONG.

MOV DX, D0TC ; XFER COUNT REG

OUT DX, AX


; NOW WE NEED TO SET THE PARAMETERS FOR

; THE CHANNEL AS FOLLOWS:

;

; DESTINATION SOURCE

; ----------- ------

; MEMORY SPACE MEMORY SPACE

; INCREMENT PTR INCREMENT PTR

;

; TERMINATE ON TC, NO INTERRUPT, UNSYNCHRONIZED,


; LOW PRIORITY RELATIVE TO CHANNEL 1, BYTE XFERS.

; WE START THE CHANNEL


MOV AX, 1011011000000110B

MOV DX, D0CON

OUT DX, AX



CODE_SEG ENDS


DATA_SEG SEGMENT

SOURCE_DATA_1 DB 29 dup('A')

DEST_DATA_1 DB 29 dup('B')

DATA_SEG ENDS


END START





Comments

  • Unfortunantly, modern chipsets haven't supported mem-to-mem DMA transfers in

    some time. I have program straight from a system architecture book that demonstrates

    a mem-to-mem transfer. It doesn't work on my machine, but if you want to try it, go

    to the following part of my page (linked at the bottom):



    Go to my main page. (via the link)

    Go to the Turbo Pascal section.

    Download the Collection of Programs under Source.

    The .PAS file you'll want from that is DMA.PAS



    Matthew Gross

    [email protected]


    URL:http://acheronx.resnet.tamu.edu/home/

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories