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文件 展开
意法半导体(中国)投资有限公司
2023-06-12 广告
2023-06-12 广告
单片机,即单片微控制器,也称为单片微型计算机,是将中央处理器(CPU)、存储器(ROM,RAM)、输入/输出接口和其他功能部件集成在一块 在一个小块的集成电路上,从而实现对整个电路或系统的数字式控制。单片机不是完成某一个逻辑功能的芯片,而是...
点击进入详情页
本回答由意法半导体(中国)投资有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询