Microsoft PowerPoint - C15_LECTURE_NOTE_11

Similar documents
Microsoft PowerPoint - STU_EC_Ch08.ppt

Microsoft PowerPoint - C15_LECTURE_NOTE_08.ppt

Edge-Triggered Rising Edge-Triggered ( Falling Edge-Triggered ( Unit 11 Latches and Flip-Flops 3 Timing for D Flip-Flop (Falling-Edge Trigger) Unit 11

BC04 Module_antenna__ doc

Microsoft PowerPoint - C15_LECTURE_NOTE_04.ppt

Microsoft PowerPoint - C15_LECTURE_NOTE_04.ppt

Microsoft PowerPoint - C15_LECTURE_NOTE_08.ppt

2/80 2

Microsoft PowerPoint - C15_LECTURE_NOTE_09

K7VT2_QIG_v3

Microsoft PowerPoint - C15_LECTURE_NOTE_05.ppt

Microsoft PowerPoint - C15_LECTURE_NOTE_05.ppt

Microsoft PowerPoint - C15_LECTURE_NOTE_10.ppt

PowerPoint Presentation

AL-M200 Series

穨control.PDF

1.ai

Bus Hound 5

Microsoft PowerPoint - CA_02 Chapter5 Part-I_Single _V2.ppt

untitled

Microsoft PowerPoint - STU_EC_Ch04.ppt

Guide to Install SATA Hard Disks

中国人民大学商学院本科学年论文

P4V88+_BIOS_CN.p65

Microsoft PowerPoint - C15_LECTURE_NOTE_06

Pin Configurations Figure2. Pin Configuration of FS2012 (Top View) Table 1 Pin Description Pin Number Pin Name Description 1 GND 2 FB 3 SW Ground Pin.

幻灯片 1

Ác Åé å Serial ATA ( Sil3132) S A T A (1) SATA (2) BIOS SATA (3)* RAID BIOS RAID (4) SATA (5) SATA (a) S A T A ( S A T A R A I D ) (b) (c) Windows XP

Microsoft PowerPoint - Lecture7II.ppt

AN INTRODUCTION TO PHYSICAL COMPUTING USING ARDUINO, GRASSHOPPER, AND FIREFLY (CHINESE EDITION ) INTERACTIVE PROTOTYPING

untitled

Microsoft Word - HSK使用手册.doc

untitled

P4VM800_BIOS_CN.p65

入學考試網上報名指南

Microsoft PowerPoint - C15_LECTURE_NOTE_06

A Preliminary Implementation of Linux Kernel Virus and Process Hiding

IP TCP/IP PC OS µclinux MPEG4 Blackfin DSP MPEG4 IP UDP Winsock I/O DirectShow Filter DirectShow MPEG4 µclinux TCP/IP IP COM, DirectShow I

lan03_yen

4. 每 组 学 生 将 写 有 习 语 和 含 义 的 两 组 卡 片 分 别 洗 牌, 将 顺 序 打 乱, 然 后 将 两 组 卡 片 反 面 朝 上 置 于 课 桌 上 5. 学 生 依 次 从 两 组 卡 片 中 各 抽 取 一 张, 展 示 给 小 组 成 员, 并 大 声 朗 读 卡

T stg -40 to 125 C V cc 3.8V V dc RH 0 to 100 %RH T a -40 to +125 C -0.3 to 3.6V V -0.3 to VDD+0.3 V -10 to +10 ma = 25 = 3V) VDD

RAID RAID 0 RAID 1 RAID 5 RAID * ( -1)* ( /2)* No Yes Yes Yes A. B. BIOS SATA C. RAID BIOS RAID ( ) D. SATA RAID/AHCI ( ) SATA M.2 SSD ( )

投影片 1

Microsoft Word - template.doc

Microsoft Word doc

K301Q-D VRT中英文说明书141009

IP505SM_manual_cn.doc

國 立 政 治 大 學 教 育 學 系 2016 新 生 入 學 手 冊 目 錄 表 11 國 立 政 治 大 學 教 育 學 系 博 士 班 資 格 考 試 抵 免 申 請 表 論 文 題 目 申 報 暨 指 導 教 授 表 12 國 立 政 治 大 學 碩 博 士 班 論

PowerPoint Presentation

LH_Series_Rev2014.pdf

ICD ICD ICD ICD ICD

<4D F736F F F696E74202D20B5DAD2BBD5C228B4F2D3A1B0E6292E BBCE6C8DDC4A3CABD5D>

Improved Preimage Attacks on AES-like Hash Functions: Applications to Whirlpool and Grøstl

東莞工商總會劉百樂中學

System Design and Setup of a Robot to Pass over Steps Abstract In the research, one special type of robots that can pass over steps is designed and se

邏輯分析儀的概念與原理-展示版

學校發展計劃(二零零六至二零零七年)

IP Access Lists IP Access Lists IP Access Lists

untitled


學校發展計劃(二零零六至二零零七年)

Progress Report of BESIII Slow Control Software Development

ch_code_infoaccess

ARM JTAG实时仿真器安装使用指南

WTO

Microsoft Word - ChineseSATII .doc

ebook140-8

untitled

Microsoft Word - CX VMCO 3 easy step v1.doc

Windows XP

06721 main() lock pick proc() restart() [2][4] MINIX minix2.0 GDT, IDT irq table[] CPU CPU CPU CPU (IDTR) idt[] CPU _hwint00:! Interrupt

SPHE8202R Design Guide Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provi

<4D F736F F D C4EAC0EDB9A4C0E04142BCB6D4C4B6C1C5D0B6CFC0FDCCE2BEABD1A15F325F2E646F63>

Microsoft Word - MSP430 Launchpad 指导书.docx

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO

2015 Chinese FL Written examination

TX-NR3030_BAS_Cs_ indd

構 築 4 列 牌 陣 從 剩 餘 的 牌 庫 頂 抽 4 張 牌, 面 朝 上 排 列 在 桌 子 中 央 這 4 張 牌 就 是 牌 陣 的 起 始 牌, 包 括 這 張 起 始 牌 在 內, 每 一 列 最 多 只 能 容 納 5 張 牌 將 剩 餘 的 牌 暫 時 置 於 一 旁, 在 下

Preface This guide is intended to standardize the use of the WeChat brand and ensure the brand's integrity and consistency. The guide applies to all d

VASP应用运行优化

1 CPU

声 明 本 人 郑 重 声 明 : 此 处 所 提 交 的 硕 士 学 位 论 文 基 于 等 级 工 鉴 定 的 远 程 考 试 系 统 客 户 端 开 发 与 实 现, 是 本 人 在 中 国 科 学 技 术 大 学 攻 读 硕 士 学 位 期 间, 在 导 师 指 导 下 进 行 的 研 究

...1 What?...2 Why?...3 How? ( ) IEEE / 23

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

Serial ATA ( nvidia nforce4 Ultra/SLI)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 6 (4) S A T A... 9 (5) S A T A (6) Micro

2015年4月11日雅思阅读预测机经(新东方版)

Microsoft PowerPoint - ATF2015.ppt [相容模式]

\\Lhh\07-02\黑白\内页黑白1-16.p

國立中山大學學位論文典藏.PDF

東吳大學

Shanghai International Studies University THE STUDY AND PRACTICE OF SITUATIONAL LANGUAGE TEACHING OF ADVERB AT BEGINNING AND INTERMEDIATE LEVEL A Thes

软件测试(TA07)第一学期考试

PowerPoint Presentation

Microsoft Word - PZ series.doc

Microsoft Word - HC20138_2010.doc

ebook140-9

mvc

Gerotor Motors Series Dimensions A,B C T L L G1/2 M G1/ A 4 C H4 E

Transcription:

INTERRUPT INTERFACE OF THE 8088 AND 8086 MICROPROCESSOR INTERRUPT INTERFACE OF THE 8088 AND 8086 MICROPROCESSOR 11.1 Interrupt Mechanism, Types and Priority 11.2 Interrupt Vector Table 11.3 Interrupt Instructions 11.4 Enabling/Disabling of Interrupts 11.5 External Hardware-Interrupt Interface Signals 11.6 External Hardware-Interrupt Sequence 611 37100 微處理機原理與應用 Lecture 11-2

INTERRUP INTERFACE OF THE 8088 AND 8086 MICROPROCESSOR 11.7 82C59A Programmable Interrupt 11.8 Interrupt Interface Circuits Using the 82C59A 11.9 Software Interrupts 11.10 Nonmaskable Interrupt 11.11 Reset 11.12 Internal Interrupt Function 611 37100 微處理機原理與應用 Lecture 11-3 11.1 Interrupt Mechanism, Types and Priority Interrupts provide a mechanism for quickly changing program environment. Transfer of program control is initiated by the occurrence of either an event internal to the MPU or an event in its external hardware. The section of program to which control is passed is called the interrupt service routine. The 8088 and 8086 microprocessor are capable of implementing any combination of up to 256 interrupts. Interrupts are divided into five groups: External hardware interrupts Nonmaskable interrupts Software interrupts Internal interrupts reset 611 37100 微處理機原理與應用 Lecture 11-4

11.1 Interrupt Mechanism, Types and Priority Interrupt program context switching mechanism 611 37100 微處理機原理與應用 Lecture 11-5 11.1 Interrupt Mechanism, Types and Priority Hardware, software, and internal interrupts are serviced on a priority basis. Each interrupts is given a different priority level by assigning it a type number. Type 0 identifies the highest-priority interrupt, and type 255 identifies the lowest-priority interrupt. Tasks that must not be interrupted frequently are usually assigned to higher-priority levels and those that can be interrupted to lower-priority levels. Once an interrupt service routine is initiated, it could be interrupted only by a function that corresponds to a higher-priority level. 611 37100 微處理機原理與應用 Lecture 11-6

11.1 Interrupt Mechanism, Types and Priority Types of interrupts and their priority Increasing priority Reset Internal interrupts and exceptions Software interrupts Nonmaskable interrupts External hardware interrupts 611 37100 微處理機原理與應用 Lecture 11-7 11.2 Interrupt Vector Table An address pointer table is used to link the interrupt type numbers to the locations of their service routines in the program-storage memory. The address pointer table contains 256 address pointers (vectors), which are identified as vector 0 through vector 255. One pointer corresponds to each of the interrupt types 0 through 255. The address pointer table is located at the lowaddress end of the memory address space. It starts at 00000 16 and ends at 003FE 16. This represents the first 1 Kbytes of memory. 611 37100 微處理機原理與應用 Lecture 11-8

11.2 Interrupt Vector Table Interrupt vector table of the 8088/8086 611 37100 微處理機原理與應用 Lecture 11-9 11.2 Interrupt Vector Table EXAMPLE At what address are CS 50 and IP 50 stored in memory? Solution: Each vector requires four consecutive bytes of memory for storage. Therefore, its address can be found by multiplying the type number by 4. Since CS 50 and IP 50 represent the words of the type 50 interrupt pointer, we get Address = 4 x 50 = 200 converting to binary form gives Address = 11001000 2 = C8 16 Therefore, IP 50 is stored at 000C8 16 and CS 50 at 000CA 16. 611 37100 微處理機原理與應用 Lecture 11-10

11.3 Interrupt Instructions Mnemonic Meaning Format Operation Flags affected CLI Clear interrupt flag CLI 0 (IF) IF STI Set interrupt flag STI 1 (IF) IF INT n Type n software interrupt INT n (Flags) ((SP)-2) 0 TF, IF (CS) ((SP) 4) (2+4xn) (CS) (IP) ((SP) 6 ) (4xn) (IP) TF, IF IRET Interrupt return IRET ((SP)) (IP) ((SP)+2) (CS) ((SP)+4) (Flags) (SP) + 6 (SP) All INTO Interrupt on overflow INTO INT 4 steps TF, IF HLT Halt HLT Wait for an external interrupt or reset to occur None WAIT Wait WAIT Wait for TEST input to go active 611 37100 微處理機原理與應用 Lecture 11-11 11.4 Enabling/Disabling of Interrupts An interrupt-enable flag bit (IF) is provided within the 8088/8086 MPUs. The ability to initiate an external hardware interrupt at the INTR input is enabled by setting IF or masked out by resetting it. Executing the STI or CLI instructions, respectively, does this through software. During the initiation sequence of a service routine for an external hardware interrupt, the MPU automatically clears IF. This masks out the occurrence of any additional external hardware interrupts. 611 37100 微處理機原理與應用 Lecture 11-12

11.5 External Hardware-Interrupt Interface Signals Minimum-mode interrupt interface Key interrupt interface signals: INTR and INTA Minimum-mode 8088 and 8086 system external hardware interrupt interface 611 37100 微處理機原理與應用 Lecture 11-13 11.5 External Hardware-Interrupt Interface Signals Maximum-mode interrupt interface 8288 bus controller is added in the interface. The INTA and ALE signals are produced by the 8288. The bus priority lock signal LOCK is also added. This signal ensures that no other device can take over control of the system bus until the interrupt-acknowledge bus cycle is completed. Maximum-mode 8088 and 8086 system external hardware interrupt interface 國立台灣大學生物機電系 611 37100 微處理機原理與應用 Lecture 11-14 林達德

11.5 External Hardware-Interrupt Interface Signals Maximum-mode interrupt interface Interrupt bus status code to the 8288 bus controller 611 37100 微處理機原理與應用 Lecture 11-15 11.6 External Hardware-Interrupt Sequence COMPLETE CURRENT INSTRUCTION INTERNAL INTERRUPT? NMI NO YES YES INTR NO NO YES IF 0 1 ACKNOWLEDGE INTERRUPT READ TYPE NUMBER TF 0 1 COMPLET CURRENT INSTRUCTION EXECUTE NEXT INSTRUCTION LET TEMP = TF 611 37100 微處理機原理與應用 Lecture 11-16

11.6 External Hardware-Interrupt Sequence CLEAR IF & TF PUSH CS & IP CALL INTERRUPT SERVICE ROUTINE EXECUTE USER INTERRUPT ROUTINE POP IP & CS Flow chart of the interrupt processing sequence of the 8088 and 8086 microprocessor POP FLAGS RESUME INTERRUPT PROCEDURE 611 37100 微處理機原理與應用 Lecture 11-17 11.6 External Hardware-Interrupt Sequence Interrupt-acknowledge bus cycle 611 37100 微處理機原理與應用 Lecture 11-18

11.6 External Hardware-Interrupt Sequence Interrupt service routine To save registers and parameters on the stack Main body of the service routine To restore register and parameters from the stack Return to main program 611 37100 微處理機原理與應用 Lecture 11-19 PUSH XX PUSH YY PUSH ZZ..... POP ZZ POP YY POP XX IRET 11.6 External Hardware-Interrupt Sequence EXAMPLE The circuit in the next slide is used to count interrupt requests. The interrupting device interrupts the microprocessor each time the interrupt-request input signal transitions from 0 to 1. The corresponding interrupt type number generated by the 74LS244 is 60H. a. Describe the hardware operation for an interrupt request. b. What is the value of the type number sent to the microprocessor? c. Assume that (CS)=(DS)=1000H and (SS)=4000H; the main program is located at offsets of 200H; the count is held at 100H; the interrupt-service routine starts at offset 1000H from the beginning of another code segment at 2000H:0000H; and the stack starts at an offset of 500H from the stack segment. Make a map showing the memory address space. d. Write the main program and the service routine. 611 37100 微處理機原理與應用 Lecture 11-20

11.6 External Hardware-Interrupt Sequence EXAMPLE 611 37100 微處理機原理與應用 Lecture 11-21 11.6 External Hardware-Interrupt Sequence Solution: a. A positive transition at the CLK input of the flip-flop (interrupt request) make the Q output of the flip-flop logic 1 and presents a positive level signal at the INTR input of the 8088. When 8088 recognized this as an interrupt request, it responds by generating the INTA signal. The logic 0 output on the line clears the flip-flop and enables the 74LS244 buffer to present the type number to the 8088. This number is read of the data bus by the 8088 and is used to initiate the interrupt-service routine. b. From the inputs and outputs of the 74LS244, we see the type number is AD 7 AD 1 AD 0 = 2Y 4 2Y 3 2Y 2 2Y 1 1Y 4 1Y 3 1Y 2 1Y 1 = 01100000 2 AD 7 AD 1 AD 0 = 60H 611 37100 微處理機原理與應用 Lecture 11-22

11.6 External Hardware-Interrupt Sequence Solution: c. The memory organization is in the right figure 611 37100 微處理機原理與應用 Lecture 11-23 11.6 External Hardware-Interrupt Sequence Solution: d. The flowcharts of the main program and interrupt-service routine Main Program Set up data segment, stack segment, and stack pointer SRVRTN Save processor status Set up the interrupt vector Increment the count Enable interrupts Restore processor status Wait for interrupt Return 611 37100 微處理機原理與應用 Lecture 11-24

11.6 External Hardware-Interrupt Sequence Solution: 611 37100 微處理機原理與應用 Lecture 11-25 11.7 82C59A Programmable Interrupt The 82C59A is an LSI peripheral IC that is designed to simplify the implementation of the interrupt interface in the 8088- and 8086-based microcomputer system. The 82C59A is known as a programmable interrupt controller or PIC. The operation of the PIC is programmable under software control. The 82C59A can be cascaded to expand from 8 to 64 interrupt inputs. 611 37100 微處理機原理與應用 Lecture 11-26

11.7 82C59A Programmable Interrupt Block diagram of the 82C59A Block diagram and pin layout of the 82C59A 611 37100 微處理機原理與應用 Lecture 11-27 11.7 82C59A Programmable Interrupt Internal architecture of the 82C59A 611 37100 微處理機原理與應用 Lecture 11-28

11.7 82C59A Programmable Interrupt Internal architecture of the 82C59A Eight functional parts of the 82C59A The data bus buffer The read/write logic The control logic The in-service register The interrupt-request register The priority resolver The interrupt-mask register The cascade buffer/comparator 611 37100 微處理機原理與應用 Lecture 11-29 11.7 82C59A Programmable Interrupt Programming the 82C59A Two types of command words are provided to program the 82C59A: the initialization command words (ICW) and the operational command words (OCW). ICW commands (ICW 1, ICW 2, ICW 3, ICW 4 ) are used to load the internal control registers of the 82C59A to define the basic configuration or mode in which it is used. The OCW commands (OCW 1, OCW 2, OCW 3 ) permit the 8088 or 8086 microprocessor to initiate variations in the basic operating modes defined by the ICW commands. The MPU issues commands to the 82C59A by initiating output (I/O-mapped) or write (Memory-mapped) cycles. 611 37100 微處理機原理與應用 Lecture 11-30

11.7 82C59A Programmable Interrupt Programming the 82C59A ICW1 ICW2 NO (SNGL=1) IN CASCADE MODE? YES (SNGL=0) ICW3 NO (IC4=0) IS ICW4 NEEDED? YES (IC4=1) ICW4 READY TO ACCEPT INTERRUPT REQUESTS 611 37100 微處理機原理與應用 Lecture 11-31 Initialization sequence of the 82C59A 11.7 82C59A Programmable Interrupt Initialization command words ICW 1 611 37100 微處理機原理與應用 Lecture 11-32

11.7 82C59A Programmable Interrupt EXAMPLE What value should be written into ICW 1 in order to configure the 82C59A so that ICW 4 is needed in the initialization sequence, the system is going to use multiple 82C59As, and its inputs are to be level sensitive? Assume that all unused bits are to be logic 0. Solution: Since ICW 4 is to be initialized, D 0 must be logic 1, D 0 = 1 For cascaded mode of operation, D 1 must be 0, D 1 = 0 And for level-sensitive inputs, D 3 must be 1, D 3 = 1 Bits D 2 and D 5 through D 7 are don t-care states and are 0. D 2 = D 5 = D 6 = D 7 = 0 Moreover, D 4 must be fixed at the 1 logic level, D 4 = 1 This gives the complete command word D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0 = 00011001 2 = 19 16 611 37100 微處理機原理與應用 Lecture 11-33 11.7 82C59A Programmable Interrupt Initialization command words ICW 2 is used for type number determination 611 37100 微處理機原理與應用 Lecture 11-34

11.7 82C59A Programmable Interrupt EXAMPLE What should be programmed into register ICW 2 if the type numbers output on the bus by the device are to range from F0 16 through F7 16? Solution: To set the 82C59A up so that type numbers are in the range of F0 16 through F7 16, its device code bits must be D 7 D 6 D 5 D 4 D 3 = 11110 2 The lower three bits are don t-care states and all can be 0s. This gives the word D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0 = 11110000 2 = F0 16 611 37100 微處理機原理與應用 Lecture 11-35 11.7 82C59A Programmable Interrupt Initialization command words ICW 3 is required only for cascaded mode of operation 611 37100 微處理機原理與應用 Lecture 11-36

11.7 82C59A Programmable Interrupt EXAMPLE Assume that a master PIC is to be configured so that its IR 0 through IR 3 inputs are to accept inputs directly from external devices, but IR 4 through IR 7 are to be supplied by the INT outputs of slaves. What code should be used for the initialization command word ICW 3? Solution: For IR 0 through IR 3 to be configured to allow direct inputs from external devices, bits D 0 through D 3 of ICW 3 must be logic 0: D 3 D 2 D 1 D 0 = 0000 2 The other IR inputs of the master are to be supplied by INT outputs of slaves. Therefore, their control bits must be all 1: D 7 D 6 D 5 D 4 = 1111 2 This gives the complete command word D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0 = 11110000 2 = F0 16 611 37100 微處理機原理與應用 Lecture 11-37 11.7 82C59A Programmable Interrupt Initialization command words ICW 4 is used to configure device for use with the 8088 or 8086 and selects various features in its operation. 611 37100 微處理機原理與應用 Lecture 11-38

11.7 82C59A Programmable Interrupt Operational command words OCW 1 is used to access the contents of the interrupt-mask register (IMR). Setting a bit to logic 1 masks out the associated interrupt input. 611 37100 微處理機原理與應用 Lecture 11-39 11.7 82C59A Programmable Interrupt EXAMPLE What should be the OCW 1 code if interrupt inputs IR 0 through IR 3 are to be masked and IR 4 through IR 7 are to be unmasked? Solution: For IR 0 through IR 3 to be masked, their corresponding bits in the mask register must be make logic 1: D 3 D 2 D 1 D 0 = 1111 2 On the other hand, for IR 4 through IR 7 to be unmasked, D 4 through D 7 must be logic 0: D 7 D 6 D 5 D 4 = 0000 2 This gives the complete command word D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0 = 00001111 2 = 0F 16 611 37100 微處理機原理與應用 Lecture 11-40

11.7 82C59A Programmable Interrupt Operational command words OCW 2 is used to select appropriate priority scheme and assigns an IR level for the scheme. 611 37100 微處理機原理與應用 Lecture 11-41 11.7 82C59A Programmable Interrupt EXAMPLE What OCW 2 must be issued to the 82C59A if the priority scheme rotate on nonspecific EOI command is to be selected? Solution: To enable the rotate on nonspecific EOI command priority scheme, bits D 7 through D 5 must be set to 101. Since a specific level does not have to be considered, the rest of the bits in the command word can be 0. This gives OCW 2 as D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0 = 10100000 2 = A0 16 611 37100 微處理機原理與應用 Lecture 11-42

11.7 82C59A Programmable Interrupt Operational command words OCW 3 permits reading of the contents of the ISR or IRR registers through software. 611 37100 微處理機原理與應用 Lecture 11-43 11.7 82C59A Programmable Interrupt EXAMPLE Write a program that will initialize an 82C59A with the initialization command words ICW 1, ICW 2, ICW 3 derived in the previous examples, and ICW 4 is equal to 1F 16. Assume that the 82C59A resides at address A000 16 in the memory address space. Solution: Since the 82C59A resides in the memory address space, we can use a series of move instructions to write the initialization command words into its registers. Note that the memory address for an ICW is A000 16 if A 0 = 0, and it is A001 16 if A 0 = 1. However, before doing this, we must first disable interrupts. This is done with the instruction CLI ; Disable interrupts 611 37100 微處理機原理與應用 Lecture 11-44

11.7 82C59A Programmable Interrupt Next we will create a data segment starting at address 00000 16 : MOV AX, 0 ;Create a data segment at 00000H MOV DS, AX Now we are ready to write the command words to the 82C59A: MOV AL, 19H ;Load ICW1 MOV [0A000H], AL ;Write ICW1 to 82C59A MOV AL, 0F0H ;Load ICW2 MOV [0A001H], AL ;Write ICW2 to 82C59A MOV AL, 0F0H ;Load ICW3 MOV [0A001H], AL ;Write ICW3 to 82C59A MOV AL, 1FH ;Load ICW4 MOV [0A001H], AL ;Write ICW4 to 82C59A Initialization is now complete and the interrupts can be enabled STI ;Enable interrupts 611 37100 微處理機原理與應用 Lecture 11-45 11.8 Interrupt Interface Circuits Using the 82C59A Minimum-mode interrupt interface for the 8088 microcomputer using the 82C59A 611 37100 微處理機原理與應用 Lecture 11-46

11.8 Interrupt Interface Circuits Using the 82C59A Minimum-mode interrupt interface for the 8086 microcomputer using the 82C59A 611 37100 微處理機原理與應用 Lecture 11-47 11.8 Interrupt Interface Circuits Using the 82C59A For applications that require more than eight interrupt-request inputs, several 82C59As are connected into a master/slave configuration. Master/slave connection of the 82C59A interface 國立台灣大學生物機電系 611 37100 微處理機原理與應用 Lecture 11-48 林達德

11.8 Interrupt Interface Circuits Using the 82C59A Maximum-mode interrupt interface for the 8088 microcomputer using the 82C59A 611 37100 微處理機原理與應用 Lecture 11-49 11.8 Interrupt Interface Circuits Using the 82C59A EXAMPLE Analyze the circuit in the following figure and write an appropriate main program and a service routine that counts as a decimal number the positive edges of the clock signal applied to the IR 0 input of the 82C59A. 611 37100 微處理機原理與應用 Lecture 11-50

11.8 Interrupt Interface Circuits Using the 82C59A Solution: Lets first determine the I/O addresses of the 82C59A registers: A 15 A 14 A 13 A 12 A 11 A 10 A 9 A 8 A 7 A 6 A 5 A 4 A 3 A 2 A 1 A 0 = 1111111100000000 2 for A 1 = 0, M/IO = 0 and = 1111111100000010 2 for A 1 = 1, M/IO = 0 These two I/O addresses are FF00H and FF02H, respectively. The address FF00H is for the ICW 1 and FF02H is for the ICW 2, ICW 3, ICW 4, and OCW 1 command words. The command words are: ICW 1 = 00010011 2 = 13H ICW 2 = 01001000 2 = 48H ICW 3 = not needed ICW 4 = 00000011 2 = 03H OCW 1 = 11111110 2 = FEH 611 37100 微處理機原理與應用 Lecture 11-51 11.8 Interrupt Interface Circuits Using the 82C59A Software organization: 611 37100 微處理機原理與應用 Lecture 11-52

11.8 Interrupt Interface Circuits Using the 82C59A Flowcharts of the main program and service routine: Main Program Set up data segment, stack segment, and stack pointer SRV72 Save processor status Set up the interrupt vector Increment the count Initialize 82C59A Restore processor status Enable interrupts Return Wait for interrupt 611 37100 微處理機原理與應用 Lecture 11-53 11.8 Interrupt Interface Circuits Using the 82C59A Program: ;MAIN PROGRAM CLI ;Start with interrupt disabled START: MOV AX, 0 ;Extra segment at 00000H MOV ES, AX MOV AX, 1000H ;Data segment at 01000H MOV DS, AX MOV AX, 0FF00H ;Stack segment at 0FF00H MOV SS, AX MOV SP, 100H ;Top of stack at 10000H MOV AX, OFFSET SRV72 ;Get offset for SRV72 MOV [ES:120H], AX ;Set up the IP MOV AX, SEG SRV72 ;Get CS for the service routine MOV [ES:122H], AX ;Set up the CS 611 37100 微處理機原理與應用 Lecture 11-54

11.8 Interrupt Interface Circuits Using the 82C59A Program: MOV DX, 0FF00H ;ICW1 address MOV AL, 13H ;Edge trig input, single 8259A OUT DX, AL MOV DX, 0FF02H ;ICW2, ICW4, OCW1 address MOV AL, 48H ;ICW2, type 72 OUT DX, AL MOV AL, 03H ;ICW4, AEOI, nonbuf mode OUT DX, AL MOV AL, 0FEH ;OCW1, mask all but IR0 OUT DX, AL STI ;Enable the interrupts 611 37100 微處理機原理與應用 Lecture 11-55 11.8 Interrupt Interface Circuits Using the 82C59A Program: SRV72: PUSH AX ;Save register to be used MOV AL, [COUNT] ;Get the count INC AL ;Increment the count DAA ;Decimal adjust the count MOV [COUNT], AL ;Save the new count POP AX ;Restore the register used IRET ;Return from interrupt 611 37100 微處理機原理與應用 Lecture 11-56

11.9 Software Interrupts The 8088 and 8086 microcomputer systems are capable of implementing up to 256 software interrupts. The INT n instruction is used to initiate a software interrupt. The software interrupt service routine vectors are also located in the memory locations in the vector table. Software interrupts are of higher priority than the external interrupts and are not masked out by IF. The software interrupts are actually vectored subroutine calls. 611 37100 微處理機原理與應用 Lecture 11-57 11.10 Nonmaskable Interrupt The nonmaskable interrupt (NMI) is initiated from external hardware. Differences between NMI and other external interrupts: NMI can not be masked out with the interrupt flag. Request for NMI service are signaled to the 8088/8086 microprocessor by applying logic 1 at the NMI input, not the INTR input. NMI input is positive edge-triggered. Therefore, a request for NMI is automatically latched internal to the MPU. NMI automatically vectors from the type 2 vector location in the pointer table (0008 16 ~000A 16 ) Typically, the NMI is assigned to hardware events that must be responded to immediately, such power failure. 611 37100 微處理機原理與應用 Lecture 11-58

11.11 Reset The RESET input of the 8088 and 8086 microprocessors provides a hardware means for initializing the microcomputer. Reset interface and timing sequence of the 8088 611 37100 微處理機原理與應用 Lecture 11-59 11.11 Reset 8088 signal status 8086 signal status Bus and control signal status of the 8088/8086 during system reset 611 37100 微處理機原理與應用 Lecture 11-60

11.11 Reset When the MPU recognizes the RESET input, it initiates its internal initialization routine. At completion of initialization, the flags are all cleared, the registers are set to the values in the following table. CPU COMPONENT Flags Instruction pointer CS Register DS Register SS Register ES Register Queue 611 37100 微處理機原理與應用 Lecture 11-61 Clear 0000H FFFFH 0000H 0000H 0000H Empty CONTENT 11.11 Reset The external hardware interrupts are disabled after the initialization. Program execution begins at address FFFF0 16 after reset. This storage location contains an instruction that will cause a jump to the startup (boot-strap) program that is used to initialize the reset of the microcomputer system s resources, such as I/O ports, the interrupt flag, and data memory. After the system-level initialization is complete, another jump can be performed to the starting point of the microcomputer s operating system or application program. 611 37100 微處理機原理與應用 Lecture 11-62

11.12 Internal Interrupt Functions Four of the 256 interrupts of the 8088 and 8086 are dedicated to internal interrupt functions. Internal interrupts differ from external hardware interrupts in that they occur due to the result of executing an instruction, not an event that takes place in external hardware. Internal interrupts are not masked out with IF flag. Internal interrupts of the 8088 and 8086 MPU: Divide error (Type number 0) Single step (Type number 1) Breakpoint interrupt (Type number 3) Overflow error (Type number 4) 611 37100 微處理機原理與應用 Lecture 11-63 11.12 Internal Interrupt Functions Internal interrupt vector locations 611 37100 微處理機原理與應用 Lecture 11-64