ORG 0000H AJMP MAIN ORG 000BH LJMP INT_T0 ORG 0030H MAIN: MOV SP,#53H START: LCALL INIT LJMP $ INIT: MOV R0,#20 MOV TMOD,#01H MOV TL0,#0FFH SETB EA SETB ET0 SETB TR0 RET INT_T0: MOV TH0,#4BH MOV TL0,#0FFH DJNZ R0,GO_OUT MOV R0,#20 CPL P0.0 GO_OUT: RETI END
时间: 2023-06-05 09:07:23 浏览: 905
0000H
ORG 0000H:设定程序的起始地址为0000H
AJMP MAIN:跳转到主程序入口MAIN
ORG 000BH:设定中断T0的入口地址为000BH
LJMP INT_T0:长跳转到中断T0的入口地址
ORG 0030H:设定主程序的入口地址为0030H
MAIN: MOV SP,0000H:将堆栈指针寄存器SP的值设置为0000H
相关问题
DUAN BIT P2.6 WEI BIT P2.7 ORG 0000H AJMP START ORG 001BH LJMP ZHONG ORG 0030H ZHONG: MOV TL1,#0F0H MOV TH1,#0D8H DJNZ R7,PEND MOV R7,#100 DEC R1 //数据处理(减一,拆开) DEC R2 MOV B,#10 MOV A,R1 DIV AB MOV 21H,A//将十位移到21H中 MOV 20H,B//将个位移到20H中 MOV B,#10 MOV A,R2 DIV AB MOV 25H,A//将十位移到25H中 MOV 24H,B//将个位移到24H中 PEND: RETI START: MOV R7,#100 //设置 MOV TMOD,#10H MOV TL1,#0F0H MOV TH1,#0D8H SETB EA SETB ET1 SETB TR1 //开始计时 MOSHI: MOV P1,#0F9H MOV R1,#13 MOV R2,#16 MOV 30H,#0 LCALL SHU MOV P1,#0EEH MOV R1,#4 MOV R2,#4 MOV 30H,#0 LCALL SHU MOV P1,#0FAH MOV R1,#16 MOV R2,#13 MOV 30H,#3 LCALL SHU MOV P1,#0DEH MOV R1,#4 MOV R2,#4 MOV 30H,#0 LCALL SHU LJMP MOSHI SHU: MOV A,20H MOV B,#0DFH LCALL XIANSHI MOV A,21H MOV B,#0EFH LCALL XIANSHI MOV A,24H MOV B,#0FDH LCALL XIANSHI MOV A,25H MOV B,#0FEH LCALL XIANSHI MOV A,R1 CJNE A,30H,SHU RET XIANSHI:CLR DUAN CLR WEI DIS: ACALL STAB //段码 MOV P0,A SETB DUAN CLR DUAN MOV A,B //位码 MOV P0,A SETB WEI CLR WEI ACALL DELAY RET STAB: MOV DPTR,#TAB MOVC A,@A+DPTR RET DELAY: MOV R7,#20 DL1: MOV R6,#125 DL2: DJNZ R6,DL2 DJNZ R7,DL1 RET TAB: DB 3FH, 06H, 5BH, 4FH, 66H, 6DH, 7DH, 07H, 7FH, 6FH END
这段代码中的 MOSHI 是一个循环,用于控制数码管循环显示数字。通过调用 SHU 子程序来设置数码管的显示内容。其中,XIANSHI 子程序用于控制数码管的段码和位码,从而实现数字的显示。DELAY 子程序是一个简单的延时函数,用于控制数字的显示频率。最后,TAB 是一个数据表,用于存储数码管的段码。
以下是汇编语言,请将它改成C51单片机语言,令他符合逻辑。 ORG 0000H LJMP MAIN ORG 0003H LJMP PINT0 ORG 0200H MAIN: MOV IE,#81H; SETB IT0; MOV SP,#30H SETB P3.0 CLR P3.1 MOV P1,#0FFH; MOV P2,#00H; CLR P1.2 LP: JNB P1.0,LA; LA: ACALL DELAY; JNB P1.0,ALARM AJMP LP DELAY: MOV R1,0AAH LD2: MOV R2,0BBH LD1: NOP DJNZ R2,LD1 DJNZ R1,LD2 RET ALARM: SETB P1.2 CPL P3.0 CPL P3.1 ;10S time MOV 51H,#14H MOV TMOD,#01H; MOV TL0,#0B0H; MOV TH0,#3CH SETB TR0; L2: JBC TF0,L1; SJMP L2 L1: MOV TL0,#0B0H; MOV TH0,#3CH DJNZ 51H,L2; SETB P3.0; CLR P3.1 CLR P1.2; LJMP LP; ;interrupt INT0 PINT0: CLR EX0; PUSH PSW PUSH ACC JNB P3.2,LN; LN: LCALL DELAY; JNB P3.2,LN1 AJMP LN2; LN1: SETB P3.0 CLR P3.1 CLR P1.2; POP ACC POP PSW SETB EX0; LCALL LP; LN2: RETI END
以下是将汇编语言改成C51单片机语言后的代码:
```c
#include <reg51.h>
void DELAY() {
unsigned char R1, R2;
for (R1 = 0xAA; R1 > 0; R1--) {
for (R2 = 0xBB; R2 > 0; R2--) {
// do nothing
}
}
}
void main() {
TMOD = 0x01;
TH0 = 0x3C;
TL0 = 0xB0;
IE = 0x81;
P3_0 = 1;
P3_1 = 0;
P1 = 0xFF;
P2 = 0x00;
P1_2 = 0;
IT0 = 1;
SP = 0x30;
TR0 = 1;
while (1) {
while (P1_0 == 1) {
// do nothing
}
DELAY();
if (P1_0 == 1) {
P1_2 = 1;
P3_0 = !P3_0;
P3_1 = !P3_1;
TH0 = 0x3C;
TL0 = 0xB0;
for (unsigned char i = 0x14; i > 0; i--) {
while (!TF0);
TF0 = 0;
TH0 = 0x3C;
TL0 = 0xB0;
}
P3_0 = 1;
P3_1 = 0;
P1_2 = 0;
}
}
}
void PINT0() interrupt 0 {
EX0 = 0;
PSW = PSW & 0x7F;
ACC = ACC & 0x7F;
while (P3_2 == 0) {
// do nothing
}
while (P3_2 == 1) {
P3_0 = !P3_0;
P3_1 = !P3_1;
DELAY();
if (P3_2 == 0) {
P3_0 = 1;
P3_1 = 0;
P1_2 = 0;
ACC = ACC | 0x80;
PSW = PSW | 0x80;
EX0 = 1;
main();
}
}
return;
}
```
阅读全文