News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

HELP

Started by mani_amoozadeh, January 25, 2008, 05:18:53 PM

Previous topic - Next topic

mani_amoozadeh

hi.
I'm new to MASM32.
in my first program I wrote a assembly language as follow.this simple program
gets a string and print it on screen.
when I creat object using MASM.exe 5.1 and link it using link.exe everything works fine.
but when I enter my program in MASM32 I can't assemble it.
the error is :

Assembling: C:\masm32\bin\new2.asm
C:\masm32\bin\new2.asm(35) : error A2008: syntax error : cmp
C:\masm32\bin\new2.asm(38) : error A2008: syntax error : while
C:\masm32\bin\new2.asm(22) : error A2004: symbol type conflict
C:\masm32\bin\new2.asm(53) : warning A4023: with /coff switch, leading underscore required for start address : start

can anyone help me ?



cr            equ         0dh
Lf            equ         0ah
               
stacksg               segment      stack
            dw        100h dup(?)
stacksg            ends   
               
datasg            segment   
prompt1            db         'Enter a string: ','$'
prompt2            db         cr,lf,'The string is: ','$'
string            label   byte
max            db   20
len            db   ?
buffer            db   20 dup(?)
datasg            ends   
               
codesg            segment   
            assume   ds:datasg,cs:codesg
start:               
            mov      ax,datasg
            mov      ds,ax
            mov      es,ax
               
            lea   dx,prompt1
            mov   ah,9h
            int   21h
               
            lea   dx,string
            mov   ah,0Ah
            int   21h
               
            lea   si,buffer
while:            cmp   BYTE PTR [si],0dh
            je   found
            inc   si
            jmp   while
found:            mov   BYTE PTR [si],'$'
               
            lea   dx,prompt2
            mov   ah,9h
            int   21h
               
            lea   dx,buffer
            mov   ah,9h
            int   21h
               
quit:            mov   ax,4c00h   
            int   21h   
               
codesg            ends         
            end   start

MichaelW

For MASM 6.0+ while is a reserved word. The MASM32 package includes MASM (ML.EXE) version 6.14. This version can be used to assemble 16-bit DOS code, but you cannot use the same command line that you would use for Windows code. For 16-bit DOS code the minimal command line would be like this:

ML /c filename.asm

And you must use a 16-bit linker, available here:

http://website.masm32.com/microsft.htm

Many people rename the 16-bit linker to LINK16.EXE to differentiate if from the 32-bit linker also named LINK.EXE. A minimal command line would be like this:

LINK16 filename.obj;

BTW, if you have a choice, it would probably be better to bypass the 16-bit DOS stuff and go directly to Win32 code.

eschew obfuscation

mani_amoozadeh

thank you very much.
ML /c filename.asm

1) what does switch /c stand for ? and how it works ?

2) I renamed the while lable. but the following error still happens !

C:\masm32\bin\new2.asm(21) : error A2004: symbol type conflict

3) what is the difference between start and _start

C:\masm32\bin\new2.asm(52) : warning A4023: with /coff switch, leading underscore required for start address : start

MichaelW

If I name the source help.asm, replace the two instances of while with _while, and use this batch file to assemble and link:

ML /c help.asm
pause
LINK16 help.obj;
Pause


Then there are no errors and the resulting program runs OK. If you are trying the use the MASM32 editor (Quick Editor) to assemble and link, then both will fail for multiple reasons. You can get information on the command line options from QE in Help\MASM32 Help\Command Line Tools. To see the command lines that QE is using, look at the batch files in \masm32\bin. If in 16-bit DOS code you use the .MODEL directive in combination with a .386 or higher processor directive, you must take care to place the initial processor directive after the .MODEL directive (this is just the opposite of what is done for Win32 code).
eschew obfuscation