0

I'm just a beginner in assembly programming. This is the code I was trying, but it keeps returning an error.

Error is:

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

My program is:

;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

Thank you in advance.

hexacyanide
  • 88,222
  • 31
  • 159
  • 162

3 Answers3

0

Add .model small as the first line.

Gunner
  • 5,780
  • 2
  • 25
  • 40
  • 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 Microsoft (R) Segmented Executable Linker Version 5.60.339 Dec 5 1994 Copyright (C) Microsoft Corp 1984-1993. All rights reserved. Object Modules [.obj]: PRINTSTRING.obj Run File [PRINTSTRING.exe]: "PRINTSTRING.exe" List File [nul.map]: NUL Libraries [.lib]: Definitions File [nul.def]: LINK : warning L4021: no stack segment LINK : warning L4038: program has no starting address @gunner – Prateek Sharma Mar 10 '13 at 06:14
0

First, why are you doing 16bit DOS Assembly? 32Bit Assembly is a bit easier!

This works:

.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

Assemble and link:

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>

It runs fine in DOSBox

Gunner
  • 5,780
  • 2
  • 25
  • 40
0

try this

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 
Dave Ross
  • 3,313
  • 1
  • 24
  • 21
SAM
  • 1