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.

BYTE_AVAILABLE:EXP_SOH_EOT:in A,(<strong>SIO</strong>_A_D) ;read RX byte into Al_205: cp 01h ;check for SOHjp z,EXP_BLK_NRcp 04h ;check for EOTjp nz,l_2020ld e,2hreti;await block numberEXP_BLK_NR:in A,(<strong>SIO</strong>_A_D) ;read RX byte into Acp C ;check for match of block nrjp nz,l_2020;await complement of block numberld A,C ;copy block nr to expect into ACPL;and cpl Ald E,A ;E holds cpl of block nr to expectEXP_CPL_BLK_NR:in A,(<strong>SIO</strong>_A_D) ;read RX byte into Acp E ;check for cpl of block nrjp nz,l_2020;await data blockld D,0h ;start value of checksumld B,80h ;defines block size 128byteEXP_DATA:in A,(<strong>SIO</strong>_A_D) ;read RX byte into Ald (HL),Aadd A,D ;updateld D,A ;checksum in Dinc HL ;dest address +1djnz EXP_DATA ;loop until block finishedEXP_CHK_SUM:in A,(<strong>SIO</strong>_A_D) ;read RX byte into A; ld a,045h ;for debug onlycp D ;check for checksum matchjp z,l_2021ld e,3hretil_2020: ldRETIl_2021: ldRETIE,1hE,0h;return when block received completely;­­­­­­­Int routine on RX overflow­­­­­­­­­­­­­­­­­­­­­SPEC_BYTE_COND:ld HL,DLD_ENDpush HLreti;in case of RX overflow prepare abort of transferText 15: Interrupt Service Routine16

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

Saved successfully!

Ooh no, something went wrong!