interrupt service routine using VC++ 2005

Discussion in 'C++' started by mysli@gmx.de, Aug 14, 2006.

  1. Guest

    Hi all,

    I need to write a ISR using Microsoft VC++ 2005. The proplem is I did
    not found any hint on how to do it. I can register any function as a
    ISR and it will be called by the hardware interrupt, interrupt 8
    (timer) i.e., works fine in my little example progam. But the problem
    is the compiler ends every function with RETN, after disassembling the
    result of the compilation this can be seen easiely.
    Every function starts and ends with:

    push ebp //function entry
    mov ebp,esp
    ....
    pop ebp
    retn //function exit

    That's pretty fine for regular functions but as an interrupt handler
    the function first of all should save all used registers, EAX is not
    save by VC++ since its holding the return value, but ISR doesn't have
    any return value. And second it needs to end with a IRETD !!!

    Does anyone of you know how to solve this problem, maybe it points out
    the VC++ is not the appropiated tool for my project. BTW, I do use VC++
    only as editor and compiler, I do not program for windows, I just
    generate code which can be executed in protected mode.

    Many thanks,
    Daniel
    , Aug 14, 2006
    #1
    1. Advertising

  2. mlimber Guest

    mlimber, Aug 14, 2006
    #2
    1. Advertising

  3. Phlip Guest

    mysli wrote:

    > push ebp //function entry
    > mov ebp,esp


    That ... doesn't look like C++.

    You will get the best results on a forum that discusses programming the
    Win32 kernel. This newsgroup is only qualified to take a stab at C++. If
    someone took a stab at your question, there aren't enough other regulars
    here who could review their answer.

    --
    Phlip
    http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
    Phlip, Aug 14, 2006
    #3
  4. Guest

    As I mentioned in my last sentence, I'm not programming for Windows
    therefore anything regarding WinAPI / Win32 Kernel won't help my
    either. But I agree my question is maybe to specific to the Microsoft
    Compiler although I'm not using it to compile windows programs but own
    developped protected mode programs.

    But thanks for letting my know that I'm wrong here.
    Daniel

    Phlip schrieb:

    > mysli wrote:
    >
    > > push ebp //function entry
    > > mov ebp,esp

    >
    > That ... doesn't look like C++.
    >
    > You will get the best results on a forum that discusses programming the
    > Win32 kernel. This newsgroup is only qualified to take a stab at C++. If
    > someone took a stab at your question, there aren't enough other regulars
    > here who could review their answer.
    >
    > --
    > Phlip
    > http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
    , Aug 14, 2006
    #4
  5. Phlip Guest

    mysli wrote:

    > As I mentioned in my last sentence, I'm not programming for Windows
    > therefore anything regarding WinAPI / Win32 Kernel won't help my
    > either.


    "I do not program for windows, I just generate code which can be executed in
    protected mode."

    Microsoft named their OS after their windows, and "protected mode" implies
    .... kernelly things. So your last sentence was insufficient to distinguish
    the exact group you should target!

    Further, wedging interrupt service routines went out of style with MS-DOS,
    so you really ought to find a more modern way to do what you need.

    One worse way would be to get a compiler that can target 16-bit programs
    that run in the "DOS Box" emulation environment. Two that come to mind are
    http://www.delorie.com/djgpp/ and its 16-bit tools, and MS's old free
    version of Visual C++ 1.5 or similar. Then you can wedge all the interrupts
    you like, and the emulator will let you think the CPU actually gives a s--t
    what you are interrupting. ;-)

    --
    Phlip
    http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
    Phlip, Aug 15, 2006
    #5
  6. Guest

    Thanks anyway, I got the solution already.

    Phlip schrieb:

    > mysli wrote:
    >
    > > As I mentioned in my last sentence, I'm not programming for Windows
    > > therefore anything regarding WinAPI / Win32 Kernel won't help my
    > > either.

    >
    > "I do not program for windows, I just generate code which can be executed in
    > protected mode."
    >
    > Microsoft named their OS after their windows, and "protected mode" implies
    > ... kernelly things. So your last sentence was insufficient to distinguish
    > the exact group you should target!
    >
    > Further, wedging interrupt service routines went out of style with MS-DOS,
    > so you really ought to find a more modern way to do what you need.
    >
    > One worse way would be to get a compiler that can target 16-bit programs
    > that run in the "DOS Box" emulation environment. Two that come to mind are
    > http://www.delorie.com/djgpp/ and its 16-bit tools, and MS's old free
    > version of Visual C++ 1.5 or similar. Then you can wedge all the interrupts
    > you like, and the emulator will let you think the CPU actually gives a s--t
    > what you are interrupting. ;-)
    >
    > --
    > Phlip
    > http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
    , Aug 15, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pavan Zope

    problem with using Fortran routine in C.

    Pavan Zope, Feb 2, 2004, in forum: C Programming
    Replies:
    2
    Views:
    344
    Dik T. Winter
    Feb 3, 2004
  2. Edvard Majakari

    Using debug print routine inside assert

    Edvard Majakari, Nov 4, 2003, in forum: Python
    Replies:
    13
    Views:
    590
    Alex Martelli
    Nov 5, 2003
  3. Eirik Midttun

    ISR (interrupt service routine) code in isr.c

    Eirik Midttun, Feb 7, 2007, in forum: C Programming
    Replies:
    2
    Views:
    632
    Jack Klein
    Feb 8, 2007
  4. Replies:
    1
    Views:
    767
    Mike Wahler
    Mar 27, 2007
  5. dutche
    Replies:
    13
    Views:
    518
    Kenny McCormack
    May 4, 2010
Loading...

Share This Page