keil 编译汇编语言和c语言生成.hex文件 20
汇编org0sjmpSTARTorg30hSTART:movP1,#0FFh;LED不亮st1:movP2,#0FFh;准备读数(开关状态)movA,P2;读数anlA,...
汇编
org 0
sjmp START
org 30h
START: mov P1,#0FFh ;LED不亮
st1: mov P2,#0FFh ;准备读数(开关状态)
mov A,P2 ;读数
anl A,#0Fh ;取低四位
acall SEG7 ;调用显示码子程序
mov P1,A ;将得到的显示码送数显管显示
sjmp st1 ;循环
SEG7: inc A ;该子程序实现将数字转换为显示码
movc A,@A+pc
ret
DB 0c0h,0F9h,0a4h,0b0h
DB 99h,92h,82h,0F8h
DB 80h,90h,88h,83h
DB 0c6h,0a1h,86h,8eh
end
c语言
#include<reg51.h>
int main(){
P1 = 0xff;
while(1){
P2 = 0xff;
ACC = P2;
ACC &= 0xf;
switch(ACC){
case 0: P1 = 0xc0; break;
case 1: P1 = 0xf9; break;
case 2: P1 = 0xa4; break;
case 3: P1 = 0xb0; break;
case 4: P1 = 0x99; break;
case 5: P1 = 0x92; break;
case 6: P1 = 0x82; break;
case 7: P1 = 0xf8; break;
case 8: P1 = 0x80; break;
case 9: P1 = 0x90; break;
case 10: P1 = 0x88; break;
case 11: P1 = 0x83; break;
case 12: P1 = 0xc6; break;
case 13: P1 = 0xa1; break;
case 14: P1 = 0x86; break;
case 15: P1 = 0x8e; break;
}
}
while(1);
}
求这两个代码对应的hex文件 展开
org 0
sjmp START
org 30h
START: mov P1,#0FFh ;LED不亮
st1: mov P2,#0FFh ;准备读数(开关状态)
mov A,P2 ;读数
anl A,#0Fh ;取低四位
acall SEG7 ;调用显示码子程序
mov P1,A ;将得到的显示码送数显管显示
sjmp st1 ;循环
SEG7: inc A ;该子程序实现将数字转换为显示码
movc A,@A+pc
ret
DB 0c0h,0F9h,0a4h,0b0h
DB 99h,92h,82h,0F8h
DB 80h,90h,88h,83h
DB 0c6h,0a1h,86h,8eh
end
c语言
#include<reg51.h>
int main(){
P1 = 0xff;
while(1){
P2 = 0xff;
ACC = P2;
ACC &= 0xf;
switch(ACC){
case 0: P1 = 0xc0; break;
case 1: P1 = 0xf9; break;
case 2: P1 = 0xa4; break;
case 3: P1 = 0xb0; break;
case 4: P1 = 0x99; break;
case 5: P1 = 0x92; break;
case 6: P1 = 0x82; break;
case 7: P1 = 0xf8; break;
case 8: P1 = 0x80; break;
case 9: P1 = 0x90; break;
case 10: P1 = 0x88; break;
case 11: P1 = 0x83; break;
case 12: P1 = 0xc6; break;
case 13: P1 = 0xa1; break;
case 14: P1 = 0x86; break;
case 15: P1 = 0x8e; break;
}
}
while(1);
}
求这两个代码对应的hex文件 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询