8. Consider a memory-mapped access to a keyboard. The keyboard controller has tw
ID: 3836369 • Letter: 8
Question
8. Consider a memory-mapped access to a keyboard. The keyboard controller has two registers: a control register whose bit 1 (i.e., the bit at position one, assuming the least-significant bit is at position zero) can be set to 1 to enable interrupts; and a data register which contains the ASCII code of the key which got pressed (and at that time, the keyboard sends an interrupt signal if interrupts were enabled). Assume the control and data registers are accessed using physical memory addresses 0xFFFF0000 and 0xFFFF0004, respectively.
PLEASE EXPLAIN HOW YOU GOT EACH ANSWER
(i) Write low-level Intel-like instruction(s) to enable keyboard interrupt by setting bit 1 to 1 in the keyboard’s control register (and other bits to zero). (Don’t worry about the exact syntax, pseudo-code is fine.)
(ii) Write low-level Intel-like instruction(s) to read the character from the keyboard’s data register at the time of interrupt.
(iii) Which part of the system (software and/or hardware) typically executes these instructions?
PLEASE EXPLAIN HOW YOU GOT EACH ANSWER
PLEASE EXPLAIN HOW YOU GOT EACH ANSWER
PLEASE EXPLAIN HOW YOU GOT EACH ANSWER!
Explanation / Answer
As the size of the control register size is not mentioned i am assuming that its size is 4 bits as control register size started from 0xFFFF0000 and the data register(assuming data register to be 8 bits, as they are in general) starts at 0xFFFF0004
So the locations we can acces for the control register are 4 bits the locations are 0xFFFF0000,0xFFFF0001,0xFFFF0002,0xFFFF0003 and similarly for data register 8 bits
1.Here the keyboard interrupt enable bit must be changed to 1 so that the processor knows that keyboard wants to send a data (i.e by continuous polling by processor or through vectored interrupts), so assuming the last bit as interrupt enable bit , so we need to change last bit to 1 and rest of them to 0
TestBit 0xFFFF0003, #1 //TestBit will change the status to 1 and other bits can be done similarly to 0
TestBit 0xFFFF0002, #0
TestBit 0xFFFF0001, #0
TestBit 0xFFFF0000, #0
2.READWAIT: READ 0xFFFF0003 //Reading the interrupt flag of keyboard
Branch_to_READWAIT_if_[0xFFFF0003]=0 //Checking whether the interrupt is equal to 1 or not if it is one proceed to next instruction otherwise wait till interrupt flag becomes 1
LoadByte 0xFFFF0004 R5 //the ASCII(8 bits or 1 byte) value is transferred from the keyboard to the desired location by processor
And the interrupt flag is set to 0 by the circuit when the transfer is done.
3.Software doesnot participate, these are done by circuits which are programmed to perform according to the events as they must be fast.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.