| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Assembly Questions and Answers for Assembly here! |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
I'm trying to use a dos file function (ah=3Dh) to open a file using c++. but it keeps crashing.
Code:
#include <iostream.h>
void main()
{
char file[]= "text.txt";
__asm
{
mov ah,3Dh
mov al,0
lea dx,file
int 21h
}
}
i think i have all the info where it belongs, ah has 3Dh the command to open, al has 0 to use the file for input, and i load effective address of the file name to the dx register...i wrote it in assembly also and it works fine but i doesnt work here. would appreciate any help. Last edited by sublyme; November 17th, 2004 at 12:49 PM. |
|
#2
|
||||
|
||||
|
Re: C++ && _asm
turns out there's 'nothing wrong' with this code.
I forgot to set a compiler option.
Last edited by sublyme; November 22nd, 2004 at 02:34 PM. |
|
#3
|
||||
|
||||
|
Re: C++ && _asm
With which compiler did you use to compile the C code?
It depends on where you are running this. If you run this in an instance of the command line interpreter (cmd.exe) all 16Bit interrupts are blocked, since cmd.exe is a 32 Bit subsystem. You need to compile this with a DOS compiler, that generates DOS programms (Turbo C Compiler for example). In that case your programm will be executed in the 16 Bit subsystem, where all DOS/BIOS interrupts are enabled.
__________________
I am not offering technical guidiance via email or IM Come on share your photo with us! CG members photo album! Use the Code Tags! |
|
#4
|
|||
|
|||
|
Re: C++ && _asm
I'm no expert on what windows does with DOS applications, but I do know it's common for protected mode applications (including Windows kernel) to make callbacks for 16-bit interrupts. It's very inefficient because of the mode switching, but it's there for compatibility. Otherwise, how else could you run 16-bit apps within Windows 95 and up?
|
|
#5
|
||||
|
||||
|
Re: C++ && _asm
The problem with the code above is, in my oppinion, that it uses an obsolete technique. The features Windows offeres for 16 bit code are there to allow older applications to run, not to allow new 16 bit applications to be developed.
The OP probably ha ssome book or tutorial he's using. My advice is to seek modern replacement soon.
__________________
Gabriel, CodeGuru moderator Forever trusting who we are And nothing else matters - Metallica Learn about the advantages of std::vector. |
|
#6
|
||||
|
||||
|
Re: C++ && _asm
Quote:
__________________
I am not offering technical guidiance via email or IM Come on share your photo with us! CG members photo album! Use the Code Tags! |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|