【正文】
0H 。接收成功標志 RETI。*************************顯示程序************************;40H為最高位,43H為最低位,先掃描高位DISPLAY: MOV R1, 40H MOV R5, 0F7HPLAY: MOV A, R5 MOV P0, 0FFH MOV P2, A MOV A, @R1 MOV DPTR, TAB MOVC A, @A+DPTR MOV P0, A LCALL DL1MS INC R1 MOV A, R5 JNB , ENDOUT RR A MOV R5, A AJMP PLAYENDOUT: MOV P2, 0FFH MOV P0, 0FFH RETTAB: DB 0C0H, 0F9H, 0A4H, 0B0H, 99H, 92H, 82H, 0F8H, 80H, 90H, 0FFH, 88H。共陽段碼表“0”,“1”,“2”,“3”,“4”,“5”,“6”,“7”,“8”,“9”,“不亮”,“A”;****************************延時程序*****************************DLIMS: MOV R6, 14HDL1: MOV R7, 19HDL2: DJNZ R7, DL2 DJNZ R6, DL1 RET。 ***************距離計算程序(距離=計數(shù)值17/1000m)************work: PUSH ACC PUSH PSW PUSH B MOV PSW, 18H MOV R3, 45H MOV R2, 44H MOV R1, 00D MOV R0, 17D LCALL MUL2BY2 MOV R3, 03H MOV R2, 0E8H LCALL DIV4BY2 LCALL DIV4BY2 MOV 40H, R4 MOV A, 40H JNZ JJ0 MOV 40H, 0AH JJ0: MOV A, R0 MOV R4, A MOV A, R1 MOV R5, A MOV R3, 00D MOV R2, 100D LCALL DIV4BY2 MOV 41H, R4 MOV A, 41H JNZ JJ1 MOV A, 40H 。次高位為0,先看最高位是否為不亮 SUBB A, 0AH JNZ JJ1 MOV 41H, 0AH 。最高位不亮,次高位也不亮 JJ1: MOV A, R0 MOV R4, A MOV A, R1 MOV R5, A MOV R3, 00D MOV R2, 10D LCALL DIV4BY2 MOV 42H, R4 MOV A, 42H JNZ JJ2 MOV A, 41H 。次次高位為0,先看次高位是否為不亮 SUBB A, 0AH JNZ JJ2 MOV 42H, 0AH 。次高位不亮,次次高位也不亮 JJ2: MOV 43H, R0 POP B POP PSW POP ACC RET。*************************2字節(jié)無符號數(shù)乘法程序**************************;R7R6R5R4≤R3R2R1R0MUL2BY2: CLR A MOV R7, A MOV R6, A MOV R5, A MOV R4, A MOV 46H, 10HMULLOOP1: CLR C MOV A, R4 RLC A MOV R4, A MOV A, R5 RLC A MOV R5, A MOV A, R6 RLC A MOV R6, A MOV A, R7 RLC A MOV R7, A MOV A, R0 RLC A MOV R0, A MOV A, R1 RLC A MOV R1, A JNC MULLOOP2 MOV A, R4 MOV A, R2 MOV R4, A MOV A, R5 MOV A, R3 MOV R5, A MOV A, R6 ADDC A, 00H MOV R6, A MOV A, R7 ADDC A, 00H MOV R7, AMULLOOP2: DJNZ 46H, MULLOOP1 RET。********************4字節(jié)/2字節(jié)無符號數(shù)除法程序*********************;R7R6R5R4/R3R2=R7R6R5R4(商)…………R1R0(余數(shù))DIV4BY2: MOV 46H, 20H MOV R0, 00H MOV R1, 00HDIVLOOP1: MOV A, R4 RLC A MOV R4, A MOV A, R5 RLC A MOV R5, A MOV A, R6 RLC A MOV R6, A MOV A, R7 RLC A MOV R7, A MOV A, R0 RLC A MOV R0, A MOV A, R1 RLC A MOV R1, A CLR C MOV A, R0 SUBB A, R2 MOV B, A MOV A, R1 SUBB A, R3 JC DIVLOOP2 MOV R0, B MOV R1, ADIVLOOP2: CPL C DJNZ 46H, DIVLOOP1 MOV A, R4 RLC A MOV R4, A MOV A, R5 RLC A MOV R5, A MOV A, R6 RLC A MOV R6, A MOV A, R7 RLC A MOV R7, A RET END 袁節(jié)膅薂羄肅蒃薁蚃芀荿薀螆肅芅蕿袈羋膁蚈羀肁蒀蚇蝕襖莆蚇螂肀莂蚆羅袂羋蚅蚄膈膄蚄螇羈蒂蚃衿膆莈螞羈罿芄螁蟻膄膀螁螃羇葿螀裊膃蒅蝿肈羆莁螈螇芁芇莄袀肄膃莄羂艿蒂莃螞肂莈蒂螄羋芄蒁袆肀膀蒀罿袃薈葿螈聿蒄葿袁羈莀蒈羃膇芆蕆蚃羀膂蒆螅膅蒁薅袇羈莇薄罿膄芃薃蠆羆艿薃袁節(jié)膅薂羄肅蒃薁蚃芀荿薀螆肅芅蕿袈羋膁蚈羀肁蒀蚇蝕襖莆蚇螂肀莂蚆羅袂羋蚅蚄膈膄蚄螇羈蒂蚃衿膆莈螞羈罿芄螁蟻膄膀螁螃羇葿螀裊膃蒅蝿肈羆莁螈螇芁芇莄袀肄膃莄羂艿蒂莃螞肂莈蒂螄