Thread: run c app in asm

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

    run c app in asm

    How would I execute a C/C++ written program from an asm program with pure DOS?

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    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 04: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,210
    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
    2,158
    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 06:40 PM.

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

  7. #7
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    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,195
    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 11:57 AM.

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, 03: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