在KEIL中编译通过后,点击“Debug”菜单“Start”命令,然后,点击“View”菜单“Disassembly Windows”命令,就可以看到汇编代码了。
C:0x0000 020014 LJMP C:0014
4: void main()
5: {
6: IN=1;OUT=0;
C:0x0003 D295 SETB IN(0x90.5)
C:0x0005 C2B5 CLR OUT(0xB0.5)
7: while(1)
8: {
9: if(!IN)
C:0x0007 209506 JB IN(0x90.5),C:0010
10: {
11: OUT=1;IN=1;
C:0x000A D2B5 SETB OUT(0xB0.5)
C:0x000C D295 SETB IN(0x90.5)
12: }
13: else
C:0x000E 80F7 SJMP C:0007
14: {
15: OUT=0;
C:0x0010 C2B5 CLR OUT(0xB0.5)
16: }
C:0x0012 80F3 SJMP C:0007
C:0x0014 787F MOV R0,#0x7F
C:0x0016 E4 CLR A
C:0x0017 F6 MOV @R0,A
C:0x0018 D8FD DJNZ R0,C:0017
C:0x001A 758107 MOV SP(0x81),#0x07
C:0x001D 020003 LJMP main(C:0003)
手工编写的汇编程序如下:
ORG 0
LJMP START
ORG 30H
START: SETB P1.5
CLR P3.5
L1: JB P1.5,L2
SETB P3.5
SETB P1.5
SJMP L1
L2: CLR P3.5
SJMP L1
END
BIT IN P1.5
BIT OUT P3.5
ORG 0
JMP MAIN
ORG 30H
MAIN:
SETB IN
CLR OUT
LOOP:
JB IN,GO
SETB OUT
SETB IN
AJMP AGA
GO:CLR OUT
AGA:AJMP LOOP
END