Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The BIOS (Basic Input Output Services) controls low level I/O on a computer. Whe

ID: 3787941 • Letter: T

Question

The BIOS (Basic Input Output Services) controls low level I/O on a computer. When a (PC) computer first starts up the system BIOS creates a data area starting at memory address 0 times 400 for its own use. Address 0 times 0417 is the Keyboard shift flags register, the bits of this byte have the following meanings: This byte can be written as well as read. Thus we may change the status of the Caps Lock, Num Lock and Scroll Lock LEDs on the keyboard by setting or clearing the relevant bit. Write a C function using pointers and bit operators to turn Caps lock on without changing the other bits. NOTE: Do NOT try to execute this on your PC unless you boot it to DOS in real mode.

Explanation / Answer

set_flag (int flag)
{
char far *pflag;

pflag = (char far *) (((unsigned long)0x40)<<16+(unsigned long) 0x17);

*pflag |=flag
_asm {
mov ah,1
int 16h
}
}
clear_flag (int flag)
{
char far *pflag;

pflag = (char far *) (((unsigned long)0x40)<<16+(unsigned long) 0x17);

*pflag &= ˜flag;
_asm {
mov ah,1
int 16h
}
}

for flag = 16 Scroll lock
for flag = 32 Num Lock
for flag = 64 Caps Lock