学生做练习,软中断输出字符串出现乱码,求解
做80X86的习题,要求是把由十进制数ASCII码组成的字符串转换为对应的数值
.8086
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DATASEGMENT
string1db'33652214','$'
DATAENDS
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
CODESEGMENT
assumecs:CODE,ds:DATA
_Translation proc
;bx=10,cl=提取ASCII码,ax,dx=结果,si=指针
push bp
mov bp,sp
mov ax,0
mov dx,0
mov si,sp
mov si,ss:[si]
mov bx,10
mov cx,0
LOOP1:mov cl,byte ptr [si]
cmp cl,'$'
jzDONE
sub cl,48
mul bx
add ax,cx
adc dx,0
inc si
jmp LOOP1
DONE:mov sp,bp
pop bp
sub sp,2
push dx
push bx
ret
_Translation endp
START:
lea dx,string1
mov ah,9
int 21h
lea ax,string1
push ax
call _Translation
;
mov dl,al
mov ah,2
int 21h
mov dl,ah
mov ah,2
int 21h
;
mov ah,4ch
int 21h
CODEENDS
END START