Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

help, about hardware interrupt in VIRTUAL 8086 mode

CRxyzCRxyz Member Posts: 4
Hi,

I have a serial communication program which was developed under DOS. This program installs a new 0x0C hardware interrupt handler to read from serial port COM1. Under DOS and Windows NT/XP/2000, it works very well. But when I run it under the DOS-box in Windows 98/Me, it cannot get anything from COM port. I traced the program and found that the new interrupt handler was invoked once and then will never be activated. I know it is due to the V86 mode. Could some one tell me how to code a new hardware interrupt handler for a DOS programme running in V86 mode.

BTW, I tried to install other software interrupt handler, such as 0x1C, it works OK in all the Windows OS.

Here is a simple example with BC 3.1. Actually, my interrupt handler is written with Assembler.

Could somebody give me a solution about it? Thanks


===============================================

#include
#include
#include

#define INTR 0X0C /* The COM1 interrupt */

#ifdef __cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif

void interrupt ( *oldhandler)(__CPPARGS);
void interrupt ( *oldhandler1)(__CPPARGS);

int count=0;

void interrupt handler(__CPPARGS)
{
/* increase the global counter */
count++;

/* call the old routine */
oldhandler();
}

int main(void)
{
/* save the old interrupt vector */
oldhandler = getvect(INTR);

/* install the new interrupt handler */
setvect(INTR, handler);
oldhandler1 = getvect(INTR);
/* loop until the counter exceeds 20 */
while (count < 20 && !kbhit ())
printf("count is %d
",count);

/* reset the old interrupt handler */
setvect(INTR, oldhandler);

return 0;
}

Comments

  • ShoSho Member Posts: 22
    : Hi,
    :
    : I have a serial communication program which was developed under DOS. This program installs a new 0x0C hardware interrupt handler to read from serial port COM1. Under DOS and Windows NT/XP/2000, it works very well. But when I run it under the DOS-box in Windows 98/Me, it cannot get anything from COM port. I traced the program and found that the new interrupt handler was invoked once and then will never be activated. I know it is due to the V86 mode. Could some one tell me how to code a new hardware interrupt handler for a DOS programme running in V86 mode.
    :
    : BTW, I tried to install other software interrupt handler, such as 0x1C, it works OK in all the Windows OS.
    :
    : Here is a simple example with BC 3.1. Actually, my interrupt handler is written with Assembler.
    :
    : Could somebody give me a solution about it? Thanks

    Virtual-86 mode probably isnt the problem since your handler did get triggered once. The problem lies somewhere in your code. You're probably inhibiting your own interrupt routine from being called again. You must notify the PIC that your interrupt procedure is done or at a point where it handles reentry. You must send the PIC a general EOI (End-of-Interrupt [20h] ) to enable your interrupt routine to be called again.
    [code]
    (intel-sentax asm)
    MOV Al, 20h ;EOI command
    OUT 20h, Al ;Send to PIC
    (C)
    outp (0x20, 0x20);
    [/code]


    Also note that 1Ch is not a hardware interrupt, 8h (IRQ0) is the hardware interrupt, 1Ch is called from there after EOI is sent.
    "Making an OS is about breaking the ridiculous rules of the current OSes so you can make your own ridiculous rules which will soon be broken." Sho


  • CRxyzCRxyz Member Posts: 4
    Thanks a lot. I modified the code according to your suggestion. But unfortunately, It still only works onces after the system is started. Even I run the program again in another Windows DOS box, it will not be activated.

    : [code]
    : (intel-sentax asm)
    : MOV Al, 20h ;EOI command
    : OUT 20h, Al ;Send to PIC
    : (C)
    : outp (0x20, 0x20);
    : [/code]
    :
    :

  • blipblip Member Posts: 756
    Try reading the IIR (Base+2) and LSR (Base+5), that will almost certainly work.
  • CRxyzCRxyz Member Posts: 4
    Can somebody help me with this question?
  • CRxyzCRxyz Member Posts: 4
    : Can somebody help me with this question?
    :
    Please somebody help me.
  • ShoSho Member Posts: 22
    Find an existing interrupt routine and modify it.

    "Making an OS is about breaking the ridiculous rules of the current OSes so you can make your own ridiculous rules which will soon be broken." Sho


  • Chris BrownChris Brown USAMember Posts: 4,496 ✭✭

    [ http://forcoder.org ] free video tutorials and ebooks about \ Objective-C, PL/SQL, C#, Ruby, R, Go, PHP, Visual Basic, Python, C, Delphi, MATLAB, Perl, Java, Visual Basic .NET, JavaScript, Scratch, Swift, Assembly, C++ SAS, Logo, Julia, Prolog, Crystal, Scheme, Lua, ABAP, Erlang, Kotlin, Rust, Fortran, Apex, Alice, LabVIEW, Transact-SQL, D, Lisp, Ada, Bash, F#, FoxPro, Clojure, COBOL, Scala, Awk, VBScript, ML, Dart, Hack \ _________

Sign In or Register to comment.