How would I execute a C/C++ written program from an asm program with pure DOS?
This is a discussion on run c app in asm within the Tech Board forums, part of the Community Boards category; How would I execute a C/C++ written program from an asm program with pure DOS?...
How would I execute a C/C++ written program from an asm program with pure DOS?
I don't see why people think Chuck Norris is so awesome. If he was really as great as they say, he would be over here slamming my head into the keybsk;lah;flksalfksdnlcslcnsldk;acklsd;glfbaskfl
/* When I wrote this, only God and I understood what I was doing... Now, God only knows */
DOS???
Also, this is an assembly or DOS API question, not C++. Moved.
Meh. Even from assembly, I think I'd link against a CRT and use exec(). But Interrupt 21 function 5b looks promising.
Last edited by CornedBee; 12-22-2007 at 03:25 PM.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Okay, I was already sort of on that track. Here is the asm I have so far
It took me a while to get together. cprogram.exe was compiled with DJGPP; here's it's codeCode:jmp start Filename db 'CPROGRAM.EXE', 0 getkey: mov ah, 0 int 016h ret start: mov ah, 40h mov al, 0 mov dx, Filename mov ds, dx mov bx, 0 mov es, bx int 21h call getkey ret
But the asm program displays this:Code:#include <stdio.h> int main(void) { printf("Starting...\n\n"); printf("Good news; This is a real live running C program.\n"); printf("\nEnding...\n"); return 0; }
As you can see I have a major glitch error.Code:♀☻ ☻█☻─ ♀☻ï♣♀☻♫♀♀☻¶♀♀☻▼♀♀☻¡♠♀☻¡♠♀☻ñ≡ ≡7♣♀☻N+ └r►º |►º ▐☺¶♦K☺¶♦V☺¶♦å►º É►º Ü►º ╕►º T☻p ≥♦ï╙╕►º ╕►º ╕►º @☺¶♦P ╖♀Ω«►º ≡╕►º ─#☻╨╕►º ╕►º ╕►º ╕►º ╕►º ╕►º ╕►º ╕►º ╕►º ╕►º ╕►º ╕►º è♦♀☻ ♥♀☻v ♀☻a/ └╢ ≡╢ ≡╢ ≡╢ ≡╢
Help me out a little here?
Last edited by Yarin; 12-22-2007 at 05:40 PM.
I don't see why people think Chuck Norris is so awesome. If he was really as great as they say, he would be over here slamming my head into the keybsk;lah;flksalfksdnlcslcnsldk;acklsd;glfbaskfl
/* When I wrote this, only God and I understood what I was doing... Now, God only knows */
My reference tells me that 40h is WriteFile.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
But I am interrupting 21h am I not?
Do you know where I could get a copy of this reference? (Assuming you have a list of interrupts)
I don't see why people think Chuck Norris is so awesome. If he was really as great as they say, he would be over here slamming my head into the keybsk;lah;flksalfksdnlcslcnsldk;acklsd;glfbaskfl
/* When I wrote this, only God and I understood what I was doing... Now, God only knows */
The problem is that the reference is in German.
But perhaps Ralf Brown's list would be a good reference. http://www.ctyme.com/rbrown.htm
Look for int 21h, and there you can look up the function you want. 40h, as I said, is Write File.
This page looks interesting, too: http://www.ctyme.com/intr/cat-010.htm
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Last edited by abachler; 12-24-2007 at 10:57 AM.
Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.