130 likes | 226 Vues
Learn how interrupts streamline programming by automating tasks. Explore software interrupts for hardware interactions. Practice writing interrupt codes for user inputs and outputs. Discover the versatility of AH register.
E N D
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed
Interrupts • Interrupts can be seen as a number of functions. • These functions make the programming much easier • Instead of writing a code to print a character you can simply call the interrupt and it will do everything for you. • There are also interrupt functions that work with disk drive and other hardware. • We call such functions software interrupts.
Interrupts • where value can be a number between 0 to 255 (or 0 to 0FFh), generally we will use hexadecimal numbers. • You may think that there are only 256 functions, but that is not correct. Each interrupt may have sub-functions. • To specify a sub-function AH register should be set before calling interrupt. • Each interrupt may have up to 256 sub-functions (so we get 256 * 256 = 65536 functions). • In general AH register is used, but sometimes other registers maybe in use.
Interrupts • Interrupts are also triggered by different hardware, these are called hardware interrupts. • Currently we are interested in software interrupts only. • To make a software interrupt there is an INT instruction • it has very simple syntax: • INT value
INT 21H • INT 21H may be used to invoke a large number of DOS functions • A particular number of interrupt in AH register
INT 21H • INT 21H function expect input value in a certain register and return output in a certain register e.g. • MOV Ah,1 • INT 21H • Take a character as input and put the ASCII in AL register • It will put 0 in AL if non character key is pressed
INT 21H • display the character ’a’ on the screen: • mov dl, ‘a‘ ; dl = ‘a‘ • mov ah, 2h ; character output subprogram • int 21h ; call ms-dos output character • Student Exercise: Write a code that takes one character input from user, and display 2 times on screen.
INT 21H • String Function • AH contain 9 • Inputs: DX= offset address of string • The String must end with $ character • E.g • Msg DB ‘Hello!$’ • LEA DX, Msg • Mov AH,9 • INT 21H • Output: Hello!
LEA Instruction • Load Effective Address • LEA Destination, Source • It get offset address of source and put it into destination register • E.g • LEA DX, Msg • Put offset of Msg in DX register
Control Function • DL contain ASCII code of control character • INT 21H cause control function to be performed
Student Assignment • Multiplication of 3x3 Matrics • Dead Line Next Week 1st Class