¦bPC¹q¸£¤W¡A¤¤Â_¥Ñ³\¦h¤£¦Pªº¨Ó·½©Ò¤Þµo¡CµM¦Ó¤¤Â_³Ì¥DnÁÙ¬O¥Ñp®É¾¹
´¹¤ù¡AÁä½L¡A¦ê¦C¶Ç¿é°ð¡A¨Ã¦C¶Ç¿é°ð¡AºÏºÐ¾÷¡ACMOS§Y®É¯ß½Ä¡A·Æ¹«¡Aµ®Ä
¥d¡A©M¨ä¥L©PÃä³]³Æ©Ò¤Þµo¡C
³o¨Ç¸Ë¸m³s±µ¦Üintel
8259A ¥iµ{¦¡¤¤Â_±±¨î¾¹(pic)¡A
°Ï¤À80x86cpu¤¤Â_©M¤¶±ªºÀu¥ý¶¶§Ç¡C³oÓ8259A´¹¤ù¼W¥[¤F³nÅé³B²z¤¤Â_ªº¥iÆ[
½ÆÂø«×¡A©Ò¥H¦b§Ú̸յ۴yz¤¤Â_ªA°Èµ{¦¡¦p¦ó³B²z¥¦¤§«e¡A¥ý°Q½×¥iµ{¦¡¤¤Â_
±±¨î¾¹·|¬Û·í²z·Q¡CµM«á¡A¦b³oÓ³¡¤À¤¤±N·|²³æªº´yz¥iµ{¦¡¤¤Â_±±¨î¾¹¤¤Â_
CPU¤Uªº¨C¤@Ӹ˸m©M±¡ªp¡C³oÓ¤å¥ó±N·|¦b³Ì«á¤@³¹¤¤§¹¾ãªº´yz³o¨Ç¸Ë¸m¡A
©Ò¥H¦b³o¤@³¹°£¤F¦b°Q½×p®É¾¹¤¤Â_¥~¡A±N¤£·|´£¨ì¤Ó¦hªº²Ó¸`¡C
Input on 8259 | 80x86 INT | ¸Ë¸m(Device) |
---|---|---|
IRQ 0 | 8 | p®É¾¹´¹¤ù(timer chip) |
IRQ 1 | 9 | Áä½L(Keyboard) |
IRQ 2 | 0Ah | ¦ê±µªº¦¸n±±¨î¾¹
(Cascade for controller 2 (IRQ 8-15)) |
IRQ 3 | 0Bh | ¦ê¦C°ð2(Serial port 2) |
IRQ 4 | 0Ch | ¦ê¦C°ð1(Serial port 1) |
IRQ 5 | 0Dh | ¨Ã¦C°ð2¡A«O¯dµ¹PS/2¨Ï¥Î
(Parallel port 2 in AT, reserved in PS/2 systems) |
IRQ 6 | 0Eh | ºÏºÐ¾÷(Diskette drive) |
IRQ 7 | 0Fh | ¨Ã¦C°ð1(Parallel port 1) |
IRQ 8/0 | 70h | §Y®Ép®É¾¹(Real-time clock) |
IRQ 9/1 | 71h | CGA vertical retrace (and other IRQ 2 devices) |
IRQ 10/2 | 72h | «O¯d(Reserved) |
IRQ 11/3 | 73h | «O¯d(Reserved) |
IRQ 12/4 | 74h | «O¯dµ¹AT¡APS/2¨t²Î¤Wªº»²§U¸Ë¸m
(Reserved in AT, auxiliary device on PS/2 systems) |
IRQ 13/5 | 75h | ¯BÂI¹Bºâ¤¤Â_(FPU interrupt) |
IRQ 14/6 | 76h | µwºÐ±±¨î¾¹(Hard disk controller) |
IRQ 15/7 | 77h | «O¯d(Reserved) |
³oÓ8259 PIC ¹ïµ{¦¡¨Ó»¡¬O¤@Ó½ÆÂøªº´¹¤ù¡C©¯¹Bªº¬O¡A¹ï©ó©Ò¦³³o¨ÇµwÅé¡A¦b±Ò
°Êªº®ÉÔ¡ABIOS´N¤w¸gÀ°§A°µ¦n¤F¡C¦b¥»¤å¤¤§Ṳ́£¥Î¥h°Q½×¦p¦ó¥hªì©l¤Æ³oÓ´¹
¤ù¡A¦]¬°³oÓ°T®§¥u¹ï¨º¨Çn¼g§@·~¨t²Îªº¦³¥Î¦Ó¤w¡A¹³¬OLinux¡AWindows¡Aor
OS/2¡C°²¨Ï§A·Qn§A¦Û¤vªº¤¤Â_ªA°Èµ{¦¡¥h¥¿½T¦a¦bDOS©Î¬O¨ä¥LOS©³¤U¶]¡A§A
¥²¶·¥ýªì©l¤Æ³oÓPIC¡C
¨t²ÎªºPICs¤¶±¦³¸g¹L¥|ÓI/O¦ì¸m¡G20h/0A0h
21h/0A1h¡C¨C¤@¹ïªº²Ä¤@Ó¦ì§}¬O¥D
nPIC(IRQ0-7)ªº¦ì§}¡A¦Ó¨C¤@¹ïªº²Ä¤GÓ¬O»P¦¸nªºPIC(IRQ8-15)¤@P¡C20h/0A0h°ð
¬O¤@ÓÅý§A¥i¥H¼gPIC©R¥O©MŪPICª¬ºAªºÅª/¼g¦ì¸m¡A§Ú̱N¥¦ºÙ¬°©R¥O¼È¦s¾¹©Î¬O
ª¬ºA¼È¼È¾¹¡C©R¥O¼È¦s¾¹¥u¯à¼g¡A¦Óª¬ºA¼È¦s¾¹¥u¯àŪ¡C³o¨âÓ¥u¬O«ê¥©¦@¥Î¦P¤@
ÓI/O¦ì¸m¡C¦bPIC¤WªºÅª/¼g½u¨M©w¤FCPU¦s¨úþ¤@ӼȦs¾¹¡C21h/0A1h°ð¬O¤@Ó¥]§t
¤¤Â_¾B¸n¼È¦s¾¹ªºÅª/¼g¦ì¸m¡A§Ú̱N¤§ºÙ¬°¾B¸n¼È¦s¾¹¡C¨Ì§A·Qnªº¬Oþ¤@ºØ¤¤Â_
±±¨î¾¹¨Ó¿ï¾Ü¾A©yªº¦ì§}¡C
¤¤Â_¾B¸n¼È¦s¾¹¬O¤@Ó¤Kbit¼È¦s¾¹¥i¥HÅý§A¥Ñ¨t²Î¤Wªº¸Ë¸m³æ¿W¦a±N¤¤Â_P¯à©M°£¯à¡C
³o¬OÃþ¦ücli©Msti«ü¥Oªº°Ê§@¡A¦ý¥u¬O§@¥Î¦b¤@Ӹ˸mªº°ò¦¤W¡C¼g¤@Ózero¨ì¹ïÀ³ªº¦ì
¤¸P¯à¸Ë¸mªº¤¤Â_¡C¦b¤@Ó³Q¼vÅTªº¸Ë¸m¼g¤@Ó°£¯à¤¤Â_¡Cª`·N³o¬O¨S¦³¸`¨îªº¨Ï¥Î¡C
©³¤Uªº³oӹϤù´£¨Ñ¤F¤¤Â_¾B¸n¼È¦s¾¹ªº°t¸m¹Ï¡C
·í§ïÅܾB¸n¼È¦s¾¹ªº¦ì¤¸¡A§A¤£¬O¥un±Nal¸ü¤J¤@ÓÈ©Mª½±µ¦a¿é¥X¦Ü¾B¸n¼È
¦s¾¹°ð¦Ó¤w¡C¬Û¤Ï¦a¡A§A¥²¶·Åª¨ú¾B¸n¼È¦s¾¹µM«á±NÅÞ¿èor³]©w§A·Qn§ïÅܪº
¦ì¤¸©ÎªÌ±NÅÞ¿èand²M°£§A·Qn§ïÅܪº¦ì¤¸¡F³Ì«á¡A§A´N¯à±N¿é¥X¼g¦^¾B¸n¼È
¦s¾¹¡C©³¤Uªº³oÓµ{¦¡½X¨Ì§ÇªºP¯àCOM1¡G¤£·|¼vÅT¨ì¨ä¥Lªº¤¤Â_¡C
in al, 21h
;Read existing bits.
and al, 0efh
;Turn on IRQ 4 (COM1).
out 21h, al
;Write result back to PIC.³oÓ©R¥O¼È¦s¾¹´£¨Ñ¤F«Ü¦hªº¿ï¶µ¡A¦ý¬O¥u¦³§A·Qn¦b³oÓ´¹¤ù¤W°õ¦æªº¤TÓ«ü¥O¬O
»P8259ªºBIOS'ªºªì©lȬO¬Û®eªº¡G¶Ç°e¤¤Â_«ü¥Oªºµ²§ô©M¶Ç°e¨âÓŪ¨ú¼È¦s¾¹«ü¥Oªº
¨ä¤¤¤@Ó¡C
·í¤@Ó¯S®íªº¤¤Â_µo¥Í¡A8259¾B¸n¤F¸Ë¸m¤¤©Ò¦³¨ä¥Lªº¤¤Â_¡Aª½¨ì¤¤Â_ªA°Èµ{¦¡±µ¨ü
¨ì¤@Ó¤¤Â_µ²§ôªº«H¸¹¡C¦bPC¹q¸£¤W¶]DOS¡A§A¼g¤J¤@ÓÈ20h¨ì©R¥O¼È¦s¾¹¨Ó§¹¦¨³o
Ӱʧ@¡C©³¤Uªº³oÓµ{¦¡½X°µ¤F³oÓ¤u§@¡C
mov al, 20h out 20h, al ;Port 0A0h if IRQ 8-15.¹ï©ó§A·Qnªº¨C¤@Ó¤¤Â_ªA°È¡A§A¥²¶·¶Ç°e¥¿½Tªº¤¤Â_©R¥O¨ìPIC¤¤¡C°²¨Ï§A¨S¦³¶Ç°e
§A¯à¶Ç°eªº8259¨ä¥L¨âÓ©R¥OÅý§A¥i¥H¿ï¾Ü¬O§_Ū¨úin-service¼È¦s¾¹(ISR¤¤Â_ªA°È¼È
¦s¾¹)©ÎªÌ¬O interrupt
request ¼È¦s¾¹(IRR¤¤Â_n¨D¼È¦s¾¹)¡CIn-service
¼È¦s¾¹¥]§t¹ï¨C
¤@Ó¹B§@¤¤ªºISR¦ì¤¸ªº¶°¦X¡C(¦]¬°8259¤¹³\Àu¥ý¶¶§Çªº¤¤Â_¡A©Ò¥H¤@ÓISR¬Û·í¦³
¥i¯à³Q¤@Ó¸û°ªÀu¥ýÅvªºISR©Ò¤¤Â_)¡CInterrupt
request¼È¦s¾¹¥]§t¤F¦b©|¥¼³QªA°Èªº¤¤
Â_¹ïÀ³¦ì¸m¦ì¤¸ªº¶°¦X(¦³¥i¯à¬O¦]¬°ÄÝ©ó¤ñ¨º¨Ç³Q¨t²ÎªA°È¤¤ªº¤¤Â_ÁÙn§CÀu¥ýÅvªº
¤¤Â_)¡CnŪ¨úin-service
¼È¦s¾¹¡A§A»Ýn¥ý³B²z¤Uªº±Ôz¡C
;¦bPIC#1Ū¨ú in-service ¼È¦s¾¹(¦bI/O 20h¦ì§})
mov al, 0bh out 20h, al in al, 20h
Ū¨ú¤¤Â_n¨D¼È¦s¾¹¡A§A»Ý¨Ï¥Î©³¤Uªºµ{¦¡½X¡G
;¦bPIC#1¤¤Åª¨úinterrupt request ¼È¦s¾¹(¦bI/O¦ì§}20h)
mov al, 0ah out 20h, al in al, 20h¼g¤J¨ä¥LªºÈ¨ì©R¥O°ð¤]³\·|³y¦¨§Aªº¨t²Î¥¢¥h§@¥Î¡C
p®É¾¹¤¤Â_¦V¶q¤j·§¬O¦b¨t²Î¤¤³Ì±`³Q§ó§ïªº¤¤Â_¡C¥¦¦b¨t²Î¤¤¦³¨âÓ¡CInt
8 ¬O»Pp®É¾¹¤¤Â_¬ÛÃöÁpªºµwÅé¦V¶q(¦]¬°¥¦¶}©l©ó¦bPIC¤WªºIRQ0)¡C¤@¯ë¨Ó»¡¡AY§A
·Q¼g¤@Óp®É¾¹ISR§A¤£¯à§ïÅܳoÓ¤¤Â_¡C¬Û¤Ï¦a¡A
§AÀ³¸Ó§ïÅܲĤGÓp®É¾¹¤¤Â_¡A
1ch¤¤Â_¡CBIOSªºp®É¾¹¤¤Â_³B²zµ{¦¡(int
8)°õ¦æ¤@Óint 1ch«ü¥O©ó¥¦µ²§ô¤§«e¡C³o
¥i¥HÅý¨Ï¥ÎªÌ§ïÅÜp®É¾¹¤¤Â_ªº°Æµ{¦¡¦s¨ú¡C°£«D§A·Qn½Æ»sBIOS©MDOSp®É¾¹ªº
µ{¦¡½X¡A§AµLªk§¹¥þªº¥Î¦Û¤vªº¥ô¤@Ó¨Ó¨ú¥N²{¦³p®É¾¹ISR¡A°£¤F§A¦Û¤vªºISR
§AÁÙ¥²¶·¤@ª½½T«OBIOS©MDOS
ISRs¦³¦b°õ¦æ ¡C§ïÅÜint
1ch¦V¶q¬O°µ³oӰʧ@³Ì²
³æªº¤èªk¡C
¬Æ¦Ü©ó¥Î«ü¦VISRªº«ü¼Ð¨Ó¨ú¥Nint
1ch¦V¶q¬O«D±`¦MÀIªº¡Cp®É¾¹¤¤Â_ªA°È°Æµ{¦¡¬O³Ì
±`³Q¤£¦Pªº±`¾nµ{¦¡©Ò§ïÅÜ¡C¥u¬O²³æªº±N§AªºISR¦ì§}¼g¤Jp®É¾¹¤¤Â_¦V¶q¡A§A¤]
³\·|°£¯à±`¾nµ{¦¡¦Ó¥B³y¦¨¨t²Î¥¢¥h§@¥Î¡C¬°¤F¸Ñ¨M³o¼Ëªº°ÝÃD¡A§A»Ýn³Ð³y¤@Ó
¤¤Â_Ãìµ²¡C»Ýn§ó¦hªº²Ó¸`¡A½Ð¬Ý"Chaining
Interrupt Service Routines"on page 1010¡C
¹w³]ªºp®É¾¹¤¤Â_Á`¬O¦b¤¤Â_±±¨î´¹¤ù³QP¯à¡Cªº½T¡A°£¯à³oÓ¤¤Â_¥i¯à·|³y¦¨§Aªº
¨t²Î·í±¼©Î¬O¨ä¥Lªº°ÝÃD¡C¦Ü¤Ö¡A§Aªº¨t²Î±NµLªkºûÅ@¥¿½Tªº®É¶¡°²¨Ï§A°£¯à³oÓp
®É¾¹¤¤Â_¡C
¹w³]±¡ªp¤U¡A¨t²Î°£¯àIRQ3©MIRQ4¡C°²¨Ï§A¦w¸Ë¤@Ó¦ê¦CISR¡A¦b¥¦¥ÑSCC¦^À³¤¤Â_
«e¡A§A»Ýn²M°£¦b8259PIC¤¤ªº¤¤Â_¾B¸n¦ì¤¸¡C¦¹¥~¡ASCC³]p¥]¬A¤F¥¦¦Û¤v¾Ö¦³ªº
¤¤Â_¾B¸n¡C§A±N»ÝP¯à¦bSCC´¹¤ù¤Wªº¤¤Â_¾B¸n¡Cn±o¨ì§ó¦h¦bSCC¤Wªº¸ê°T¡A½Ð¬Ý
¬Ý¾A·íªº³¹¸`¡C
¨C·í¤@Ó¯BÂI¹Bºâ²§±`µo¥Í¡A80X87¯BÂI¹Bºâ¾¹´N·|²£¥Í¤@Ó¤¤Â_¡C¦b¤º«ØFPUªºCPU
¤¤(80486DX©Î§ó¦nªº)¦³¤@Ó¼ÒÀÀ¦V¶q¤¤Â_ªº¦ì¤¸¦b§A¥i¥H³]©wªº±±¨î¼È¦s¾¹¤¤ªº¤@Ó
¸Ì±¡CBIOS³q±`¬°¤F¦s¦b¨t²Îªº¬Û®e©Ê¦Óªì©l¤Æ³o¼Ëªº¦ì¤¸¡C
¦b¹w³]±¡§Î¤U¡ABIOS°£¯àFPU¤¤Â_¡C¤j³¡¤À¨Ï¥ÎFPUªºµ{¦¡¦b¥~³¡´ú¸ÕFPUªºª¬ºA¼È¦s
¾¹¨Ó¨M©w¬O§_¦³¿ù»~²£¥Í¡CY§A¤¹³\FPU¤¤Â_¡A§A¥²¶·P¯à¦b8259©M80x87FPU¤Wªº¤¤
Â_¡C
³oÓ¤¤Â_¤£¯à³Q¾B¸n¡A©Ò¥H¦b¹w³]±¡§Î¤U¥¦Á`¬O³QP¯à¡C
Art of Assembly: Chaper Seventeen - 29 SEP 1996
¨Ó·½¡Ghttp://webster.ucr.edu/Page_asm/ArtofAssembly/ArtofAsm.html