Need Help in understanding this function

dipen30

dipen30

@dipen30-hGOPpa Oct 24, 2024
Can Anyone Explain This function ?

int getkey()
{
union REGS i,o;

while(!kbhit())
;
i.h.ah=0;
int86(22,&i,&o);
return(o.h.ah);
}

also what is h & ah in this function ?

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • illuminatus

    illuminatus

    @illuminatus-XECauN Aug 6, 2009

    Re: Need Help

    Sm more info abt the prog might help!!!
  • wassup

    wassup

    @wassup-ayhA3F Aug 6, 2009

    As the name itself suggests it's function to getkey or read a key pressed. The union REGS and int86 are defined in dos.h
    int86 allows you call interrupts. In this program you are calling interrupt number 22. Which is related to keyboard. The union REGS maps x86 registers. So you need one variable for input and one for output.
    The REGS union has two types defined x which is 32 bit and h which 16 bit.
    ax/ah bx/bh are x86 registers.

    REMEMBER this works only in DOS!
  • dipen30

    dipen30

    @dipen30-hGOPpa Aug 6, 2009

    thanx wassup