求80C51单片机汇编程序:将片外3000H~303FH单元中最大和最小的找出分别放入3040H和3041H中

2025-01-03 08:33:38
推荐回答(2个)
回答1:

最小值的解决办法:理解后,自行调整并调试。并修改它,step8同时得到最大值处理。
1:设数据指针初值3000H MOV DPTR,#2FFFH MOV R0,#040H
2:设最小值为0xff, MOV A,#0FFH
3:初始化30H MOV 30H,A
4:是否结束 DJNZ R0, Step5 XCH A,30H MOVX @DPTR,A RET
5:读入数据。 INC DPTR MOVX A,@DPTR
6:比较A,30H,不等 CJNE A,30H,Step8
7:跳到4
8:判断进位标志 JC Step3
9:跳到4

回答2:

求80C51单片机汇编程序:将片外3000H~303FH单元中最大和最小的找出分别放入3040H和3041H中
汇编源程序如下:
ORG 0100H
ST: MOV RO,#00H
CLR C
MOV DPTR,#3000H
MOVX A,@DPTR
MOV 31H,A //31H单元中存放小值

MOV DPTR,#3001H
MOVX A,@DPTR
MOV 32H,A //32H单元中存放大值

MOV DPTR,#3002H
FHUI: MOVX A,@DPTR
CJNE A,31H,BXD
MOV 31H, A
MOV 32H,30H
LJMP NEXT

BDY: JBC C,MIN
CJNE A,32H,JIXU
LJMP NEXT
JIXU: JBC C,NEXT
MOV 32H,A
LJMP NEXT
MIN: MOV 31H, A
LJMP NEXT

NEXT: INC DPTR
INC R0
CJNE R0,#61,FHUI
MOV DPTR,#3040H
MOV A,32H
MOVX @DPTR,A
MOV DPTR,#3041H
MOV A,31H
MOVX @DPTR,A
MOV RO,#00H
NOP
NOP
END