I'm doing homework and trying to read keys from keyboard. I tried to use 16h
interrupt and started with this code
int main(){
char key, shiftKey(2);
asm ("movb %1, %%al;"
"int $0x16;"
"movb %%al, %0;"
:"=r"(key)
:"r"(shiftKey)
:"%al"
);
std::cout << int(key);
}
Assembly algorithm is:
- pass function number (02) to
al
registermovb 2, al
- call interruption
int 16h
al
now should have mask of all keys like shift, capslock etc.
This code crashes with Process finished with exit code -1073741819 (0xC0000005)
. So I have no proper info what have I done wrong.