home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cdisk.zip / DMA / WORD_DMA.ASM < prev   
Assembly Source File  |  1993-01-18  |  2KB  |  85 lines

  1.     title _word_dma
  2.     .286P
  3.     .model small
  4.     include    bsedos.inc
  5. ;
  6. ; dma set up and execute routine 
  7. ; written by: Steve Mastrianni
  8. ;
  9. ; word_dma(USHORT operation,      1=write, 2=read         [bp+4]
  10. ;       USHORT channel,      5, 6 or 7             [bp+6]
  11. ;       USHORT count,      0-65535 (0=1 word)         [bp+8]
  12. ;       ULONG address,     far to/from address         [bp+10,12]
  13. ;       USHORT auto,         0 for single, 1 for auto    [bp+14]
  14. ;       USHORT init)      0 no auto init, 1 auto init [bp+16]
  15. ;
  16. _text    segment public 'CODE'
  17.     assume    cs:_text,ds:NOTHING
  18.     public    _word_dma
  19.  
  20. _word_dma proc    near
  21.     push    bp        ;
  22.     mov    bp,sp        ;current frame pointer
  23.     cli            ;disable rupts during dma setup
  24.     push    bx
  25.     push    dx
  26.     mov    ax,[bp+6]    ;get channel number
  27.     sub    ax,4        ;minus 4 for second controller
  28.     mov    bx,[bp+4]    ;get mode byte and make command
  29.     shl    bx,2        ;make valid mode bits
  30.     or    ax,bx
  31.     mov    bx,[bp+14]    ;or in initialize bit
  32.     cmp    bx,0        ;autoinitialize selected?
  33.     jz    output        ;no
  34.     or    ax,010h        ;yes, add in autoinitialize bit
  35. output:
  36.     mov    bx,[bp+16]    ;block or single mode?
  37.     or    ax,40h        ;default single
  38.     cmp    bx,0
  39.     jz    single        ;single mode
  40.     and    ax,0bfh        ;make block mode
  41.     or    ax,080h
  42. single:
  43.     out    0d8h,al        ;set the first/last flip flop
  44.     jmp    short $+2    ;small delay
  45.     out    0d6h,al        ;output the mode byte
  46.     mov    dx,[bp+6]    ;get channel number
  47.     sub    dx,4        ;minus 4 for second controller
  48.     mov    ax,08ah        ;set page register
  49.     add    ax,dx        ;
  50.     push    dx        ;save port temp
  51.     mov    dx,ax        ;put page register address in dx
  52.     mov    ax,ds        ;high page address
  53.     out    dx,al        ;do it
  54.     pop    dx
  55.     rol    dx,2        ;times 4 for proper address
  56.     add    dx,0c0h        ;this is port address
  57.     mov    ax,[bp+10]    ;low offset address
  58.     out    dx,al
  59.     jmp    short $+2
  60.     mov    al,ah        ;now high part
  61.     out    dx,al        ;do it
  62.     jmp    short $+2
  63.     add    dx,2        ;formulate count address
  64.     mov    ax,[bp+8]    ;put low and
  65.     out    dx,al        ;high count to controller
  66.     jmp    short $+2
  67.     mov    al,ah
  68.     out    dx,al
  69.     jmp    short $+2
  70.     sti            ;re-enable interrupts
  71.     mov    ax,4        ;request dma transfer 
  72.     or    ax,[bp+6]    ;add in channel number
  73.     out    0d2h,al        ;request dma transfer
  74.     jmp    short $+2
  75.     pop    dx
  76.     pop    bx
  77.     pop    bp
  78.     ret    
  79. ;
  80. _word_dma endp
  81.  
  82. _text    ends
  83.  
  84.     end
  85.