一个汇编程序,高手帮我注释一下吧,看不懂

来源:百度知道 编辑:UC知道 时间:2024/05/15 08:09:52
一个排序题目,主要不太理解他的存储。
他不用转化的,ascii码直接比较码?
帮帮小弟
.286
.model small
;---------------------------------------------------------------
.code
start:
push cs
pop ds
push cs
pop es

mov ah,09h
mov dx,offset msg1
int 21h

;输入功能从这里开始
mov dx,offset InputBuffer
sub bx,bx
mov ah,3fh
mov cx,80h
int 21h

mov si,offset InputBuffer
mov di,offset numbers
sub ax,ax
mov cx,0ah

@InputLoop:
sub bx,bx
sub bp,bp

call Skip
cmp al,'+'
je @Positive
cmp al,'-'
jne @SignEnd
inc bp
@Positive:
mov al,[si]
inc si
@SignEnd:

@ReadBegin:
sub al,'0'
jl @ReadEnd
cmp al,9
jg @ReadEnd
imul bx,bx,0ah
add bx,ax
mov al,[si]
inc si
jmp @ReadBegin
@ReadEnd:

or bp,bp
je @SignChan

程序已经把ACSII转成十进制了,看这一段

;输入功能从这里开始
mov dx,offset InputBuffer
sub bx,bx
mov ah,3fh
mov cx,80h
int 21h

mov si,offset InputBuffer
mov di,offset numbers
sub ax,ax
mov cx,0ah

@InputLoop:
sub bx,bx
sub bp,bp

call Skip ;如果遇到空格符(20h)或者(09h)则忽略并继续读下一字符

;----------------------------------------------------------------
;这一段确定当前数字的符号,如果是正号则令bp=0,如果是负号则bp=1
cmp al,'+'
je @Positive
cmp al,'-'
jne @SignEnd
inc bp
@Positive:
mov al,[si]
inc si
@SignEnd:
;----------------------------------------------------------------

;这一段将连续的ascii码(30h--39h)按十进制转化为数值(按16进制存储)
@ReadBegin:
sub al,'0' ;用当前ascii码减去'0'的ascii码(30h)得到当前字符代表的数值

jl @ReadEnd ;如果得到的数值不是0--9,则认为一个数字已读完
cmp al,9
jg @ReadEnd

imul bx,bx,0ah ;如果是0--9则把已经读到的数值乘以10,再加上当前数值