考试的时候千万不要着急,一步一步来,不到最后一刻千万不要放弃,加油,你也一定可以的!
ORG 0000H RESET: AJMP MAIN ORG 000BH AJMP IT0P MAIN: MOV SP, #60H; MOV TMOD, #01; ACALL PT0M0; HRER: AJMP HERE PT0M0: MOV TL0, #0CH MOV TH0, #0FEH SETB ET0; SETB EA; SETB TR0; RET IT0P: MOV TL0, #0CH MOV TH0, #0FEH CPL P1.0; RETI;
ORG 0000H RESET: AJMP MAIN ORG 000BH AJMP IT0P ORG 0100H MAIN: MOV SP, #60H MOV B, 0AH ACALL PT0M0 HERE: AJMP HERE PT0M0: MOV TMOD, #01H MOV TL0, # MOV TH0, # SETB ET0 SETB EA SETB TR0 RET IT0P: MOV TL0,# MOV TH0,# JNZ B, LOOP RTURN: RETI
ORG 0000H RESET: AJMP MAIN ORG 000BH AJMP IT0P ORG 001BH AJMP IT1P ORG 1000H MAIN: MOV SP, #60H ACALL PT0M2 LOOP: MOV C, F0 JNC LOOP HERE: AJMP HERE PT0M0: MOV TMOD, #25H MOV TL0, #FFH MOV TH0, #FFH SETB ET0 MOV TL1, #06H MOV TH1, #06H CLR F0 SETB EA SETB TR0 RET IT0P: CLR TR0 SETB F0 RETI IT1P: CPL P1.0 RETI
ORG 0100H START: MOV R0, #0FEH MOV A, #00H LOOP: MOVX @R0, A INC A JNZ LOOP
ORG 0100H START: MOV R0, #0FEH MOV A, #00H UP: MOVX @R0, A INC A JNZ UP DOWN: DEC A MOVX @R0, A JNZ DOWN AJMP UP
ORG 0100H START: MOV R0, #0FEH MOV A, #data1 MOVX @R0, A ACALL DELAY1 MOV A, #data2 MOVX @R0, A ACALL DELAY2
#include<reg51.h> #define uchar unsigned char #define uint unsigned int #define DigW P1 //设置P1口为位选口(选择第几位的) #define DigD P2 //P2为段选,(选择数码管的哪段亮起来的) uchar show[] = {5, 2, 0, 1, 3, 1, 4}; uchar DigT[] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71}; //共阴极数码管0~9,a-f段码表 /**************************延时函数*************************/ void delay() { uint j; for (j = 0; j < 150; j++); } /**************************主函数*************************/ void main(void) { Dig_W = 0x00;//关数码管 Dig_D = 0x00; while (1) { uchar temp = 0x80; for (uchar i = 0; i < 7; i++) { Dig_W = tmep; Dig_D = DigT[show[i]+1]; delay(); temp = temp >> 1; } } }
#include <reg51.h> #define uchar unsigned char #define uint unsigned int #define Dig_W P1 #define Dig_D P2 #define io_KEY P3 uchar key_T[] = {0xee, 0xde, 0xbe, 0x7e, 0xed, 0xdd, 0xbd, 0x7d, 0xeb, 0xdb, 0xbb, 0x7b, 0xe7, 0xd7, 0xb7, 0x77}; //按键值 uchar dis_T[] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71}; //共阴极数码管0~9,a-f段码表 uchar zhi = 0; /**************************延时函数*************************/ void d_ms() { uint j; for(j=0;j<150;j++); } /**************************显示函数*************************/ void display(uchar num) { uchar i, temp; temp = 0x80; Dig_W = temp; Dig_D = dis_T[num]; temp = temp >> 1; } uint Scanner() { int 列 = 0, 行 = 0, 按键 = 0, a; io_KEY = 0xf0; //P2口后4位置高电平前4位置低电平,当有按键按下时确定列数 while (io_KEY == 0xf0); //判断P2口是否有信号输入 列 = io_KEY; //保存列数 delay(); io_KEY = 0x0f; //P2口后4位置低电平前4位置高电平,当有按键按下时确定行数 while (io_KEY == 0x0f); //判断P2口是否有信号输入 行 = io_KEY; //保存行数 按键 = 列 | 行; return 按键; } /**************************主函数*************************/ void main(void) { uint KeyV = 0; Dig_W = 0x00;//关数码管 Dig_D = 0x00; while (1) { KeyV = Scanner(); //得到按键值 for (int i = 0; i < 16; i++)//判断按键值 { if (key_T[i] == KeyV) { zhi = i; break; } } display(zhi); } }
MOV R0,#60H MOV R2,#10H CLR A TU: MOV @R0,A INC R0 INC A DJNZ R2,TU MOV R0, #60H MOV R1, #70H MOV R2, #10H TT: MOV A,@R0 MOV @R1,A INC R0 INC R1 DJNZ R2,TT RET END
MOV 70H, #12H MOV 71H, #90H MOV 72H, #78H MOV 60H, #56H MOV 61H, #34H MOV 62H, #12H MOV R0,#70H MOV R1,#60H MOV R2,#03H CLR CY LOOP:MOV A,@R0 ADDC A,@R1 DA A MOV @R1,A INC R0 INC R1 DJNZ R3,LOOP END
MOV 30H,#45H LOOP: MOV A,30H SWAP A ANL A,#0FH MOV 31H,A MOV A,30H ANL A,#0FH MOV 32H,A END MOV 32H,#98H MOV 31H,#76H MOV 30H,#54H MOV R2,#04H LOOP: CLR CY MOV A,30H RLC A MOV 30H,A MOV A,31H RLC A MOV 31H,A MOV A,32H RLC A MOV 32H,A DJNZ R2,LOOP RET END
ORG 0000H START: MOV R0,#60H MOV DPTR,#QW1 MOV R5,#0 MOV R7,#10H LOOP: MOV A,R5 MOVC A,@A+DPTR MOV @R0,A INC R0 INC R5 DJNZ R7,LOOP LJMP QW2 QW1: DB 60H,61H,62H,63H,64H,65H,66H,67H DB 68H,69H,6AH,6BH,6CH,6DH,6EH,6FH QW2:MOV R0,#60H MOV R1,#70H MOV R5,#0FH