我是汇编语言编程的新手,
我搜索了二进制搜索程序并找到了这个,我尝试理解该程序。它工作正常,但我无法理解代码的成功部分:
什么是ADD al,'0'
什么mov res,al
?
.model small
.stack 100h
.data
ARR DW 1000H,2000H,3000H,4000H,5000H,6000H
LEN DW ($-ARR)/2
KEY EQU 2000H
SUC DB "KEY IS FOUND AT$"
FAILURE DB "KEY IS NOT FOUND$"
RES DB "POSITION",13,10,"$"
.CODE
START:
MOV AX,@data
MOV DS,AX
MOV BX,00 ;LOW
MOV DX,LEN ;HIGH
MOV CX,KEY ;KEY
AGAIN:
CMP BX,DX
JA FAIL
MOV AX,BX
ADD AX,DX
SHR AX,1
MOV SI,AX
ADD SI,SI
CMP CX,ARR[SI]
JAE BIG
DEC AX
MOV DX,AX
JMP AGAIN
BIG:
JE SUCCESS
INC AX
MOV BX,AX
JMP AGAIN
SUCCESS:
ADD AL,01
ADD AL,'0'
MOV RES,AL
LEA DX SUC
JMP DISP
FAIL:
LEA DX,FAILURE
DISP:
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
END START