Re: interrupt service routine using VC++ 2005

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



As I mentioned, I will not run the generated code under Windows
afterwards, I'm abusing the compiler more or less to generate code
which can be executed in a protected mode environment, where I have the
complete control over the system, I'm the OS let's say.
My question points just in that way how do I have to write the C++ code
with VC++ to generate the functions I need, in this case a function
which works as a ISR, with the mentioned saving of registers and ending
the function with IRETD.
I know that VC++ is intended to write programs running under Windows
(Ring3), the OS (Windows in this case) takes care of the ISRs so there
will actually be no need for a user to think about writing an own ISR.
But since my code will not talk to any Win32 kernel or so, I'm really
about to program it low-level, also running on ring0 afterwards, in my
own environment.

So, will it be possible to force the VC++ compiler to code a function
as a ISR with all the requirement of an ISR?

Daniel

Scott McPhillips [MVP] schrieb:

mysli@xxxxxx wrote:
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


VC++ is not the appropriate tool. If you did try this and it traps the
interrupt you are working with some dreadfully ancient operating system.
Modern Windows will not permit your program to access the int vectors.

The required tools and documentation are available (for 32 bit Windows)
as the DDK (device driver kit).

--
Scott McPhillips [VC++ MVP]

.



Relevant Pages

  • Re: Assembling Visual Studio generated listing files
    ... card issues an interrupt each time it has a new position for any one ... An ISR is constrained to act in < 10us, and for most modern machines, 12.5us is a very ... Without MASM and in pure C or C++ and without any Windows API/MFC, ... This is a device driver. ...
    (microsoft.public.vc.mfc)
  • Re: interrupt service routine using VC++ 2005
    ... I need to write a ISR using Microsoft VC++ 2005. ... ISR and it will be called by the hardware interrupt, ... is the compiler ends every function with RETN, ... Modern Windows will not permit your program to access the int vectors. ...
    (microsoft.public.vc.language)
  • Re: more on timing problems
    ... Are you handling ALL interrupts in your ISR? ... make sure you do not have a pending interrupt before leaving your ISR. ... Windows is not a realtime OS. ... > At least get rid of PIO and use busmaster DMA instead. ...
    (microsoft.public.development.device.drivers)
  • Re: PIC mplab c18 C compiler
    ... Apparently the compiler manual says you ... >work out what registers to save/restore in interrupt routines... ... RAM location is used for several automatic variables, ... Therefore automatic variables used in an ISR cannot share any RAM ...
    (comp.arch.embedded)
  • interrupt service routine using VC++ 2005
    ... I need to write a ISR using Microsoft VC++ 2005. ... I can register any function as a ... ISR and it will be called by the hardware interrupt, ... is the compiler ends every function with RETN, ...
    (microsoft.public.vc.language)