Link to home
Start Free TrialLog in
Avatar of Richard_Thompson
Richard_Thompson

asked on

Fatal exception when calling interrupts using inline assembler.

I am trying to call int 13h functions using the inline assembler with MS Visual C++ 4.  However, when I run a progam which calls the interrupt, it crashes, showing that infamous blue screen with a FATAL EXCEPTION 0D error message.

Take the following example.  I am calling the "GET STATUS OF LAST OPERATION" function.  My documentation states that AH should be loaded with 01h and DL with the drive number (01h for drive A).  So here goes...

void main()
{
      _asm
      {
            mov ah, 01h
            mov dl, 01h
            int 13h
      }
}

But when the code fragment is run, all I get is a fatal exception 0D.  What should I be doing to make it work and get rid of the fatal exception?  I've tried this technique out with several different interrupt calls, but still get the same problem.
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

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
>> I am trying to call int 13h functions using the inline assembler with MS Visual C++ 4.
MSVC4 can only generate Win32 code.  Under the Win32 protection model, a client program is not allowed to call OS software interrupts directly.

In order to use INT 13h from your code you will have to delegate the task either to a VxD (VWIN32.VXD will do some of the work under Win95) or to a 16-bit DLL.  I think both options will fail under NT but then you can obtain a handle to the drive and call DeviceIoControl() to perform the functions you need.

Drop me a note if you need more help.
Meanwhile, search your online help for KB articles Q125712 and Q137176 or just do a global help search for "VWIN32"


Avatar of nietod
nietod

Alex, I believe that VC4 can produced DOS programs.  (5 definitly can't.)  That is why I wasn't 100% sure that was the problem.  

>> Drop me a note if you need more help.
What's wrong with this question?  
>> Alex, I believe that VC4 can produce DOS programs.
Nope, it definitely cannot.  In order to compile DOS or Win16 apps one needs 1.52 or earlier.

>> What's wrong with this question?
Huh?
1.52.  Wow that long ago.  I didn't realize.

The "drop me a note" sounds like an invitation for e-mail.  Maybe not?  If so,  I was wondering why?
Richard, we're waiting for your input, comments, anything...

Todd,
>> The "drop me a note" sounds like an invitation for e-mail.

A note here, a note by email, it really does not matter since I take care to summarize here any solution that was negotiated via email while avoiding unnecessary clutter ("it doesn't work"; "here's a minor bugfix"; "it still doesn't work"; "here's another"; "thanx") and keeping the discussion free for alternative suggestions by others.

As your experience with John500 showed, this forum is highly suitable for exchanging abstract ideas and small code snippets, not for sharing longer sources.
Oh well, you win some, you lose some...
>> you win some you lose some
what is that referring to?
It was referring to the fact that R.T. solveed the problem using the KB articles mentioned in my comment followed by a brief exchange on the marvellous invention referred to above as "email" to solve a minor bug.

I usually add this comment when I think that my answer was superior (in content or details) to the accepted one.  It means roughly "at least I tried".
That does seem a bit unfair then.  

But then again, I answered the question and was not made part of the resolution discussion, so It would not be fair for you to get the points either.  

I know what to do, we give the points to RONSLOW.
>> That does seem a bit unfair then.
Why?  Because a minor implementation bug was solved via email?
How would you classify your correspondence with John500 then?

>> I answered the question
I consider your answers most helpful and complete.  However, in this particular case, it was lacking.  Compare your answer to my comment from "June 23 1998 - 12:08AM PDT" then tell me I'm wrong.

>>  and was not made part of the resolution discussion
The email I got from RT said something like "Thank you for pointing me to the references.  But my code doesn't work." along with source.  The reply was "Use 0x100 instead of 0x1000".  Not much of a discussion, is it?

Unfair that you didn't get the points since you solved it.  But I was also pointing out that I wasn't really given a chance to.   In the case of the john500 stuff, I solved it via e-mail (hundreds of them), but also answered it.
This is getting ridiculous.  Let's drop the subject, OK?