run c app in asm

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?...

  1. #1
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,605

    run c app in asm

    How would I execute a C/C++ written program from an asm program with pure DOS?
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    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

  3. #3
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Quote Originally Posted by CornedBee View Post
    Meh. Even from assembly, I think I'd link against a CRT and use exec().
    Using C library functions is definitely the way to go in assembly if it's an option.

    I would argue that DOS should be dead now, though.

  4. #4
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,605
    Okay, I was already sort of on that track. Here is the asm I have so far
    Code:
    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
    It took me a while to get together. cprogram.exe was compiled with DJGPP; here's it's code
    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;
    }
    But the asm program displays this:
    Code:
    ♀☻
    ☻█☻─      ♀☻&#239;♣♀☻♫♀♀☻&#182;♀♀☻▼♀♀☻&#161;♠♀☻&#161;♠♀☻&#241;≡ ≡7♣♀☻N+ └r►&#186; |►&#186; ▐☺&#182;♦K☺&#182;♦V☺&#182;♦&#229;►&#186; &#201;►&#186; &#220;►&#186;
    ╕►&#186; T☻p ≥♦&#239;╙╕►&#186; ╕►&#186; ╕►&#186; @☺&#182;♦P  ╖♀Ω&#171;►&#186;
     ≡╕►&#186; ─#☻╨╕►&#186; ╕►&#186; ╕►&#186; ╕►&#186; ╕►&#186; ╕►&#186; ╕►&#186; ╕►&#186; ╕►&#186; ╕►&#186; ╕►&#186; ╕►&#186; &#232;♦♀☻&#160;♥♀☻v   ♀☻a/ └╢
     ≡╢
     ≡╢
     ≡╢
     ≡╢
    As you can see I have a major glitch error.

    Help me out a little here?
    Last edited by Yarin; 12-22-2007 at 05:40 PM.
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    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

  6. #6
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,605
    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)
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

  7. #7
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    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

  8. #8
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by MacGyver View Post
    I would argue that DOS should be dead now, though.

    mmm, not quite yet Im afraid, its still used in some industrial machines. Stability , runs on the 80188 uC/uP, entire OS+Environment fits in the L2 cache on newer processors. Just some of its few benefits.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stop GUI Application returning when run
    By DaveHope in forum Windows Programming
    Replies: 7
    Last Post: 06-29-2009, 08:57 PM
  2. Is this correct? Daemonizing an app
    By boreder in forum C Programming
    Replies: 2
    Last Post: 11-14-2008, 02:12 AM
  3. c++ consle app HELP
    By programer345 in forum C++ Programming
    Replies: 15
    Last Post: 06-29-2008, 04:38 AM
  4. Stand alone app and .dll's
    By earth_angel in forum Windows Programming
    Replies: 4
    Last Post: 08-08-2005, 01:05 PM
  5. Compiled App as release - won't run - as debug runs
    By XenoCodex Admin in forum C++ Programming
    Replies: 7
    Last Post: 08-05-2002, 04:43 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21