微机原理实验,实验四程序

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

方波发生

ORG 0000H

START:CPL P1.0

MOV R2,#25

LCALL DELAY

SJMP START; DELAY:PUSH 02H

LP1: PUSH 02H

LP2: PUSH 02H

LP3: DJNZ R2,LP3

POP 02H

DJNZ R2,LP2

POP 02H

DJNZ R2,LP1

POP 02H

DJNZ R2,DELAY

RET

END P1口输出

ORG 0000H

LJMP LOOP

ORG 0030H

LOOP: MOV A,#0FH

MOV P1,A

MOV A,P1

ORL A,#0F0H

SWAP A

MOV P1,A

SJMP LOOP

END

P1口输出3

ORG 0000H

LJMP LOOP

ORG 0030H

LOOP: MOV A,#0FH

MOV P1,A

MOV A,P1

ORL A,#0F0H

CJNE

A,#0FFH,NEXT

MOV A,#10H

LOOP1:MOV P1,A

RL A

MOV R2,#25H

LCALL DELAY

CJNE

A ,#01H,LOOP1

SJMP LOOP

NEXT: MOV P1,#0FFH

SJMP LOOP

DELAY: PUSH 02H

LP1: PUSH 02H

LP2: PUSH 02H

LP3: DJNZ R2,LP3

POP 02H

DJNZ R2,LP2

POP 02H

DJNZ R2,LP1

POP 02H

DJNZ R2,DELAY

RET

END

外部中断(1)p1

ORG 0000H

SRART:LJMP MAIN;

ORG 0003H

INT0: LJMP INT0S;

ORG 0030H

MAIN:MOV P1,#0FFH

SETB PX0

SETB IT0

SETB EX0

SETB EA

REP:SJMP REP;

INT0S:MOV A,P1

SWAP A

CPL A

ORL A,#0FH

MOV P1,A

RETI

END

外部中断(1)循环左移

ORG 0000H

SRART: LJMP MAIN;

ORG 0003H

INT0: LJMP INT0S;

ORG 0030H

MAIN: MOV P1,#0FFH

SETB PX0

SETB IT0

SETB EX0

SETB EA

MOV A,#10H

REP: SJMP REP

INT0S: MOV P1,A

MOV R2,#25H

LCALL DELAY

RL A

CJNE A,#01H,INT0S

MOV A,#10H

SJMP INT0S

RETI

DELAY:PUSH 02H

LP1: PUSH 02H

LP2: PUSH 02H

LP3: DJNZ R2,LP3

POP 02H

DJNZ R2,LP2

POP 02H

DJNZ R2,LP1

POP 02H

DJNZ R2,DELAY

RET

END

外部中断(1)奇数偶数ORG 0000H

MOV R3,#00H SRART:LJMP MAIN; ORG 0030H

INT0:MOV A,R3

MOV B,#02

DIV AB

JNB B,INT01

MOV A,#10H

LJMP INT02;

ORG 0040H MAIN:MOV P1,#0FFH

SETB PX0

SETB IT0

SETB EX0

SETB EA

INC R3

REP: SJMP REP; INT01:MOV A,P1

SWAP A

ORL A,#0FH

MOV P1,A

RETI INT02:MOV P1,A

MOV R2,#25H

LCALL DELAY

RL A

CJNE A,#01H,INT02

MOV A,#10H

RETI

SJMP MAIN

DELAY: PUSH 02H

LP1: PUSH 02H

LP2: PUSH 02H

LP3: DJNZ R2,LP3

POP 02H

DJNZ R2,LP2

POP 02H

DJNZ R2,LP1

POP 02H

DJNZ R2,DELAY

RET

END

外部中断(2)

ZWMADDR EQU 8002H;

ZXMADDR EQU 8004H;

ORG 0000H

LJMP START;

ORG 0003H

INT0: LJMP INT0S

START: SETB PX0

SETB IT0

SETB EX0

SETB EA

MOV A,#7FH

MOV DPTR,#ZXMADDR

MOVX @DPTR,A

MOV A,#01H

LOOP:

MOV DPTR,#ZWMADDR

MOVX @DPTR,A

LJMP LOOP

INT0S: RL A

CJNE A,#40H,BYE

MOV A,#01H

BYE: R ETI

END

外部中断(2)0~F

ZWMADDR EQU 8002H;

ZXMADDR EQU 8004H;

ORG 0000H

LJMP START;

ORG 0003H

INT0: LJMP INT0S

START: SETB PX0

SETB IT0

SETB EX0

SETB EA

MOV R3,#20H

MOV R4,#00H

LOOP:

MOV DPTR,#CHAR

MOV A,R4

MOVC A,@A+DPTR

MOV DPTR,#ZXMADDR

MOVX @DPTR,A

MOV A,R3

MOV DPTR,#ZWMADDR

MOVX @DPTR,A

LJMP LOOP

INT0S: MOV A,R3

RR A

MOV R3,A

INC R4

CJNE R3,#80H,BYE

MOV R3,#20H

BYE: R ETI

CHAR:DB

3FH,06H,5BH,4FH,66H,6DH,7D

H,07H

DB

7FH,6FH,77H,7CH,39H,5EH,79

H,71H

END

相关文档
最新文档