80x86 assembly language drivers – Sensoray 417 User Manual
Page 13

Instruction Manual
12
80x86 Assembly Language Drivers
;***********************************************************
; Handshake a command byte into the 417 command register.
; Entry:DX points to 417 base port address.
;
AL contains command byte to send to 417.
;***********************************************************
;INITIALIZE DRIVER
XMIT:
PUSH AX
;
Save command byte to be sent to 417
INC DX
;
Set address pointer to status port
;WAIT FOR “COMMAND REGISTER EMPTY”
XLOOP: IN AL,DX
;
Read status port
TEST AL,80H
;
and test CRMT status flag
JE XLOOP
;
Loop until command register is empty
;SEND COMMAND BYTE TO 417 BOARD
DEC DX
;
Set address pointer to command register
POP AX
;
Restore command byte
OUT DX,AL
;
and write it into command register
RET
;EXIT DRIVER
;***********************************************************
; Handshake a byte from the 417 data register.
; Entry:DX points to 417 base port address.
; Exit:AL contains data byte read from 417.
;***********************************************************
;INITIALIZE DRIVER
RCV:
INC DX
;
Set address pointer to status port
;WAIT FOR “DATA AVAILABLE”
RLOOP: IN AL,DX
;
Read 417 status port
TEST AL,40H
;
and test DAV status flag
JE RLOOP
;
Loop until data register is full
;READ DATA BYTE FROM 417 BOARD
DEC DX
;
Set address pointer to 417 data register
IN AL,DX
;
Read byte from data register
RET
;EXIT DRIVER