需要有关masm32程序的帮助

时间:2013-03-05 10:04:01

标签: 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

提前谢谢。

3 个答案:

答案 0 :(得分:0)

添加.model small作为第一行。

答案 1 :(得分:0)

首先,你为什么要做16位DOS程序集? 32位程序集更容易一些!

这有效:

.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中运行良好

答案 2 :(得分: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