0

我只是汇编编程的初学者。这是我正在尝试的代码,但它一直返回错误。

错误是:

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

先感谢您。

4

3 回答 3

0

添加.model small为第一行。

于 2013-03-06T04:19:13.360 回答
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 中运行良好

于 2013-03-10T06:57:20.103 回答
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 
于 2016-05-01T13:03:41.303 回答