Solved

Assembly program compiling and linking with TASM but not with MASM

Posted on 2002-07-15
12
2,245 Views
Last Modified: 2008-02-26
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".
0
Comment
Question by:san_hbs
12 Comments
 
LVL 7

Expert Comment

by:jimwasson
ID: 7155826
MASM as of version 6.1 has a /COFF command line option that will tell it to output COFF files.
0
 
LVL 9

Expert Comment

by:BeyondWu
ID: 7156154
Try to use following command.
masm yourasm.asm
link yourasm (note: use the link under the binr folder in MASM)

Good Luck.
0
 

Author Comment

by:san_hbs
ID: 7158754
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 

Expert Comment

by:ckhitler
ID: 7158952
up
0
 
LVL 11

Expert Comment

by:dimitry
ID: 7160487
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
 

Author Comment

by:san_hbs
ID: 7161314
Hi,
 _vectloc and _oldvect are defined as follows in data segment:
=====
.data
_vectloc     DD     000001ccH
_oldvect     DD      0f000ff23H
=====
0
 

Author Comment

by:san_hbs
ID: 7161426
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
 
LVL 9

Accepted Solution

by:
BeyondWu earned 50 total points
ID: 7163655
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
 

Author Comment

by:san_hbs
ID: 7171828
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
 
LVL 9

Expert Comment

by:BeyondWu
ID: 7173106
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
 

Expert Comment

by:LoShu
ID: 7323975
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
 

Expert Comment

by:SpideyMod
ID: 8292988
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question