Assembly program compiling and linking with TASM but not with MASM

Hi there,
   Please help me in compiling and linking an Assembly program. This program deals with port input/output. When I compile this using TASM it is working fine but with MASM (ml.exe also) a linking error comes like "unable to convert OMF to COFF. File invalid or corrupt" etc.

Thanks for any help.
Regards
San
"Be Good, Do Good".
san_hbsAsked:
Who is Participating?
 
BeyondWuConnect With a Mentor Commented:
san_hbs:
Have you ever tried my comment? I think it is because the ml will invoke the "link.exe" automatically, but the "link.exe" in the path is the 32-bit linker under the VC's bin folder, not the 16-bit linker under the masm's binr folder.So you should use Masm or ml/c to assembler your code, then you can link it with the 16-bit linker, to do this, you can type c:\masmdir\binr\link.

You can check if the ml use the 32-bit linker automatically with following method, you can rename the link.exe in VC's bin folder with other name, then use ml to compile your code again, if it throw "cannot find link.exe" error, it means the ml find the 32-bit linker firest. That because all the VC and masm in the system's path environment,and the VC's path must locate before the masm's path in the system's path environment.

I would like to know is your Visual C program a 32-bit windows program? From your masm code, it's seems you want to change the interrupt vector table, but if your program is a protect mode 32-bit windows program, how can you change it? It only available in DOS and V86 mode. Or maybe you are using a 16-bit VC?

Have a good day.
0
 
jimwassonCommented:
MASM as of version 6.1 has a /COFF command line option that will tell it to output COFF files.
0
 
BeyondWuCommented:
Try to use following command.
masm yourasm.asm
link yourasm (note: use the link under the binr folder in MASM)

Good Luck.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
san_hbsAuthor Commented:
Hi, Thanks for ur comments. I am a newbie in Assembly programming and unaware of good tricks. Here I am posting a part of code along with the error I am getting. Please try to help me.
=====
;TEST.ASM

PUBLIC  _vectloc
PUBLIC  _oldvect

     les     bx,DWORD PTR _vectloc          ;1
     mov     ax,WORD PTR es:[bx]          ;2
     mov     dx,WORD PTR es:[bx+2]          ;3
     mov     WORD PTR _oldvect,ax          ;4
     mov     WORD PTR _oldvect+2,dx          ;5
     mov     WORD PTR es:[bx],OFFSET _handler;6 _handler is a procedure
     mov     WORD PTR es:[bx+2],SEG _handler     ;7

TEST.ASM(1) : error A2074: cannot access label through segment registers
TEST.ASM(4) : error A2074: cannot access label through segment registers
TEST.ASM(5) : error A2074: cannot access label through segment registers

=====

Thanks in advance.
San
"Be Goood, Do Good".
0
 
ckhitlerCommented:
up
0
 
dimitryCommented:
Is _vectloc defined in your assembler code somewhere ?
Or you want to access it when it is defined in another file ? In this case you need to use "extrn" directive and not a "public".
If _vectloc is defined in code segment, then after
  les     bx,DWORD PTR _vectloc          ;1
you can add
  ASSUME  ES:TEXT
0
 
san_hbsAuthor Commented:
Hi,
 _vectloc and _oldvect are defined as follows in data segment:
=====
.data
_vectloc     DD     000001ccH
_oldvect     DD      0f000ff23H
=====
0
 
san_hbsAuthor Commented:
Hi,
I would like to describe the situation again. The assembly program I am writing will be interacting with MS Visual C program. For that I need to link the assembly object file with visual C project.

When I am compiling with ml.exe and parameter /c, no compilation error occurs, but at the time of linking I get the error like
====
/z2
"test.obj"
"test.exe"
NUL
LINK : warning LNK4044: unrecognized option "z2"; ignored
LINK : error : Segment reference in fixup record
test.obj : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
====

When I compile with ml.exe /coff, I get the compilation error mentioned in my comment dated 07/16/2002 above.

Please try to understand my situation and help me. I have got stuck with the situation.

Any help will be greatly appreciated.

Regards
San.
"Be Good, Do Good".
0
 
san_hbsAuthor Commented:
BeyondWu
You are right. I am trying to access the 16-bit assembly from 32-bit VC program. My intention to do this is I want to read a port from an ISA add-on card and get the values in my VC application. The assembly program I am trying to use is the existing one, which used to work on DOS based application written in C. Now I am trying to write an Application that will work on Windows platform. I am absolutely clueless, as how to proceed. Please help me and show me a way to proceed.

Thanks for any help.
San
0
 
BeyondWuCommented:
Your question is:
Assembly program compiling and linking with TASM but not with MASM :O(
And I think I have answered your question! ^_^

Which platform are you using? Win9x or W2K?
I think you a driver, actually, if you familiar with DOS, it's simple for you to migrate the existing DOS apllication to a windows driver, the driver run under ring0, so can do anything just like under DOS.

If you only want to read a port, there will be a lot of methods you can select, you even needn't write a driver, what you should to do is convert to ring0, and then read the port.

It depend on what you really want to do.
0
 
LoShuCommented:
Hi san_hbs,

Because I do not see all of your code I cannot answer your question in details, but the error message you stated says that you have to assume somewhere the usage of the segment registers (see the comment from Dimitry):

ASSUME DS:..., ES:..., SS:..., CS:...

With best regards.
0
 
SpideyModCommented:
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.