	  MNAME PLLEL_ASM
	  SRC MODULE PLLEL_ASM;
	  SRC IMPORT IODECLARATIONS;
	  SRC EXPORT
	  SRC   TYPE
	  SRC     TIMER_REC = RECORD
	  SRC                   TIME : INTEGER;
	  SRC                   FLAG : IO_WORD;
	  SRC                 END;
	  SRC
	  SRC     PROCEDURE START_TIMER(VAR TIME : TIMER_REC);
	  SRC     FUNCTION  TIME_EXPIRED(VAR TIME : TIMER_REC):BOOLEAN;
	  SRC     PROCEDURE ABORT_IO;
	  SRC     PROCEDURE STBSY;
	  SRC     PROCEDURE STCLR;
	  SRC     FUNCTION GETDMA:INTEGER;  {returns dma channel (0,1) being used}
	  SRC     FUNCTION DROPDMA:INTEGER; {returns dma final count+1; 0, not -1, means normal completion}
	  SRC
	  SRC END; { PLLEL_ASM }

	  DEF PLLEL_ASM_PLLEL_ASM
	  DEF PLLEL_ASM_START_TIMER
	  DEF PLLEL_ASM_TIME_EXPIRED
	  DEF PLLEL_ASM_ABORT_IO
	  DEF PLLEL_ASM_STBSY
	  DEF PLLEL_ASM_STCLR
	  DEF PLLEL_ASM_GETDMA
	  DEF PLLEL_ASM_DROPDMA

*         include IOLIB:COMDCL
	  include COMDCL

*************************************************************************
* START_TIMER                           timing setup
*
*   ASSUMES:
*       - sp+4 points to location of a timer record
*              the TIME field is a delay in milliseconds
*   RETURNS:
*       - The TIME field contains a value to match against the timer
*         (no timer present then this field is a scaled count)
*************************************************************************

	REFA    CHECK_TIMER   in system POWERUP code
	LMODE   CHECK_TIMER

PLLEL_ASM_START_TIMER equ *
	movea.l 4(sp),a0        get addr of timer rec
	btst    #timer_present,sysflag2
	bne.s   soft_start
	st      4(a0)   set the first time flag
	jmp     CHECK_TIMER

soft_start equ  *
*       scale the time out value for use as a counter
	move.l  (a0),d0
	lsl.l   #4,d0           x 16
	move.l  d0,(a0)
	move.l  (sp)+,(sp)      move the return address
	rts
*************************************************************************
* FUNCTION TIME_EXPIRED(VAR TIME: INTEGER):BOOLEAN;
*   ASSUMES:
*       - sp+4 points to a timer record (set up by start_timer)
*************************************************************************

PLLEL_ASM_TIME_EXPIRED  EQU *
	clr.b   8(sp)           clear the function value
	btst    #timer_present,sysflag2
	bne.s   soft_check
	move.l  4(sp),-(sp)     copy the timer rec address
	jsr     CHECK_TIMER
	bpl.s   timex1
timex0  move.b  #1,8(sp)
timex1  move.l  (sp)+,(sp)      move the return address
	rts
soft_check equ  *
	movea.l 4(sp),a0
	subq.l  #1,(a0)
	bpl     timex1
	bra     timex0
*************************************************************************
* pascal wrapper routines for the iocomasm driver routines that have
* assembly only interfaces.
*************************************************************************
	  refa  pllel_util
	  refa  abort_io
	  refa  stbsy
	  refa  stclr
	  refa  itxfr
	  refa  getdma
	  refa  dma_stbsy
	  refa  dropdma
	  lmode pllel_util
	  lmode abort_io
	  lmode stbsy
	  lmode stclr
	  lmode itxfr
	  lmode getdma
	  lmode dma_stbsy
	  lmode dropdma

gettmp  equ *
	movea.l pllel_util-4(a5),a2
	rts

*************************************************************************
* PROCEDURE ABORT_IO
*************************************************************************
PLLEL_ASM_ABORT_IO equ *
	bsr     gettmp
	jsr     abort_io
	rts

*************************************************************************
* PROCEDURE STBSY
*************************************************************************
PLLEL_ASM_STBSY equ *
	bsr     gettmp
	jsr     itxfr
	move.l  d3,d0
	jsr     stbsy
	rts

*************************************************************************
* PROCEDURE STCLR
*************************************************************************
PLLEL_ASM_STCLR equ *
	bsr     gettmp
	jsr     stclr
	rts

*************************************************************************
* FUNCTION GETDMA:INTEGER
*    o acquires DMA channel
*    o set up DMA address
*    o set up DMA count
*    o set up DMA arm word for priority and ARMS!
*    o returns the channel, either 0 or 1.
*************************************************************************
PLLEL_ASM_GETDMA equ *
	bsr     gettmp
	jsr     itxfr
	move.l  d3,d0
	movea.l c_adr(a2),a1
	jsr     getdma
	addq.w  #8,d2           ;dma priority
	move.w  d2,(a4)         ;arm DMA channel
	sub     #$81,d3
	moveq   #0,d0
	move.b  d3,d0
	move.l  d0,4(sp)        ;return channel #
	rts

*************************************************************************
* PROCEDURE DROPDMA
*************************************************************************
PLLEL_ASM_DROPDMA equ *
	bsr     gettmp
	jsr     DROPDMA
	move.l  d4,4(sp)
	rts
*
*       module initialization
*
PLLEL_ASM_PLLEL_ASM EQU *
	  RTS

	end
