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.
Richard_ThompsonAsked:
Who is Participating?
 
nietodCommented:
Are you doing this from a DOS program?  This will not work from a 32 bit console program.  This will only work from a 16 bit DOS program.  There are other ways to get this information from a 32 bit console program
0
 
alexoCommented:
>> 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"


0
 
nietodCommented:
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?  
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

 
alexoCommented:
>> 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?
0
 
nietodCommented:
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?
0
 
alexoCommented:
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.
0
 
alexoCommented:
Oh well, you win some, you lose some...
0
 
nietodCommented:
>> you win some you lose some
what is that referring to?
0
 
alexoCommented:
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".
0
 
nietodCommented:
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.
0
 
alexoCommented:
>> 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?

0
 
nietodCommented:
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.
0
 
alexoCommented:
This is getting ridiculous.  Let's drop the subject, OK?
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.