$NOMOD51 $INCLUDE(MOD8751) LCALL 00C1H ;8583 initilize MOV 21H,#00H ;clear 21H MOV 22H,#00H ;clear 22H MOV 23H,#00H ;clear 23H MOV 24H,#00H ;clear 24H LCALL 0017H ;execute sub-function from 0017 to 0041 LCALL 0042H ;execute sub-function from 0042 to 00AD SJMP 000FH ;jump to 000F LCALL 00AEH ;execute sub-function from 00AE to 00C0 MOV A,29H ;write data of Address 29H into Accumulator PUSH ACC ;save data of Accumulator into Address (SP+1)H of RAM ANL A,#0FH ;compare data=0FH with data of Accumulator then save the same data number of both into Accumulator MOV 24H,A ;write data of Accumulator to Address=24H POP ACC ;load data of Address (SP)H into Accumulator SWAP A ;exchange data of High-nibble and Low-nibble in Accumulator ANL A,#0FH ;compare data=0FH with data of Accumulator then save the same data number of both into Accumulator MOV 23H,A ;write data of Accumulator into Address=23H MOV A,2AH ;write data of Address=2AH into Accumulator PUSH ACC ;save data of Accumulator into Address (SP+1) of RAM ANL A,#0FH ;compare data=0FH with data of Accumulator then save the same data number of both into Accumulator MOV 22H,A ;write data of Accumulator into Address=22H POP ACC ;load data of Address (SP) into Accumulator SWAP A ;exchange data of High-nibble and Low-nibble in Accumulator ANL A,#03H ;compare data=03H with data of Accumulator then save the same data number of both into Accumulator MOV 21H,A ;write data of Accumulator into Address=21H LCALL 00F0H ;execute sub-function from 00F0 to 0123 LCALL 00F0H ;execute sub-function from 00F0 to 0123 LCALL 00F0H ;execute sub-function from 00F0 to 0123 RET ;back to main function MOV P1,#0FFH ;write data=0FFH into P1(Address of outside data memory) CLR P3.2 ;clear data number of the third bit of P3 into 0 SETB P3.5 ;set data number of the 6th bit of P3 into 1 JB P3.7,0079H ;if the data number of the 8th bit of P3 equal to 1 then execute 0079 MOV A,29H ;write data of Address 29H into Accumulator ADD A,#01H ;add data=01H with data of Accumulator then save the result in Accumulator DA A ;after ADD adjust the data of Accumulator to Hex. CJNE A,#60H,0056H ;compare data=60H with data of Accumulator if not equal then execute 0056 MOV A,#00H ;write data=00H into Accumulator MOV 2AH,#03H ;write data=03H into Address=2AH MOV 2BH,A ;write data of Accumulator into Address=2BH MOV R0,#2AH ;write data=2AH into Register R0 MOV R1,#02H ;write data=02H into Register R1 ACALL 0150H ;execute sub-function from 0150 to 0162 MOV 2AH,#01H ;write data=01H into Address 2AH MOV 2BH,#00H ;write data=00H into Address 2BH MOV R0,#2AH ;write data=2AH into Registor R0 MOV R1,#02H ;write data=02H into Registor R1 ACALL 0150H ;execute sub-function from 0150 to 0162 ACALL 0017H ;execute sub-function from 0017 to 0041 MOV P1,#0FFH ;write data=0FFH into P1 CLR P3.2 ;clear data number of the third bit of P3 into 0 SETB P3.5 ;set data number of the 6th bit of P3 into 1 JNB P3.7,006DH ;if data number of the 8th bit of P3 equal to 0 then execute 006D SETB P3.2 ;set data number of the third bit of P3 into 1 CLR P3.5 ;clear data number of the 6th bit of P3 into 0 JB P3.7,00ADH ;if data number of the 8th bit of P3 equal to 1 then execute 00AD MOV A,2AH ;write data of Address 2AH into Accumulator ADD A,#01H ;add data=01H with data of Accumulator then save the result into Accumulator DA A ;After ADD adjust the data of Accumulator to Hex. CJNE A,#24H,008AH ;compare data=24H with the Data of Accumulator if not equal then execute 008A MOV A,#00H ;write data=00H into Accumulator MOV 2AH,#04H ;write data=04H into Address 2AH MOV 2BH,A ;write data of Accumulator into Address 2BH MOV R0,#2AH ;write data=2AH into Registor R0 MOV R1,#02H ;write data=02H into Registor R1 ACALL 0150H ;execute sub-function from 0150 to 0162 MOV 2AH,#01H ;write data=01H into Address 2AH MOV 2BH,#00H ;write data=00H into Address 2BH MOV R0,#2AH ;write data=2AH into Registor R0 MOV R1,#02H ;write data=02H into Registor R1 ACALL 0150H ;execute sub-function from 0150 to 0162 ACALL 0017H ;execute sub-function from 0017 to 0041 MOV P1,#0FFH ;write data=0FFH into P1 SETB P3.2 ;set data number of the third bit of P3 into 1 CLR P3.5 ;clear data number of 6th bit of P3 into 0 JNB P3.7,00A1H ;if data number of 8th bit of P3 equal to 0 then execute 00A1 RET ;back to main function MOV 2AH,#00H ;write data=00H into Address 2AH MOV 2BH,#00H ;write data=00H into Address 2BH MOV R0,#2AH ;write data=2AH into Registor R0 MOV R1,#01H ;write data=01H into Registor R1 ACALL 0150H ;execute sub-function from 0150 to 0162 MOV R0,#26H ;write data=26H into Registor R0 MOV R1,#08H ;write data=08H into Registor R1 ACALL 0163H ;execute sub-function from 0163 to 172 RET ;back to main function MOV 2AH,#00H ;clear 2a MOV R0,#2AH ;R0 point to 2A MOV R1,#01H ;write data=01H into Registor R1 ACALL 0150H ;execute sub-function from 0150 to 0162 RET ;back to main function MOV 2AH,#03H ;write data=03H into Address 2AH MOV 2BH,#54H ;write data=54H into Address 2BH MOV R0,#2AH ;write data=2AH into Registor R0 MOV R1,#02H ;write data=02H into Registor R1 ACALL 0150H ;execute sub-function from 0150 to 0162 MOV 2AH,#00H ;write data=00H into Address 2AH MOV 2BH,#00H ;write data=00H into Address 2BH MOV R0,#2AH ;write data=2AH into Registor R0 MOV R1,#02H ;write data=02H into Registor R1 ACALL 0150H ;execute sub-function from 0150 to 0162 MOV 2AH,#04H ;write data=04H into Address 2AH MOV 2BH,#07H ;write data=07H into Address 2BH MOV R0,#2AH ;write data=2AH into Registor R0 MOV R1,#02H ;write data=02H into Registor R1 ACALL 0150H ;execute sub-function from 0150 to 0162 RET ;back to main function MOV R1,#04H ;write data=04H into Registor R1 MOV B,#0BFH ;write data=0BFH into Registor B MOV R0,#21H ;write data=21H into Registor R0 ORL P3,#3CH ;write data=3CH into P3 MOV A,@R0 ;write the data of Address (data number of R0) into Accumulator INC R0 ;add 1 into data number of Registor R0 MOV DPTR,#0130H ;write data=0130H into DPTR MOVC A,@A+DPTR ;write the data of function memory Address into Accumulator CPL A ;1's complement MOV P1,A ;write the data of Accumulator into P1 JB B.5,010BH ;if data number of the 6th bit of Registor B equal to 1 then execute 010B JB 26H.0,010BH ;if data number of the first bit of Address 26H equal to 1 then execute 010B CLR P1.7 ;clear the data number of 8th bit of P1 equal to 0 MOV A,B ;write data of Registor B into Accumulator RR A ;rotate Accumulator Right 1 bit MOV B,A ;write data of Accumulator into Registor B ANL P3,A ;compare the data of Accumulator with P3 then save the same data number of both into P3 LCALL 012BH ;execute sub-function from 012B to 012F ORL P3,#3CH ;use Logic OR to compare P3 and data=3CH then save the result at P3 DJNZ R1,00FAH ;decrease 1 from the data number of Registor R1 if not equal to 00H then execute 00FA LCALL 0124H ;execute sub-function from 0124 to 012A LCALL 0124H ;execute sub-function from 0124 to 012A LCALL 0124H ;execute sub-function from 0124 to 012A RET ;back to main function MOV R7,#0E6H ;write data=0E6H into Registor R7 NOP ;No action NOP ;No action DJNZ R7,0126H ;decrease 1 from the data number of Registor R7 if not equal 00H then execute 0126 RET ;back to main function MOV R7,#0C8H ;write data=0C8H into Registor R7 DJNZ R7,012DH ;decrease 1 from the data number of Registor R7 if not equal 00H then execute 012D RET ;back to main function ADDC A,R7 ;add the data number of Registor R7, Accumulator and C then save the result to Accumulator INC @R0 ;add 1 into the data number of Address(data of Registor R0) ANL A,R3 ;compare the data of Registor R3 with Accumulator then save the same data number of both into Accumulator ORL A,R7 ;use Logic OR to compare R7 and Accumulator then save the result into Accumulator XRL A,@R0 ;use Logic Exclusive OR to compare the data of Address(data of Registor R0) with Accumulator then save the result into Accumulator XRL A,R5 ;use Logic Exclusive OR to compare the data of Registor R5 with Accumulator then save the result into Accumulator MOV R5,#07H ;write data=07H into Registor R5 MOV R7,#6FH ;write data=6FH into Registor R7 MOV @R1,#7CH ;write data=7CH into Address(data number of Registor R1) ADDC A,R1 ;add the data number of Registor R1, Accumulator and C then save the result to Accumulator ANL A,R6 ;compare the data of Registor R6 with Accumulator then save the same data number of both into Accumulator MOV R1,#71H ;write data=71H into Registor R1 NOP ;No action JMP @A+DPTR ;jump to @A+DPTR ANL A,R0 ;use Logic AND to compare the data of Registor R0with Accumulator then save the result into Accumulator ORL A,R4 ;use Logic OR to compare R4 and Accumulator then save the result into Accumulator MOV @R0,#5EH ;write data=5EH into @R0 MOV R1,#50H ;write data=50H into Registor R1 JC 018AH ;if C=1 then jump to 018A NOP ;No action NOP ;No action NOP ;No action NOP ;No action NOP ;No action NOP ;No action MOV A,#0A0H ;write data=0A0H into Accumulator ACALL 0173H ;execute sub-function from 0173 to 0189 JB 20H.0,0160H ;if data number of the first bit of Address 20H equal to 1 then execute 0160 MOV A,@R0 ;write data of @R0 into Accumulator ACALL 018DH ;execute sub-function from 018D to 01AB INC R0 ;Add 1 to data of R0 JB 20H.0,0160H ;if data number of the first bit of Address 20H equal to 1 then execute 0160 DJNZ R1,0157H ;decrease 1 from the data of R1 if not equal to 00H then execute 0157 ACALL 01D4H ;execute sub-function from 01D4 to 01DE RET ;No action MOV A,#0A1H ;write data=0A1H into Accumulator ACALL 0173H ;execute sub-function from 0173 to 0189 JB 20H.0,0170H ;if data number of the first bit of Address 20H equal to 1 then execute 0170 ACALL 01ACH ;execute sub-function from 01AC to 01D3 MOV @R0,A ;write the data of Accumulator into @R0 INC R0 ;add 1 to data of R0 DJNZ R1,016AH ;decrease 1 from the data fo R1 if not equal to 00H then execute 016A ACALL 01D4H ;execute sub-function from 01D4 to 01DE RET ;back to main function SETB 20H.2 ;set 20H.2=1 CLR 20H.0 ;clear CLR 20H.1 ;clear JNB P3.0,018AH ;check pin 2=0 JNB P3.1,018AH ;check pin 3=0 CLR P3.1 ;clear pin 3=0 ACALL 01E0H ;delay CLR P3.0 ;clear the data number of the first bit of P3 equal to 0 ACALL 01E0H ;delay ACALL 018DH ;execute sub-function from 018D to 01AB RET ;back to main function SETB 20H.1 ;set the data number of the second bit of Address 20H equal to 1 RET ;back to main function MOV R2,#08H ;write data=08H into Registor R2 RLC A ;rotate Accumulator Left 1 bit through Carry MOV P3.1,C ;move carry to sda ACALL 01E2H ;8583 ready to rcv? ACALL 01E0H ;delay CLR P3.0 ;set scl=0 ACALL 01E0H ;delay DJNZ R2,018FH ;R2=0? if no go to 018F SETB P3.1 ;set the data number of the second bit of P3 equal to 1 ACALL 01E2H ;execute sub-function from 01E2 to 01E7 ACALL 01DFH ;execute sub-function from 01DF to 01E1 JNB P3.1,01A7H ;if the data number of the second bit of P3 equal to 0 then execute 01A7 SETB 20H.0 ;set the data number of the first bit of Address 20H equal to 1 CLR P3.0 ;clear the data number of the first bit of P3 equal to 0 ACALL 01E0H ;execute sub-function from 01E0 to 01E1 RET ;back to main function MOV R2,#08H ;write data=08H into R2 ACALL 01E2H ;execute sub-function from 01E2 to 01E7 ACALL 01E0H ;execute sub-function from 01E0 to 01E1 MOV C,P3.1 ;write the data number of the second bit of P3 into C RLC A ;rotate Accumulator Left 1 bit through Carry CLR P3.0 ;clear the data number of the first bit of P3 equal to 0 ACALL 01E0H ;execute sub-function from 01E0 to 01E1 DJNZ R2,01AEH ;decrease 1 from the data of R2 if not equal to 00H then execute 01AE PUSH ACC ;save the data of Accumulator into Address (SP+1)H of RAM MOV A,R1 ;write the data of R1 into Accumulator CJNE A,#01H,01C5H ;compare data=01H with the data of Accumulator if not equal then execute 01C5 SETB P3.1 ;set the data number of the second bit of P3 equal to 1 SJMP 01C7H ;jump to 01C7 CLR P3.1 ;clear the data number of the second bit of P3 equal to 0 ACALL 01E2H ;execute sub-function from 01E2 to 01E7 POP ACC ;load the data of Address (SP)H into Accumulator ACALL 01E0H ;execute sub-function from 01E0 to 01E1 CLR P3.0 ;clear the data number of the first bit of P3 equal to 0 SETB P3.1 ;set the data number of the second bit of P3 equal to 1 ACALL 01DFH ;execute sub-function from 01DF to 01E1 RET ;back to main function CLR P3.1 ;clear sda ACALL 01E2H ;execute sub-function from 01E2 to 01E7 ACALL 01E0H ;delay SETB P3.1 ;set sda high CLR 20H.2 ;clear the data number of the third bit of Address 20H equal to 0 RET ;back to main function NOP ;No action NOP ;No action RET ;back to main function SETB P3.0 ;set scl=1 JNB P3.0,01E4H ;if the data number of the first bit of P3 equal to 0 then execute 01E4 RET ;back to main function END