Thread: Help with inline asm

  1. #1
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685

    Help with inline asm

    This code isn't supposed to do anything other than change to mode 13h then return control to dos. I'm using dev-c++ and am just trying to understand its inline asm syntax. Does anyone know what is wrong here?

    int main(void){

    __asm volatile("mov $0x00, %ah");
    __asm volatile("mov $0x13, %al");
    __asm volatile("int $0x10");

    __asm volatile("mov $0x4c, %ah");
    __asm volatile("mov $0x00, %al");
    __asm volatile("int $0x21");
    return 0;
    }

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    I don't think you can call those interrupts from within a normal win32 app.

  3. #3
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Arrrgh! So far that has been what i've been noticing. The asm calls work fine except for interrupts. Oh well, it would have been an easy way but no, that would make a win32 program easy to program

  4. #4
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    That is a weird way to go into 13h mode. Just do this:

    void InitGraph (void)
    {
    asm {
    mov ax,13h
    int 10h
    }
    }

    void CloseGraph (void)
    {
    asm {
    mov ax,03h
    int 10h
    }
    }

    Those functions will open and close 13h mode.
    My Website

    "Circular logic is good because it is."

  5. #5
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    It doesn't matter which style you use(probably compiler based), if your o/s doesn't let you call the interupts, it's not going to work.

  6. #6
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Thanks Davidp but zen is right. Windows has some stupid protective measures. Which, by the way, wouldn't be a bad thing if they couldn't by bypassed by any twelve-year old with a little programming skills.

    Also, if someone is reading this because they have the same question then DON'T compile any code presented here. It will only kill windows and may force you to restart.

    There are other solutions that aren't as convenient as using inline interrupts so I'll take another route. Thanks for the help zen and davidp.

  7. #7
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    There are some compilers out there that will allow you to compile for DOS, hence interrupt support, but code it within the Windows environment. MSVC will not allow this, but some of Borland's compilers will allow you to compile for DOS standard and DOS overlay. If you do get a copy of BC 4.52 or earlier for Windows, they have DOS support. When you compile and run the code, it is given it's own DOS window or you can make it run full-screen with the standard ALT-ENTER. It will allow you to create mode 13h programs, and it will allow you to both use and install interrupt handlers as well as use a very nice inline assembler.

    In actuality you are coding from the Windows environment using the IDE, but your code is running in a DOS window. To ensure that the code works properly sometimes it is necessary to reboot to DOS because Windows changes the interrupt vectors so much.

    Also, if you get a copy of these, make sure that you are using the alternate startup module. If you do not do this, your program will not execute and will just show a blinking cursor in the upper left corner of your screen.

  8. #8
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    That's good news. I'll look for an old copy of borland out there. Thanks for the useful info.

  9. #9
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    Please do not bump old threads (NUMBER 5). A general rule of thumb is that if you don't have a serious question about something in a thread that is over 2 weeks old, don't post. If you do have a serious question and it's older than 3-4 weeks, post a new thread and link to the old one.
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  2. Certain functions
    By Lurker in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2003, 01:26 AM
  3. Inline asm
    By wavering in forum C Programming
    Replies: 2
    Last Post: 01-29-2002, 02:42 AM
  4. Inline asm - I love it!
    By wavering in forum C Programming
    Replies: 2
    Last Post: 01-08-2002, 02:19 PM
  5. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 06:05 PM