ORG 0000H
MAIN:
MOV 50H, #0 ;先用0充当最小值.
MOV R0, #40H ;起始地址.
LOOP: MOV A, @R0 ;取出一个数.
CLR C
SUBB A, 50H ;减去最小值.
JNC NEXT ;无借位(即够减)转移.
MOV 50H, @R0 ;否则就用这个数当最小值.
NEXT: INC R0 ;转向下一个地址.
CJNE R0, #4AH, LOOP;不到最后就转到前面去循环比较.
SJMP $ ;暂停.
END ;完.
ORG 00H
START:
MOV SP,#5FH
CLR RS0
CLR RS1
CLR A
MOV B,#00H
MOV R0,#40H
MOV A,@R0
LOOP:
INC R0
MOV 03H,@R0
MOV B,03H
PUSH ACC
PUSH B
DIV AB
JZ NEXT
POP ACC
POP B
AJMP END_LOOP
NEXT:
POP B
POP ACC
END_LOOP:
CJNE R0,#49H,LOOP
MOV 50H,A
SJMP $
END
ORG 0000H
MOV R0,#41H
MOV R7,#10
MOV 50H,40H
LOOP: MOV A,@R0
CJNE A,50H,$+3
JNC LOOP1
XCH A,50H
LOOP1: INC R0
DJNZ R7,LOOP
SJMP $
END
START_ADDR EQU 40H
END_ADDR EQU 49H
DEST EQU 50H
ORG 0000H
MAIN:
MOV RO, #START
LOOP:
MOV A, R0,
MOV R1, A
INC R1
MOV A, @R0
CLR C
SUBB A, @R1
JC NEXT
NEXT:
SJMP OVERFLY
MOV A, @R0
MOV @R1, A
OVERFLY:
INC R0
CJNE R0, #END_ADDR - START_ADDR + 1, LOOP
MOV A, @END_ADDR
MOV @DEST, A
Note:The subroutine above just suit unsigned 8-bits comparasion.
请参考