编程题目
1、分别把数12H,14H存入单元40H,41H,然后把这个数取出来,进行相加,并把结果存入42H。 ORG 0100H MOV 42H, #00H MOV 40H, #12H MOV 41H, #14H
MOV 42H, #40H+41H END
2、分别把12H,14H存入单元40H,41H,然后取出这两个单元里的内容的低半字节,合成一个字节,其中40H单元的内容的低半字节放在合成字节中的低半字节,41H单元的内容的低半字节放在合成字节的高半字节,并把结果存入43H.. ORG 1000H MOV 40H, #12H MOV 41H, #14H ANL 40H, #0FH ANL 41H, #0FH MOV A,41H SWAP A ADD A,40H MOV 43H,A END
SDA EQU P1.0 CLK EQU P1.1
ORG 4000H AJMP MAIN ORG 4100H MAIN:
MOV SP,#60H LEDRESET:
MOV r2,#7FH MOV R1,#08H
CLR P1,7
LEDUP: ACALL TXDBYTE ACALL DELAY MOV A,R2 RR A
MOV R2,A
DJNZ R1,LEDUP AJMP LEDRESET ;若发送的数据存放在R2中 TXDBYTE:
PUSH PSW PUSH ACC MOV A,R2 MOV R3,?#08H TXDUP: RLC A MOV SDA,C CLR CLK SETB CLK
DJNZ R3,TXDUP POP ACC POP PSW RET ;延时子程序
DELAY: MOV R7,#0b0H;12M时钟下延时1MS DELAY0: MOV R6,#0f0H DELAY1: nop nop nop
DJNZ R6,DELAY1 DJNZ R7,DELAY0 RET END
SDA EQU P1.0 CLK EQU P1.1
ORG 4000H AJMP MAIN ORG 4100H MAIN:
MOV SP,#60H LEDRESET:
MOV r2,#7FH
MOV R1,#08H CLR P1.7
LEDUP: ACALL TXDBYTE ACALL DELAY MOV A,R2 RR A
MOV R2,A
DJNZ R1,LEDUP AJMP LEDRESET ;若发送的数据存放在R2中 TXDBYTE:
PUSH PSW PUSH ACC MOV A,R2 MOV R3,#08H TXDUP: RLC A MOV SDA,C CLR CLK SETB CLK
DJNZ R3,TXDUP POP ACC POP PSW RET ;延时子程序
DELAY: MOV R7,#0b0H;12M时钟下延时1MS DELAY0: MOV R6,#0f0H DELAY1: nop nop nop
DJNZ R6,DELAY1 DJNZ R7,DELAY0 RET END
因篇幅问题不能全部显示,请点此查看更多更全内容