Int 16 keyboard interrupt

Hi - I'm trying to write a program using int16, implementing a polled waiting loop that monitors the keyboard for input and displays it on the screen. Also displaying the system clock while waiting for input would be good. Please, please..I'm stuck.

Comments

  • : Hi - I'm trying to write a program using int16, implementing a polled waiting loop that monitors the keyboard for input and displays it on the screen. Also displaying the system clock while waiting for input would be good. Please, please..I'm stuck.
    [blue]
    You can try this (not tested--only works with a
    16-bit compiler):[/blue][code]
    int main ()
    {
    char scancode=0;
    _asm
    {
    mov ah, 01h
    int 16h
    mov scancode, al
    }
    [green]// now 'scancode' contains the
    // ANSII char for the key pressed.[/green]
    }[/code]
  • : Hi - I'm trying to write a program using int16, implementing a polled waiting loop that monitors the keyboard for input and displays it on the screen. Also displaying the system clock while waiting for input would be good. Please, please..I'm stuck.
    :

    you can do it without using software interrupts.
    [code]
    time_t t1, t2;
    t1 = 0;
    while(!_kbinp())
    {

    t2 = time(0);
    if(t2-t1 >= 1)
    {
    struct tm* tm = localtime(&now);
    printf("%s", asctime(tm));
    }
    Sleep(100);
    }
    // key detected
    [/code]
  • : : Hi - I'm trying to write a program using int16, implementing a polled waiting loop that monitors the keyboard for input and displays it on the screen. Also displaying the system clock while waiting for input would be good. Please, please..I'm stuck.
    : :
    :
    : you can do it without using software interrupts.
    : [code]
    : time_t t1, t2;
    : t1 = 0;
    : while(!_kbinp())
    : {
    :
    : t2 = time(0);
    : if(t2-t1 >= 1)
    : {
    : struct tm* tm = localtime(&now);
    : printf("%s", asctime(tm));
    : }
    : Sleep(100);
    : }
    : // key detected
    : [/code]
    :
    Ya, but sleep is such a sloppy way of doing things.

  • : :
    : Ya, but sleep is such a sloppy way of doing things.
    :
    :

    why do you say that -- all it does is release the CPU so that other processes get time. It prevents the current program from hogging all the CPU time. On single processor systems such as MS-DOS it doesn't really matter because there are no other processes to worry about.
  • I'm merely mocking sleep. You have to remember, chances are if he's using Int 16 to try to get key presses he's probabbly using MS-DOS or similar OS.
  • : I'm merely mocking sleep. You have to remember, chances are if he's using Int 16 to try to get key presses he's probabbly using MS-DOS or similar OS.
    :


    Oh I get it now. Simetimes things like that fly high above my head :-)
  • Ya, but I've realized that I do a horrible job at explaining things, and I overcomplicate things constantly so don't worry too much about it.

Sign In or Register to comment.

Howdy, Stranger!

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

Categories