计算机组成原理 外设,输入输出系统 (RV$6.9,唐第5章) llxx@ustc.edu.cn 1
1 计算机组成原理 外设,输入输出系统 (RV $6.9,唐第5章) llxx@ustc.edu.cn
1/O:printf(),getchar(),putchar()? #include <stdio.h> Processor int main(void) FSB int ch; Graphics North Bridge SDRAM printf("Input a character:"); PCI 33 MHz Slots /read a cD→oO IDE character from USB South Bridge the standard input SA stream * Super ch getchar(); COM1 putchar(ch); COM2 return 0;
I/O:printf(),getchar(),putchar()? #include <stdio.h> int main(void) { int ch; printf("Input a character:"); /* read a character from the standard input stream */ ch = getchar(); putchar(ch); return 0; }
KB:位置码 Key Cap d f 8 9 b Spring 哒哒嗌嗒 Mechanical switch 4 5 6 7 Conductor-coated membrane 0 2 Logical arrangement of keys Contacts Membrane switch 编码键盘:字符码(ASCI) 非编码键盘:位置码(POS机)
KB:位置码 编码键盘:字符码(ASCII) 非编码键盘:位置码(POS机)
I/F:Keyboard-to-processor connection Input interface Data Data Address KBD DATA Encoder Keyboard Processor R/W KBD STATUS circuit switches Master-ready Valid Slave-ready keyboard data 15 87 0 interrupt enable bit KBDR 151413 ready bit KBSR interrupt signal to processor
I/F:Keyboard-to-processor connection
Input from Keyboard:步骤 USTC When a character is typed: KB Data:its ASCll code is placed in bits [7:0]of KBDR .(bits [15:8]are always zero) - the“ready bit'”(KBSR[15])is set to1 keyboard is disabled(可屏蔽)-any typed characters will be ignored keyboard data 15 87 0 interrupt enable bit KBDR 151413 0 ready bit KBSR interrupt signal ·When KBDR is read: to processor KBSR[15]is set to 0 keyboard is enabled INTR or轮询 一多任务?
Input from Keyboard:步骤 • When a character is typed: – KB Data:its ASCII code is placed in bits [7:0] of KBDR • (bits [15:8] are always zero) – the “ready bit” (KBSR[15]) is set to 1 – keyboard is disabled(可屏蔽) -- any typed characters will be ignored • When KBDR is read: – KBSR[15] is set to 0 – keyboard is enabled • INTR or 轮询 – 多任务?