汇编语言,找出最大值与最小值
STACK1 SEGMENT STACK
DW 256 DUP(?)
STACK1 ENDS
DDATA SEGMENT
MES1 DB 'The least number is:$'
MES2 DB 0AH,0DH,'The largest number is:$'
NUMB DB 0D9H,07H,8BH,0C5H,0EBH,04H,9DH,0F9H
DDATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DDATA
START: MOV AX,DDATA
MOV DS,AX
MOV SI,OFFSET NUMB
MOV CX,0008H
;JCXZ A4
MOV BH,[SI]
MOV BL,BH
A1: LODSB ;AL=DS:[SI],SI=SI+1 取串指令
CMP AL,BH
JBE A2
MOV BH,AL
JMP A3
A2: CMP AL,BL
JAE A3
MOV BL,AL
A3: LOOP A1
A4: MOV DX,OFFSET MES1 ;show mes1
MOV AH,09H
INT 21H
MOV AL,BL ;show the least number
AND AL,0F0H ;get the highest 4 bits
SHR AL,4
CMP AL,0AH
JB C2
ADD AL,07H
C2: ADD AL,30H
MOV DL,AL ;show character
MOV AH,02H
INT 21H
MOV AL,BL
AND AL,0FH ;get the lowest 4 bits
CMP AL,0AH
JB C3
ADD AL,07H
C3: ADD AL,30H
MOV DL,AL ;show character
MOV AH,02H
INT 21H
MOV DX,OFFSET MES2 ;show mes2
MOV AH,09H
INT 21H
MOV AL,BH ;show the largest number
AND AL,0F0H ;get the highest 4 bits
SHR AL,4
CMP AL,0AH
JB C22
ADD AL,07H
C22: ADD AL,30H
MOV DL,AL ;show character
MOV AH,02H
INT 21H
MOV AL,BH
AND AL,0FH ;get the lowest 4 bits
CMP AL,0AH
JB C33
ADD AL,07H
C33: ADD AL,30H
MOV DL,AL ;show character
MOV AH,02H
INT 21H
MOV AX,4C00H ;go back to dos
INT 21H
CODE ENDS
END START
摘自 jbx929205249的专栏
补充:软件开发 , 其他 ,