微机原理及其应用 试编制一程序,找出DA数据区中带符号数的最大数和最小数

2024-11-14 14:10:01
推荐回答(1个)
回答1:

DATAS SEGMENT
ORG 3000H
DATA DB 23H,22H,43H,4H,90H,22H,1H,0EAH
MAX DB 0
MIN DB 0
DATAS ENDS

STACKS SEGMENT
DB 100 DUP(0)
STACKS ENDS

CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
MOV SI,OFFSET DATA
MOV CX,OFFSET MAX
SUB CX,OFFSET DATA
MOV BL,[SI];MAX
MOV BH,BL;MIN
DEC CX
K: INC SI
MOV AL,[SI]
CMP AL,BL;BL最大值
JL AG
MOV BL,AL
AG: CMP AL,BH;BH最小值
JG N
MOV BH,AL
N: LOOP K
MOV [MAX],BL
MOV [MIN],BH
INT 3
MOV AH,4CH
INT 21H
CODES ENDS
END START