National Instruments 320030-01 Printer Accessories User Manual


 
Appendix C Sample Programs
© National Instruments Corporation C-19 GPIB-1014 User Manual
|
| * * * * * * * * * * * * * * * * * * * * * *
| * COMMAND SEND - CSEND *
| * * * * * * * * * * * * * * * * * * * * * *
|
| Summary:
| - Called by CMD to send interface messages
|
| Assumptions on entry:
| - The GPIB-1014 is Active Controller
| - The d0 register contains the number of bytes to
| send
| - The a0 register contains the address oc cmdbuf
|
| Actions:
| - Initialize a count variable
| - Wait until the CDOR is empty
| - Write a byte and increment the counter
| - Check for a GPIB error
| - Loop until all bytes are transferred
| - On an error, set d0 to -1
|
| Status on return:
| - d0 register contains number of bytes sent or -1 if an
| error occurred
|
|
68000 Code | Comments
--------------------------------------------------------------------------------------------------------------------------------------------
|
CSEND: clrw count | Initialize count variable
|
CSEND1: btst #CO,ISR2 | Wait till CDOR is empty
beq CSEND1 |
|
cmpw #count,d0 | Have all commands been sent?
beq CSEND3 | Yes
|
addw #1,count | No--Increment counter and write
movb (a0)+,CDOR | the next command
|
btst #ERR,ISR1 | If there are no Listeners, return -1
bne CSEND2 | in d0 register
|
bra CSEND1 |
|
CSEND2: movw #-1,d0 |
|
CSEND3: rts |