【问题标题】:Need help regarding a masm32 program需要有关 masm32 程序的帮助
【发布时间】:2013-03-05 10:04:01
【问题描述】:

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

错误是:

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

提前谢谢你。

【问题讨论】:

    标签: masm32


    【解决方案1】:

    .model small 添加为第一行。

    【讨论】:

    • F:\masm32\bin>ml PRINTSTRING.ASM Microsoft (R) 宏汇编器版本 6.14.8444 版权所有 (C) Microsoft Corp 1981-1997。版权所有。汇编:PRINTSTRING.ASM Microsoft (R) Segmented Executable Linker Version 5.60.339 Dec 5 1994 版权所有 (C) Microsoft Corp 1984-1993。版权所有。对象模块 [.obj]:PRINTSTRING.obj 运行文件 [PRINTSTRING.exe]:“PRINTSTRING.exe”列表文件 [nul.map]:NUL 库 [.lib]:定义文件 [nul.def]:链接:警告 L4021 :没有堆栈段链接:警告L4038:程序没有起始地址@gunner
    【解决方案2】:

    首先,您为什么要进行 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 中运行良好

    【讨论】:

      【解决方案3】:

      试试这个

      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 
      

      【讨论】:

      • 您能否为您的答案添加一些解释?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-23
      • 2014-12-26
      • 2013-08-12
      • 2014-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多