下面程序有什么问题??(为什么没有输出字符,而是乱七八糟的符号)?

来源:百度知道 编辑:UC知道 时间:2024/06/26 01:25:35
assume cs:code,ds:data
data segment
string db 'd','c','h','e','a','g','f','b'
data ends

code segment
start:

mov cx,0
display:
mov bx,cx
mov dl,string[bx]
mov ah,2
int 21h

add cx,1
cmp cx,8
jne display

mov ah,0
int 16h

mov ax,4c00h
int 21h
code ends
end start

你没有把数据段的偏移地址给DS,没有获取正确的数据,所以会乱码,程序改成这样就可以了,输出的是dcheagfb,按回车退出 ,楼上的太监,这道题明明是我第一个答的,怎么我写的答案都跑到楼上去了
--------------------------------------------------

data segment
string db 'd','c','h','e','a','g','f','b'
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax

mov cx,0
display:
mov bx,cx
mov dl,string[bx]
mov ah,2
int 21h

add cx,1
cmp cx,8
jne display

mov ah,0
int 16h

mov ax,4c00h
int 21h
code ends
end start

data segment
string db 'd','c','h','e','a','g','f','b'
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov cx,0
display:
mov bx,cx
mov dl,string[bx]
mov ah,