
SPIIo:
 MOV SPSTAT,#80h ;Clear SPIF flag by setting it
 MOV SPDAT,A ;Write out to SPI port
SPIIo_Wait:
 MOV A,SPSTAT ;Get the SPI status register
 JNB ACC.7,SPIIo_Wait ;Wait for completed IO
 MOV SPSTAT,#80h ;Clear the SPIF flag
 MOV A,SPDAT ;Get the read value
RET
