Architecture of Computers 2 - Chapter 4 - Interruptions & I/O PDF
Document Details
Uploaded by WellPositionedRiemann6967
USTHB
2024
Tags
Summary
These lecture notes provide a summary on the architecture of computers. Specifically, they cover chapter 4, Interruptions & I/O, along with providing historical context.
Full Transcript
Architecture of Computers 2 L2ING Chapter 4 Interruptions & I/O 2024-2025 Historical A microprocessor is an integrated circuit able to perform all the operations of a central processing unit. In 1971, the American company Intel succeede...
Architecture of Computers 2 L2ING Chapter 4 Interruptions & I/O 2024-2025 Historical A microprocessor is an integrated circuit able to perform all the operations of a central processing unit. In 1971, the American company Intel succeeded, for the first time, in placing all the components that make up a processor on a single integrated circuit. Historical Marcian Ted Hoff Federico Faggin Historical ✓ Premier microprocesseur de l’histoire et de l’industrie. ✓ Performances équivalentes aux 30 mètres cubes d’un ENIAC, concentrée sur 10 millimètres carrés. ✓ Calculateur sur 4 bits, 16 registres de donnée sur 4 bits, jeu de 46 instructions. ✓ Largeur du bus de donnée 4 bits. ✓ Horloge à 108 kHz ✓ 2300 transistors ✓ Format de la puce : 3,81 mm de long sur 2,79 mm de large : 10,62 mm2. ✓ Tarif industriel 200 dollars (en 1971). ✓ Intel vend le microprocesseur et les droits exclusif du Intel 4004 à son client Japonais Busicom pour 60 000 dollars. SOLUTION! ✓ Diminuer la fréquence des cœurs pour réduire la consommation électrique et la dissipation thermique, mais avec plus de cœurs pour gagner en puissance de calcul. Mono-coeur Bi-cœurs Frequency F 0.75 F Consumption W 0.84 W Performance P 1.5 P - 25% Frequency - 16% Consumption + 50% Performance Intel 8086 Intel Core i9 THE INTERRUPTIONS ✓ This is an "asynchronous" event, causing the "temporary suspension" of the currently executing program. ✓ It causes a "branch" (Pileup) to a sub-program called an interrupt routine (or the dealing of interrupt). ✓ Therefore, a return (IRET) is necessary to continue the execution of the suspended program. Main Program Routine interruption 2 1 START START INT 3 Instruction 1 Instruction 1 INT Interruption Instruction 2 Instruction 2 INT Execution Instruction 3 Instruction 3 INT Return IRET 5 Instruction 4 END INT Instruction 5 Continue Instruction 6 4 END THE INTERRUPTIONS INTERRUPTION CLASSES 1. Material interrupts : (Interrupt ReQuest ou IRQ), they are caused by external events (Input/Output peripherals via electrical signals) INTR : INTerrupt Request NMI : Non Maskable Interrupt (Depends on IF Flag) (Does not depend on IF Flag) ‘’0:masked, 1: armed’’ NMI Control bus CPU INTR INTA INTA : Acknowledgement of receipt THE INTERRUPTIONS INTERRUPTION CLASSES 2. Software interrupts : They are caused either by special instructions in the instruction set or by logical and exceptional conditions in the microprocessor itself. THE INTERRUPTIONS Main program 2 Interrupt routine 1 START START INT 3 Instruction 1 CS:IP Instruction 1 INT Interruption Instruction 2 Instruction 2 INT Execution Instruction 3 Instruction 3 INT Return IRET 5 Instruction 4 END INT Instruction 5 4 Continue Instruction 6 END THE INTERRUPTIONS INTERRUPTION VECTOR TABLE T 0000:0000 𝐼𝑃0 Vector 0 : IT division by zero error A 𝐶𝑆0 0000:0004 𝐼𝑃1 5 vectors Reserved B Vector 1 : IT step-by-step execution 𝐶𝑆1 in the CPU at L 0000:0008 𝐼𝑃2 its delivery Vector 2 : IT NMI (Reserved by Intel) E 𝐶𝑆2 0000:000C 𝐼𝑃3 D Vector 3 : IT insert breakpoint 𝐶𝑆3 E 0000:0010 𝐼𝑃4 Size (TVI) Vector 4 : IT Overflow = S 𝐶𝑆4 1 KBytes 0000:0014 𝐼𝑃5 V Vector 5 : IT Print Screen 𝐶𝑆5 E 251 vectors some are C Defined by the OS 0000:0020 𝐼𝑃8 and others are free Vector 8 : IT Timer T 𝐶𝑆8 E 0000:0024 𝐼𝑃9 Vector 9 : IT Kyboard 𝐶𝑆9 U R 0000:03FC 𝐼𝑃255 S Vector 255 𝐶𝑆255 LES INTERRUPTIONS Hardware Interrupts Recap! Case 1 : NMI Case 2 : INTR THE INTERRUPTIONS Software interrupts Software interrupts : They are caused either by special instructions in the instruction set or by logical and exceptional conditions in the microprocessor itself. ✓ Calling a software interrupt n° N → SYNTAXE : INT N IF=0, TF=0 Stack (SS) 𝑰𝑷𝒓𝒐𝒖𝒕𝒊𝒏𝒆 = [𝑵 × 𝟒] Main Program 𝑪𝑺𝒓𝒐𝒖𝒕𝒊𝒏𝒆 = [(𝑵 × 𝟒) + 𝟐] IP(Return=Inst5) SP= SP-6 CS:IP Instruction 1 CS:IP Instruction 2 CS(Return_Inst5) SP= SP-4 CS:IP Instruction 3 PSW SP= SP-2 CS:IP INT N CS:IP Instruction 5 SP CS:IP Instruction 6 NOTE : N is 8-bits between 00H and FFH (0 à 255) ! THE INTERRUPTIONS Main Program Interrupt Routine CS:IP Instruction 1 START INT 𝐶𝑆𝑟𝑜𝑢𝑡 : 𝐼𝑃𝑟𝑜𝑢𝑡 Instruction 1 INT CS:IP Instruction 2 Instruction 2 INT CS:IP Instruction 3 Instruction 3 INT CS:IP INT N IRET 𝐶𝑆𝑅 :𝐼𝑃𝑅 Instruction 5 END INT IF=0, TF=0 𝑰𝑷𝑵 = 𝑰𝑷𝑹 𝑰𝑷𝒓𝒐𝒖𝒕𝒊𝒏𝒆 = [𝑵 × 𝟒] 𝑪𝑺𝑵 = 𝑪𝑺𝑹 After INT N After IRET 𝑪𝑺𝒓𝒐𝒖𝒕𝒊𝒏𝒆 = [(𝑵 × 𝟒) + 𝟐] 𝑷𝑺𝑾 = 𝑷𝑺𝑾 Empiler 𝐼𝑃𝑅 SP= SP-6 𝐼𝑃𝑅 SP= SP-6 𝐶𝑆𝑅 SP= SP-4 𝐶𝑆𝑅 SP= SP-4 PSW SP= SP-2 PSW SP= SP-2 SP SP Dépiler THE INTERRUPTIONS SOFTWARE INTERRUPTS THE INTERRUPTIONS SOFTWARE INTERRUPTS THE INTERRUPTIONS THE INTERRUPT 21H This is a very long interrupt routine sometimes called SYSTEM INTERRUPT, it offers several services. Each service is a function whose number must first be sent to the AH register before calling this interrupt. Main program... MOV AH, N°_Function INT 21H.. THE INTERRUPTIONS Structure of the 21H interrupt routine Main Program... MOV AH, N°_Function INT 21H.. THE INTERRUPTIONS Some services of 21H #service Service 01H LECTURE D'UN CARACTERE AU CLAVIER AVEC ECHO 02H ECRITURE D'UN CARACTERE A L'ECRAN 05H ENVOI D’UN CARACTERE A L’IMPRIMANTE 08H LECTURE D'UN CARACTERE SANS ECHO AU CLAVIER 09H AFFICHAGE D'UNE CHAINE DE CARACTERS A L'ECRAN 0AH LECTURE D'UNE CHAINE DE CARACTERS AU CLAVIER 25H INSTALLATION D'UN VECTEUR D'INTERRUPTION 35H LECTURE D'UN VECTEUR D'INTERRUPTION https://www.gladir.com/LEXIQUE/INTR/INT21.HTM THE INTERRUPTIONS Programme Principal. AH=01H (LECTURE D'UN CARACTERE AU CLAVIER AVEC ECHO). Input : 01H MOV AH, 01H Output: AL= Caractère lu INT 21H.. Programme Principal AH=02H (ECRITURE D'UN CARACTERE A L'ECRAN). Input : 02H, DL= Caractère à écrire. Output : Rien MOV AH, 02H MOV DL,42H INT 21H. 42H (Code ASCII de ‘’B’’. THE INTERRUPTIONS AH=09H (AFFICHAGE D'UNE CHAINE DE CARACTERS A L'ECRAN) INPUT : AH=09H DS:DX ADRESSE DU 1er CARACTERE DE LA CHAINE A AFFICHER (la chaîne de caractères doit se terminer par ‘’$’’) OUTPUT : RIEN THE INTERRUPTIONS AH=25H (INSTALLATION D'UN VECTEUR D'INTERRUPTION) INPUT : AH=25H AL= NUMERO D'INTERRUPTION DS:DX ADRESSE DE LA PREMIERE INSTRUCTION DE LA ROUTINE D'INTERRUPTION OUTPUT : RIEN Example : (Exercise 1 de la série) Show using interrupt 21H how to install interrupt Installer program vector number 93H corresponding to the interrupt routine that is loaded into central memory at address 789A:0102 MOV AX, CS(Routine_N) MOV DS, AX Solution : MOV DX, IP(Routine_N) MOV AX, 789AH MOV AL,Num_IT MOV DS, AX MOV AH, 25H MOV DX, 0102H INT 21H MOV AL, 93H MOV AH,25H INT 21H THE INTERRUPTIONS THE INTERRUPT 1CH THE INTERRUPTIONS DIVERTING AN INTERRUPTION Le déroutement de l'interruption numéro N consiste à conserver le numéro de l'interruption N et donc la conservation de l'adresse du vecteur N (i.e 4 x N) et le changement du contenu de ce vecteur (i.e (4 x N) et (4 x N + 2)). En d'autres termes ceci consiste à conserver le numéro de l'interruption et changer son traitement THE INTERRUPTIONS DIVERTING AN INTERRUPTION Le déroutement de l'interruption numéro N consiste à conserver le numéro de l'interruption N et donc la conservation de l'adresse du vecteur N (i.e 4 x N) et le changement du contenu de ce vecteur (i.e (4 x N) et (4 x N + 2)). En d'autres termes ceci consiste à conserver le numéro de l'interruption et changer son traitement Example : (Exercise 3 de la série) Ecrire une séquence d’instructions qui permet de dérouter l’interruption 1CH sur une routine d’interruption vide. ; code routine d'IT 1CH new: IRET ; déroutement de la routine d'IT 1CH MOV AX, seg new MOV DS, AX MOV DX, offset new MOV AX, 251CH INT 21H INPUTS/OUTPUTS LES ENTREES /SORTIES (E/S ou I/O) Input /Output: Input/Output operations allow the exchange of data between the microprocessor and peripherals through input/output interface circuits (I/O controllers). Interface circuit (C.I): It is an intelligent and programmable circuit, it is specific to a particular type of device. Its main function is to allow the exchange of data between the microprocessor and a given type of device and also to control this transfer. Characteristics of ICs: ✓ Intelligent: involves several operating modes ✓ Programmable: This means that each of the operating modes is obtained by simple instructions (coding) LES ENTREES /SORTIES (E/S ou I/O) LES ENTREES/SORTIES (E/S ou I/O) ✓ The processor considers an interface circuit as a set of registers called I/O ports, and each port is characterized by an address. In general, there are four types of ports: TYPES OF I/O OPERATIONS IN : to read from PORT OUT: to write in the PORT LES INTERRUPTIONS TYPES OF OPERATIONS I/O Instruction Form Transfer Syntax Description Long form Byte (1 octet) IN AL, Adr AL [Adr] Long form Word (2 octets) IN AX, Adr AX [Adr+1]:[Adr] IN Short form Byte (1 octet) IN AL, DX AL [DX] Short form Word (2 octets) IN AX, DX AX [DX+1]:[DX] Instruction Form Transfer Syntax Description Long form Byte (1 octet) OUT Adr, AL [Adr] AL Long form Word (2 octets) OUT Adr, AX [Adr+1]:[Adr] AX OUT Short form Byte (1 octet) OUT DX, AL [DX] AL Short form Word (2 octets) OUT DX, AX [DX+1]:[DX] AX Instruction Form Transfer Syntax Description Long form Byte (1 octet) IN AL, Adr AL [Adr] Long form Word (2 octets) IN AX, Adr AX [Adr+1]:[Adr] IN Short form Byte (1 octet) IN AL, DX AL [DX] Short form Word (2 octets) IN AX, DX AX [DX+1]:[DX] 58H IN AL, 60H 59H 60H 00001111 AL=00001111 61H Instruction Form Transfer Syntax Description Long form Byte (1 octet) IN AL, Adr AL [Adr] Long form Word (2 octets) IN AX, Adr AX [Adr+1]:[Adr] IN Short form Byte (1 octet) IN AL, DX AL [DX] Short form Word (2 octets) IN AX, DX AX [DX+1]:[DX] 58H IN AX, 60H 59H 60H 00001111 AX=1111111100001111 61H 11111111 AH AL Instruction Form Transfer Syntax Description Long form Byte (1 octet) IN AL, Adr AL [Adr] Long form Word (2 octets) IN AX, Adr AX [Adr+1]:[Adr] IN Short form Byte (1 octet) IN AL, DX AL [DX] Short form Word (2 octets) IN AX, DX AX [DX+1]:[DX] MOV DX, 1234H 1232H IN AL, DX 1233H 1234H 00001111 1235H AL=00001111 Instruction Form Transfer Syntax Description Long form Byte (1 octet) IN AL, Adr AL [Adr] Long form Word (2 octets) IN AX, Adr AX [Adr+1]:[Adr] IN Short form Byte (1 octet) IN AL, DX AL [DX] Short form Word (2 octets) IN AX, DX AX [DX+1]:[DX] MOV DX, 1234H 1232H IN AX, DX 1233H 1234H 00001111 AX=1111111100001111 1235H 11111111 AH AL Instruction Form Transfer Syntax Description Long form Byte (1 octet) OUT Adr, AL [Adr] AL Long form Word (2 octets) OUT Adr, AX [Adr+1]:[Adr] AX OUT Short form Byte (1 octet) OUT DX, AL [DX] AL Short form Word (2 octets) OUT DX, AX [DX+1]:[DX] AX 58H MOV AL, 00001111 59H 00001111 60H OUT 59H, AL 61H Instruction Form Transfer Syntax Description Long form Byte (1 octet) OUT Adr, AL [Adr] AL Long form Word (2 octets) OUT Adr, AX [Adr+1]:[Adr] AX OUT Short form Byte (1 octet) OUT DX, AL [DX] AL Short form Word (2 octets) OUT DX, AX [DX+1]:[DX] AX AH AL 58H MOV AX, 1111111100001111 59H 00001111 60H 11111111 OUT 59H, AX 61H Instruction Form Transfer Syntax Description Long form Byte (1 octet) OUT Adr, AL [Adr] AL Long form Word (2 octets) OUT Adr, AX [Adr+1]:[Adr] AX OUT Short form Byte (1 octet) OUT DX, AL [DX] AL Short form Word (2 octets) OUT DX, AX [DX+1]:[DX] AX 0FFFH MOV AL, 00001111 1000H 00001111 MOV DX, 1000H 1001H OUT DX, AL 1002H Instruction Form Transfer Syntax Description Long form Byte (1 octet) OUT Adr, AL [Adr] AL Long form Word (2 octets) OUT Adr, AX [Adr+1]:[Adr] AX OUT Short form Byte (1 octet) OUT DX, AL [DX] AL Short form Word (2 octets) OUT DX, AX [DX+1]:[DX] AX AH AL 0FFFH MOV AX, 1111111100001111 1000H 00001111 1001H 11111111 1002H MOV DX, 1000H OUT DX, AX TYPES OF I/O OPERATIONS Example Écrire un programme en assembleur qui lit le bit d'état 𝐵0 d'un interrupteur connecté à un port d'état d’adresse 05H et allume une LED connectée à un port de sortie d’adresse 08H si l'interrupteur est enfoncé. (LED est allumée si 𝐵0 =1 et son port de sortie = FFH, sinon 00H) Solution Vérifier : IN AL, 05H (Lire le port d’état) TEST AL, 01 JZ Eteindre MOV AL, FFH OUT 08H, AL (Ecrire sur le port de sortie) JMP Vérifier Eteindre : MOV AL, 00H OUT 08H, AL (Ecrire sur le port de sortie) JMP Vérifier TYPES OF I/O OPERATIONS TYPES OF I/O OPERATIONS TYPES OF I/O OPERATIONS