如下代码:
assume cs:code,ds:data
data segment
db 'welcome to masm!'
db '................'
data ends
code segment
start:
mov ax, 0
mov ax, data
mov ds, ax
mov si, 0
mov di, 16
mov cx, 8
s: mov ax, [si]
mov [di], ax
add si, 2
add di, 2
loop s
mov ax, 4c00h
int 21
code ends
end
用del "%1.exe"
del "%1.obj"
ml /c /nologo "%1.asm"
doslnk "%1.obj"
执行之后,运行异常,发现它的数据段跑到代码段中了
将代码段位置调整一下,编译之后发现正常
*****************************************
assume cs:code,ds:data
code segment
data segment
db 'welcome to masm!'
db '................'
data ends
start:
mov ax, 0
mov ax, data
mov ds, ax
mov si, 0
mov di, 16
mov cx, 8
s: mov ax, [si]
mov [di], ax
add si, 2
add di, 2
loop s
mov ax, 4c00h
int 21
code ends
end
阅读(1555) | 评论(2) | 转发(0) |