Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1687
  • Last Modified:

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
0
yunikon
Asked:
yunikon
  • 10
  • 4
  • 2
  • +4
2 Solutions
 
CmdrRickHunterCommented:
just a guess... try making main into _main like it seems to be asking?
0
 
yunikonAuthor Commented:
Thanks, that creates other errors.

-y
0
 
RHenningsgardCommented:
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---
0
[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

 
RHenningsgardCommented:
"oterh"?  Man, my fingers are sleepy this morning!
0
 
yunikonAuthor Commented:
I get block nesting errors.  Using QEDITOR, MASM32.

-y
0
 
DanRollinsCommented:
>>  block nesting errors
Change
        main
 to
        _main
in all three places.

-- Dan
0
 
yunikonAuthor Commented:
Getting error  'symbol type conflict'  at line,

mov   ax, seg message  

after lines,
 
.code
main   proc
   
0
 
DanRollinsCommented:
Try replacing all occurrences of
      main
with
      _main

It's worth a try.  If that doesn't work, try changing that line to...

     mov   ax, cs
0
 
yunikonAuthor Commented:
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
0
 
yunikonAuthor Commented:
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
0
 
DanRollinsCommented:
One old trick is
     PUSH CS
     POP AX


0
 
The_SharK_356Commented:
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"
0
 
yunikonAuthor Commented:


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
0
 
DanRollinsCommented:
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.
0
 
DawafflemanCommented:
.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.
0
 
yunikonAuthor Commented:
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?
0
 
stefan73Commented:
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
0
 
DawafflemanCommented:
or you could just change it to model medium and keep the ds cs and es
0
 
yunikonAuthor Commented:
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.
0
 
yunikonAuthor Commented:
I suspect that I need a 16 bit linker for the 32 bit masm.  Trying to find a site with the linker.

-y
0
 
yunikonAuthor Commented:
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 10
  • 4
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now