12.07.2015 Views

HOWTO program the Z80 SIO

HOWTO program the Z80 SIO

HOWTO program the Z80 SIO

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

REC_BLOCK:;set block transfer modeld a,21h ;write into WR0 cmd4 and select WR1out (<strong>SIO</strong>_A_C),Ald a,10101000b ;wait active, interrupt on first RX characterout (<strong>SIO</strong>_A_C),A ;buffer overrun is a spec RX conditioneicallhaltcallA_RTS_ONA_RTS_OFF;await first rx charld a,01h ;write into WR0: select WR1out (<strong>SIO</strong>_A_C),Ald a,00101000b ;wait function inactiveout (<strong>SIO</strong>_A_C),A;check return code of block reception (e holds return code)ld a,ecp 0 ;block finished, no errorjp z,l_210cp 2 ;eot foundjp z,l_211cp 3 ;chk sum errorjp z,l_613ld a,10hjp l_612l_210: call TX_ACK ;when no errorinc c ;prepare next block to receivesub Ald (temp0),A ;clear bad block counterjp REC_BLOCKl_211: call TX_ACK ;on eotld A,01hjp l_612l_613: call TX_NAK ;on chk sum errorscfccf;clear carry flagld DE,0080h ;subtract 80hsbc HL,DE ;from HL, so HL is reset to block start addressl_612:DLD_END:ld A,(temp0) ;count bad blocks in temp0inc Ald (temp0),Acp 09hjp z,l_612 ;abort download after 9 attempts to transfer a blockjp REC_BLOCK ;repeat block receptionretText 14: Receive Data Block15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!