2013-03-05 170 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