;       SCCSID = @(#)atespmac.inc	6.2 91/04/08
PWRITE  MACRO   reg,value
        LOCAL   Loop

IF (reg EQ ESP_R_CMD1)
   bit = ESP_RDY_CMD1
ENDIF

IF (reg EQ ESP_R_CMD2)
   bit = ESP_RDY_CMD2
ENDIF

        mov     dx,[di].pi_address
Loop:   in      al,dx
        test    al,bit
        jz      Loop

        add     dx,reg
        mov     al,value
        out     dx,al

ENDM

PREAD   MACRO   reg
        LOCAL   Loop

IF (reg EQ ESP_R_STATUS1)
   bit = ESP_RDY_STATUS1
ENDIF

IF (reg EQ ESP_R_STATUS2)
   bit = ESP_RDY_STATUS2
ENDIF

; no waiting for RR or SID
IFE (reg EQ ESP_R_RDY) OR (reg EQ ESP_R_SID)
        mov     dx,[di].pi_address
Loop:   in      al,dx
        test    al,bit
        jz      Loop
ENDIF
        add     dx,reg
        in      al,dx
ENDM

ISSUE   MACRO   cmd,cmd2,cmd3,cmd4,cmd5

        PWRITE  ESP_R_CMD1,cmd

IFNB    <cmd2>
        PWRITE  ESP_R_CMD2,cmd2
ENDIF

IFNB    <cmd3>
        PWRITE  ESP_R_CMD2,cmd3
ENDIF

IFNB    <cmd4>
        PWRITE  ESP_R_CMD2,cmd4
ENDIF

IFNB    <cmd5>
        PWRITE  ESP_R_CMD2,cmd5
ENDIF

ENDM


