Thread: do not detect error

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    3

    do not detect error

    i have following piece of code

    Code:
    void interrupt (*oldTimer)(void);
    void interrupt (*oldKey)(void);
    void interrupt newTimer ( );
    void interrupt newKey ( );
    void clearScreen(void);
    void printInfo(int);
    
    char far *scr = (char far* ) 0xB8000000; 
    char far *kbd = (char far* ) 0x00400017; 
    
    int i, t = 0, m = 0;
    
    char charscr [4000];
    
    
    void main( )
    {
    
    oldTimer = getvect(8); 
    oldKey = getvect (9); 
    
    setvect (8,newTimer); 
    setvect (9,newKey);

    but when i compile this code it gives error that

    cannot convert void interrupt far*(...) to void interrupt far*

    this error points to the line

    oldTimer = getvect(8);

    i cannot understand why this error comes can any 1 help me??

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    What is 'getvect'? I don't see it any place in your code.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Apr 2010
    Posts
    3
    here is the complete code


    Code:
    #include <dos.h>
    #include <conio.h>
    
    void interrupt (*oldTimer)(void);
    void interrupt (*oldKey)(void);
    void interrupt newTimer ( );
    void interrupt newKey ( );
    void clearScreen(void);
    void printInfo(int);
    
    char far *scr = (char far* ) 0xB8000000; //Address of video memory.
    char far *kbd = (char far* ) 0x00400017; //Keyboard status byte.
    
    int i, t = 0, m = 0;
    
    char charscr [4000];
    
    
    void main( )
    {
    
    oldTimer = getvect(8); //Save the old timer routine in oldTimer (interrupt function pointer)
    oldKey = getvect (9); //Save the old keyboard routine in oldKey (interrupt function pointer)
    
    setvect (8,newTimer); //Replace the functionality of orginal routine with new one.
    setvect (9,newKey);
    
    keep(0,1000); //Making this program TSR
    
    getch();
    getch();
    
    }
    
    //This function will be invoked after every 1/18.2 th of second.
    void interrupt newTimer ( )
    {
    t++;
    if((t >= 91) && (m == 0))
    {
    for (i =0; i < 4000; i ++)
    {
    charscr [i] = *(scr + i); //Save the original screen into charscr[] array
    }
    m=1;
    }
    
    if (t >= 91 && m == 1) //Check if 5 seconds have passed.
    {
    clearScreen();
    printInfo(1990);
    }
    
    
    (*oldTimer) ( );
    }
    
    
    void clearScreen()
    {
    int i;
    
    // Write the spaces with withe back color in whole screen
    
    for (i =0; i <=4000; i +=2)
    {
    
    *(scr + i) = 0x20; //ASCII code of space key
    *(scr + i + 1) = 0x70; //Means white fore colr and black back color
    
    }
    
    }
    
    
    
    void printInfo(int i)
    {
    
    *(scr + i) = 0x41;
    *(scr + i + 1) = 0x70;
    i+=2;
    
    *(scr + i) = 0x42;
    *(scr + i + 1) = 0x70;
    i+=2;
    
    *(scr + i) = 0x43;
    *(scr + i + 1) = 0x70;
    i+=2;
    
    *(scr + i) = 0x28;
    *(scr + i + 1) = 0x70;
    i+=2;
    
    *(scr + i) = 0x42; // ASCII code of 'B'
    *(scr + i + 1) = 0x70; // Means Black fore colr and White back color
    i+=2;
    
    
    *(scr + i) = 0x43; // ASCII code of 'C'
    *(scr + i + 1) = 0x70;
    i+=2;
    
    
    *(scr + i) = 0x30; // ASCII code of '0'
    *(scr + i + 1) = 0x70;
    i+=2;
    
    
    *(scr + i) = 0x30;
    *(scr + i + 1) = 0x70;
    i+=2;
    
    
    *(scr + i) = 0x30;
    *(scr + i + 1) = 0x70;
    i+=2;
    
    
    *(scr + i) = 0x30;
    *(scr + i + 1) = 0x70;
    i+=2;
    
    *(scr + i) = 0x30;
    *(scr + i + 1) = 0x70;
    i+=2;
    
    
    *(scr + i) = 0x30;
    *(scr + i + 1) = 0x70;
    i+=2;
    
    
    *(scr + i) = 0x30;
    *(scr + i + 1) = 0x70;
    i+=2;
    
    
    *(scr + i) = 0x30;
    *(scr + i + 1) = 0x70;
    i+=2;
    
    *(scr + i) = 0x30;
    *(scr + i + 1) = 0x70;
    
    
    }
    
    void interrupt newKey ( )
    {
    int w;
    
    if (inportb(0x60)==0x10 && m==1 && ( ((*kbd)&12)==12 ))
    {
    
    for (w =0; w < 4000; w ++)
    {
    //Restoring the original screen
    *(scr + w) = charscr [w]; // Whenever Alt+Ctrl+Q is pressed original screen will be restored
    
    }
    m = 0;
    t = 0;
    }
    (*oldKey) ( );
    
    }

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    What operating system are you trying to run this program on?

    What compiler are you using?

    Windows 2000 and later, on cpu's later than 80286 don't have far pointers, IIRC.

    The offset denoted by the "far" designation, does point to memory, but it may not be memory that your program has been given.

    Here's the scoop on getvect():


    Code:
    getvect:   Gets interrupt vector.
    
    
     Syntax:
       void interrupt (*getvect(int interrupno))();
    
     Prototype in:
     dos.h
    
     Remarks:
    Every processor of the 8086 family includes a set of interrupt
    vectors, numbered 0 to 255.
    
    The 4-byte value in each vector is actually an address, which is the
    location of an interrupt function.
    
    getvect reads the value of the interrupt vector given by interruptno
    and returns that value as a (far) pointer to an interrupt function.
    The value of interruptno can be from 0 to 255.
    
     Return Value:
    Returns the 4-byte value stored in the interrupt vector named by
    interrupno.
    
     Portability:
    getvect is unique to DOS.
    
     See Also:
      disable    enable    geninterrupt   setvect
    
     Example:
     #include <stdio.h>
     #include <dos.h>
    
     void interrupt get_out(); /* interrupt prototype */
    
     void interrupt (*oldfunc)(); /* interrupt function pointer */
     int looping = 1;
    
     int main(void)
     {
       puts("Press <Shift><Prt Sc> to terminate");
    
       /* save the old interrupt */
       oldfunc  = getvect(5);
    
        /* install interrupt handler */
       setvect(5,get_out);
    
        /* do nothing */
       while (looping);
    
        /* restore to original interrupt routine */
        setvect(5,oldfunc);
    
       puts("Success");
       return 0;
     }
     void interrupt get_out()
     {
       looping = 0; /* change global variable to get out of loop */
     }
    Last edited by Adak; 04-23-2010 at 05:21 AM.

  5. #5
    Registered User
    Join Date
    Apr 2010
    Posts
    3
    i m using win xp and compiler is borland C

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I use that same combination myself, for a lot of console programming.

    Since the 80386 cpu and Windows 2000 (IIRC), Windows doesn't support far * memory addresses. The memory IS there, but it's not segmented into offset pages like it used to be for the 8086 cpu type architecture. The memory you request may not even be in the memory range that the program was given by Windows, to run in.

    I believe you can access the keyboard buffer at the address, but the screen memory may be quite different - depending on what your current system supports.

    Terminate and stay resident programs are not possible to run in WindowsXP, IMO.

    I can run low graphics screens, and access the keyboard buffer. But use getvect()? I believe that will immediately crash the program, and maybe your system, as well.

    If you want to run a program that touches upon the hardware at a low level, you pretty much have to use the Windows API, for most of it.

    It does take me for a walk down memory lane, though. Thanks for that, and I'm sorry I can't give you anything more definite. I just haven't done that kind of programming since Windows came out.

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    oldTimer and oldKey are function pointers. That's why it's complaining at you. That's why I asked what getvect was. Because those are pointers to functions, and you aren't assigning them functions. You're trying to assign them the return value from the function.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM