Solved

Assembly program compiling and linking with TASM but not with MASM

Posted on 2002-07-15
12
2,218 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Moving applications to the cloud or switching services to cloud-based ones, is a stressful job.  Here's how you can make it easier.
In this article, I show you step by step with screenshots to assist you - HOW TO: Deploy and Install the VMware vCenter Server Appliance 6.5 (VCSA 6.5), with some helpful tips along the way.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now