大家来看看我实验十的第三小题这样写有问题没
assume cs:codedata segment
db 10 dup (0)
data ends
code segment
start: mov ax,12666
mov bx,data
mov ds,bx
mov si,0
call dtoc
mov dh,8
mov dl,3
mov cl,2
call show_str
mov ax,4c00h
int 21h
show_str: push ax
push bx
push si
push es
mov bx,0b800h
moc es,bx
dtoc: mov cx,ax
jcxz ok
div ax
add dx,30h
mov ds:,dl
inc si
jamp offste dtoc
ok:
mov si,0
mov al,2
mov di,1123h
mov cx,ds:
jcxz s
mov dl,ds:
mov es:,dl
inc di
mov es:,al
inc si
inc di
jamp ok
s: pop ax
pop bx
pop si
pop es
ret
code ends
end start 会出现溢出。。还有就是JAMP&MOC这样的笔误要多留心。 assume cs:code
data segment
I DW 10 dup (0)
SAX DW ?
data ends
code segment
start: mov ax,12666
mov bx,data
mov ds,bx
mov si,0
call dtoc
mov dh,8
mov dl,3
mov cl,2
call show_str
mov ax,4c00h
int 21h
;==================================
;字符串显示
;==================================
show_str:
PUSH SI
PUSH DI
PUSH CX
PUSH DX
MOV AX,0B800H
MOV ES,AX
SUB DI,DI
ADD DL,DL
SUB AX,AX
MOV AL,DL
MOV DI,AX
MOV AL,DH
MOV AH,0
MOV BX,160
MUL BX
ADD DI,AX
LOOP_: MOV AL,DS:
CMP AL,0
JZ EXIT_
INC SI
MOV ES:,AL
INC DI
MOV ES:,CL
INC DI
JMP LOOP_
EXIT_:
POP DX
POP CX
POP DI
POP SI
RET
;==================================
;ASCII码转换DTOC
;==================================
dtoc:
PUSH SI
PUSH DI
PUSH BP
PUSH CX
MOV CX,0
MOV BX,10
TEST AX,DX
JNZ EXIT
MOV SAX,AX
MOV AX,DX
XOR DX,DX
CMP AX,0
JZ AX_PROC
DX_PROC:DIV BX
ADD DX,30H
PUSH DX
SUB DX,DX
INC CX
CMP AX,0
JNZ DX_PROC
AX_PROC:
MOV AX,SAX
TEST AX,DX
JNZ POP_
AX_: DIV BX
ADD DX,30H
PUSH DX
XOR DX,DX
INC CX
CMP AX,0
JNZ AX_
POP_:
POP DS:
INC SI
LOOP POP_
EXIT: POP CX
POP BP
POP DI
POP SI
ret
code ends
end start
{:5_108:}
页:
[1]