2013-03-05 175 views
0

我只是一个汇编程序设计的初学者。这是我正在尝试的代码,但它一直返回一个错误。需要关于masm32程序的帮助

错误是:

F:\masm32\bin>ml PRINTSTRING.ASM 
Microsoft (R) Macro Assembler Version 6.14.8444 
Copyright (C) Microsoft Corp 1981-1997. All rights reserved. 
Assembling: PRINTSTRING.ASM 
PRINTSTRING.ASM(35) : fatal error A1010: unmatched block nesting : data 

我的计划是:

;Print a String 

data segment 
;add your data here 
mymessage db"Enter your data $" 
end 

stack segment 
dw 128 dup(0) 
end 

code segment 
Start: 

;Set Segment Registers 
    mov  ax,OFFSET mymessage 
    mov  ds,ax 
    mov  es,ax 
    lea  dx,mymessage 
    mov  ah,mymessage 
    mov  ah,9 
    int  21h 

    mov  ah,1 
    int  21h 

    mov  ax,4c00h 
    int  21h 

end 
end Start 

预先感谢您。

回答

0

添加.model small作为第一行。

+0

F:\ MASM32 \ BIN>毫升PRINTSTRING.ASM Microsoft (R)宏汇编程序版本6.14.8444 版权所有(C)Microsoft Corp 1981-1997。版权所有。 装配:PRINTSTRING.ASM Microsoft(R)分段可执行链接程序版本5.60.339 1994年12月5日 版权所有(C)Microsoft Corp 1984-1993。版权所有。 对象模块[.OBJ]:PRINTSTRING.obj 运行文件[PRINTSTRING.exe]: “PRINTSTRING.exe” 列表文件[nul.map]:NUL 库[.LIB]: 定义文件[nul.def ]: LINK:警告L4021:没有堆栈段 LINK:警告L4038:程序没有起始地址 @gunner – 2013-03-10 06:14:32

0

首先,你为什么要做16位的DOS汇编? 32Bit组装更容易!

这工作:

.model small 
.stack 100h 
.data 
mymessage db 'Enter your data $' 

.code 
start: 
    mov  ax, @data 
    mov  ds, ax 

    lea  dx, mymessage 
    mov  ah, 09h 
    int  21h 

    mov  ah, 1h 
    int  21h 

    mov  ax, 4c00h 
    int  21h 
end start 

汇编和链接:

D:\Projects\DOS>ml /c prateek.asm 
Microsoft (R) Macro Assembler Version 6.15.8803 
Copyright (C) Microsoft Corp 1981-2000. All rights reserved. 

Assembling: prateek.asm 

D:\Projects\DOS>link16 prateek.obj 

Microsoft (R) Segmented Executable Linker Version 5.60.339 Dec 5 1994 
Copyright (C) Microsoft Corp 1984-1993. All rights reserved. 

Run File [prateek.exe]: 
List File [nul.map]: 
Libraries [.lib]: 
Definitions File [nul.def]: 

D:\Projects\DOS> 

它运行正常在DOSBox中

0

试试这个

data segment 

;add your data here 

mymessage db"Enter your data $" 

data ends 

stack segment 

dw 128 dup(0) 

stack ends 

code segment 

Start: 


;Set Segment Registers 

    mov  ax,OFFSET mymessage 

    mov  ds,ax 

    mov  es,ax 

    lea  dx,mymessage 

    mov  ah,mymessage 

    mov  ah,9 

    int  21h 


    mov  ah,1 

    int  21h 


    mov  ax,4c00h 

    int  21h 


code ends 

end 
+0

您能否为您的答案添加一些满足感? – 2016-05-01 13:30:02