Link to home
Start Free TrialLog in
Avatar of yunikon
yunikon

asked on

assemble error

Assembled this code and got errors shown,

[CODE]
model small
.stack
.data
message   db "Hello world, I'm learning Assembly !!!", "$"

.code

main   proc
   mov   ax, seg message  ;ERROR - SYMBOL TYPE CONFLICT
   mov   ds,ax

   mov   ah,09
   lea   dx,message
   int   21h

   mov   ax,4c00h
   int   21h
main   endp
end main  ;ERROR - with /coff switch,  leading underscore required for start address :main
[/CODE]

-y
SOLUTION
Avatar of CmdrRickHunter
CmdrRickHunter

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yunikon
yunikon

ASKER

Thanks, that creates other errors.

-y
Other errors?  OK, and what would the oterh errors be?

Odds are that the assembler is aborting on not finding a properly-named entry point _MAIN, which is why it's not reporting your other errors until you correct the entry point name error.

Rob---
"oterh"?  Man, my fingers are sleepy this morning!
Avatar of yunikon

ASKER

I get block nesting errors.  Using QEDITOR, MASM32.

-y
Avatar of DanRollins
>>  block nesting errors
Change
        main
 to
        _main
in all three places.

-- Dan
Avatar of yunikon

ASKER

Getting error  'symbol type conflict'  at line,

mov   ax, seg message  

after lines,
 
.code
main   proc
   
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yunikon

ASKER

Program assembles when substitute mov  ax, cs.   Try to Assemble & Link or Build All.  Get  error,

'test2.obj: fatal error LNK1190: invalid fixup found, type 0x0001
-
Link error'

Also cursor always stops at line,    mov  ax, (cursor)cs
Avatar of yunikon

ASKER

The theory behind the problem is that message is an identifier inside segment, .data.  message defines the byte string  "Hello world, I'm learning Assembly !!!", inside .data segment.  I'm trying to load the number of the segment, .data, into register ax.   seg message is supposed to represent this numbert.

   mov ax, seg message

Assembler is seeing    seg message   as invalid.

Is there another way to represent   data segment's  number for  this mov instruction?

y
One old trick is
     PUSH CS
     POP AX


REMOVE [code]      line 1
REMOVE .stack      line 3
REMOVE [/CODE]  line 21

change "$"      line 5
to     "0"

change mov ax,seg message
to     mov ax,offset message

above "main proc"
type "start"

instead of "end main"
type "end start"
Avatar of yunikon

ASKER



SharK 356,

[CODE] and [/CODE] are not part of program.   They indicate that a program is within them.   Corrected program,

.model small
                 
.data
message   db "Hello world, I'm learning Assembly !!!","0"

.code
start
_main   proc
   mov  ax, offset message        
   mov   ds,ax
   mov   ah,09
   lea   dx,message
   int   21h
   mov   ax,4c00h
   int   21h
_main   endp
end start


errors,

 Assembling: C:\masm32\test2.asm
C:\masm32\test2.asm(9) : error A2008: syntax error : start
C:\masm32\test2.asm(22) : error A2006: undefined symbol : start
C:\masm32\test2.asm(22) : error A2148: invalid symbol type in expression : start
 Volume in drive C has no label.
 Volume Serial Number is 000D-9CE8

 Directory of C:\masm32

09/28/2004  10:23a                 310 test2.asm
               1 File(s)            310 bytes
               0 Dir(s)  23,054,757,888 bytes free
----------------------------------------------------
Dan,

.model small

.data
message   db "Hello world, I'm learning Assembly !!!","0"

.code

_main   proc
             
   push cs
   pop ax
   mov ds,ax

   mov   ah,09
   lea   dx,message
   int   21h

   mov   ax,4c00h
   int   21h
_main   endp
end _main

get error,

test2.obj : fatal error LNK1190:  invalid fixup found, type 0x0001

program came from this site,

http://www.xs4all.nl/~smit/asm01001.htm

Under  'Index of Section1', click  'Code Example'  on left
I think that in small model, DS will be already set the same as CS.

Se if just removing the two lines:

   mov   ax, seg message  ;ERROR - SYMBOL TYPE CONFLICT
   mov   ds,ax

will work.

All things considered, you should also try just put the message in the code segment:

.model small

.code
message   db "Hello world, I'm learning Assembly !!!","0"
_main   proc
   mov   ah,09
   lea   dx,message
   int   21h

   mov   ax,4c00h
   int   21h
_main   endp
end _main

-- Dan

(note: I normally test code before providing it, but I have not used MASM directly for many years... It is *so much* more efficient (time-wise) to program in C and just use _asm{} blocks when doing low-level coding.

Also, 16-bit coding like this (small model) is way obsolete.  I haven't had to worry about setting segment registers since about 1995.
.model small
                 
.data
message   db "Hello world, I'm learning Assembly !!!","0"

.code
start
_main   proc
   mov  ax, offset message        
   mov   ds,ax
   mov   ah,09
   lea   dx,message
   int   21h
   mov   ax,4c00h
   int   21h
_main   endp
end start

this will work but you need to place a : in front of start so it is read as a label like so..

.model small
                 
.data
message   db "Hello world, I'm learning Assembly !!!","0"

.code
start:
_main   proc
   mov  ax, offset message        
   mov   ds,ax
   mov   ah,09
   lea   dx,message
   int   21h
   mov   ax,4c00h
   int   21h
_main   endp
end start

it seems that is what the assembler is bragging about

and another question (i havent used masm so i dont know if it is required) should the main part be a procedure? maybe you should try getting rid of the _main lines, unless they are neccisary when working with masm.
Avatar of yunikon

ASKER

Dan:-

Removing  '
  mov   ax, seg message  ;ERROR - SYMBOL TYPE CONFLICT
   mov   ds,ax
'
was usuccessful.

Tried the following correction.  Code assemble's.  When link get error,  

test2.obj : fatal error LNK1109:  invlalid fixup found, type 0x0001

CODE,

.model small

.code
 
    message   db "Hello world, I'm learning Assembly !!!","0"
 
 _main   proc
   
   mov ds,ax
   mov dx,OFFSET message          
   mov   ah,09
   lea   dx,message
   int   21h

   mov   ax,4c00h
   int   21h
_main   endp
end _main



             -------------------------------------------------

Dawaffleman:-

Application assembles only the code below.  When link get error

test2.obj : fatal error LNK1109:  invlalid fixup found, type 0x0001


CODE,

.model small                  
.data
message   db "Hello world, I'm learning Assembly !!!","0"

.code
_start:
   
   mov  ax, offset message        
   mov   ds,ax
   mov   ah,09
   lea   dx,message
   int   21h
   mov   ax,4c00h
   int   21h
   
end _start

What assembly application do you use?
Hi DanRollins,
> I think that in small model, DS will be already set the same as CS.
That's in tiny (.com) only.

But still, he won't have to modify the CS and DS. They should be OK.

Yunikon: Try tiny model, and leave out the .code and .data lines. Move your data behind the code. Don't modify CS, DS, ES.

Cheers!

Stefan
or you could just change it to model medium and keep the ds cs and es
Avatar of yunikon

ASKER

Used tiny model and assemble.  Get error ,  ' model must precede .stack and .data directives' and also error     'must be in segment block'     for lines from       message db "Hello world, ......   to      int 21h.

Removed .data and .code.   When assemble get error     'must be in segment block'    as above.

When use model medium code assembles but get error,

test2.obj : fatal error LNK1109:  invlalid fixup found, type 0x0001.

However .data and .code must be present else get  error       'must be in segment block'     as above.
Avatar of yunikon

ASKER

I suspect that I need a 16 bit linker for the 32 bit masm.  Trying to find a site with the linker.

-y
Avatar of yunikon

ASKER

The error is that I was using a 32 bit linker for the 16 bit DOS files.
 
Microsoft ® Incremental Linker Version 5.12.8078
Copyright © Microsoft Corp 1992-1998. All rights reserved.

My files are now working ok.
Appreciate all the help.

-y