CS EQU P1.7 SK EQU PI.6 DI EQU P15 DO EQU P1.4 ADRCODE BYTE 7FH DATAH BYTE 7EH DATAL BYTE 7DH OUTBYTE BYTE 7CH OUTLEN BYTE 7BH INBYTE BYTE 7AH INLEN BYTE 79H FLAG BYTE 20H B5BITADR BIT 01H DATOUT: CLR SK MOV R2,OUTLEN MOV A,OUTBYTE DOUT1: CLR SK NOP RLC A MOV DI,C NOP SETB SK NQP DJNZ R2,DOUT1 RET DATIN': CLR SK MOV R2,INLEN DATINI: CLR SK NOP MOV C,DO RLC A NOP SETB SK NOP DJNZ R2,DATINI MOV INBYTE,A RET READ: SETB CS MOV OUTBYTE,#11000000E MOV OUTI.EN,#03H LCALL DATAOUT JB BSBITADR,READ MOV OUTLEN,#08 MOV OUTBYTE,ADRCODE LCALL DATAOUT AJMP READ2 READ: MOV OUTLEN,#06H MOV OUTBYTE,ADRCODE LCALL DATAOUT READ2: MOV INLEN,#08H LCALL DATAIN MOV DATAH,INBYTE MOV INLEN,#08H LCALL DATAIN MOV DATAL,INBYTE CLR CS CLR SK RET WRITE: SETB CS MOV OUTBYTE,#10100000B MOV OUTLEN,#03H LCALL DATAOUT JB B5BITADR,WRITEI MOV OUTLEN,#OS MOV OUTBYTE,ADRCODE LCALL DATAOUT JMP WRITE2 WRITE1: MOV OUTLEN,#06H MOV OUTBYTE,ADRCODE LCALL DATAOUT WRITE2: MOV OUTLEN,#OSH MOV OUTBYTE,DATAH LCALL DATAOUT MOV OUTLEN.#08H MOV OUTB YTE,DATAL LCALL DATAOUT CLR CS NOP NOP SETB CS WRITE3: MOV C,DO JNC WRITE3 CLR CS RET WEN: SETB CS MOV OUTBYTE,#10000000B MOV OUTLEN,#03H LCALL DATAOUT JB B5BITADR,WEN MOV OUTLEN,#08H MOV OUTBYTE,ADRCODE LCALL DATAOUT CLR WEN2 WENT: MOV OUTLEN,#06H MOV OUTBYTE,ADRCODE LCALL DATAOUT WEN2: CLR CS RET