Presentation is loading. Please wait.

Presentation is loading. Please wait.

Assembly Language Lecture 21-23 Presented By Shery khan 10:00 to 11:00

Similar presentations

Presentation on theme: "Assembly Language Lecture 21-23 Presented By Shery khan 10:00 to 11:00"— Presentation transcript:

1 Assembly Language Lecture Presented By Shery khan 10:00 to 11:00

2 Agenda ► What are interrupts? ► What are types of Interrupts? ► Working of Interrupts? ► Software & Hardware Interrupt? ► Hooking An Interrupts? ► Bios & dos Interrupts? ► Hardware Interrupts? ► Example…..

3 What are interrupts? What are interrupts? ► INT are ASYNCHOROUS & Unpredictable ► Current State of Processor or Working is Not Disturbed or Currently Executing Instruction ► Asynchronous mean which point of instruction were instruction is Executed. ► Un predictable : means at which time interrupt will come ► IN Generally : the event that occur outside the processor and the processor must be informed

4 What are types of Interrupts? ► 8088 processor divides it in two major classes ► Software Interrupts ► Hardware Interrupts Hardware INT: Generated by External world Software INT: Not Generated by External world they are just Extended Far Call Extended Far Call: Push Segment+offset+Flag

5 Continue: ► Why Flag is Saved ? ► Sunario is That let suppose I want to Compare two instruction and Then Jump but in between Interrupt comes here comparison is done but not performed Jump instead processor now execute interrupt routine now there Flag registers are changed now I return on actual instruction ► Here the Jump will be the Instruction but Jump will not be legal because Flags are Changed in Interrupt routine. So to avoid this we save Flags.

6 IVT ► When ever Interrupt comes some operation is done in arrival of Interruption ► So the Relation between Interrupt and Operation is performed on the basis of Interrupt vector table ► Boiler Example like that When Temperature Increases The Interrupt Signal is Invoked and Processor Will read this Interruption and do some operation to reduce the Heat of Boiler. So Arrival of Interrupt Processor take Action

7 ISR/HOOK ► So every Interrupt we can made we can build a routine in relation with interrupt which we can called as Interrupt Service Routine.or we say the Mechanism for Interrupt to served is called ISR ► The Co-Relationship between Interrupt and Interrupt service routine is Generally called HOOKING

8 Syntax ► INT n ► Here we use Int key word with num in byte ► INT ► Number tells us which Interrupt is used to achieve the respective results ► INT opcode is CD and the Num is Co-related to Interrupt to route the service routine(ISR) ► IT IS 2 BYTE

9 RESERVED INTERRUPTS ► Generally we do not use these Reserved INT ► Because these are related to processor Like INT 0 is divide by zero Int Like INT 0 is divide by zero Int Such interrupts are programmed in the hardware to generate the designated interrupts when specific condition arises Such interrupts are programmed in the hardware to generate the designated interrupts when specific condition arises

10 Co-relation INT & Num ► We use a Table IVT ► IVT Location is Fixed to Physical Memory address zero ► Each Entry of Table is four Byte long contain the segment & offset of Interrupt routine for corresponding interrupt Number ► First two byte Contain Offset ► Next Two Segment

11 Continue ► Mathematically offset of the Interrupt n will be n*4 while segment will be n*4+2 ► One entry in this table is called Vector ► So Here vector for INT 0 ► Is 0*4=4 ► Int 0 ► 0,1,2,3 Colored Vectors are offset ► 2,3 is Segment

12 continue ► INT 1 1*4=4 So 4,5,6,7 ► INT 2 ► 2*4=8 ► So 8,9,10,11 ► Int 3 ► 2*3= ?question ► respectively

13 Working of INT ► First Push the Flag Register ► Secondly Push the CS Segment Register ► Then IP is Pushed to Stack ► Here two flags Automatically IF=0,TF=0 ► So the other Up coming Interrupts are Disable When One is In IVT Table so First come First Served Basis Other are Not allowed Disabled

14 continue ► After these step the ISR is Called and Control goes to Interrupt service Routine ► For Returning from this Routine Use iret

15 Story ► When An interrupt arrived Processor take Action and go to IVT table and Call the Routine after Some Specific Operation it Return and How it can Return we Use IRET ► iRet for this Purpose ► Iret is Working Reverse first ► POP the IP into Ip ► Pop the CS ► POP the Flag

16 Why we not use Ret Far instead of Iret??? ► Ret Far not use it is used when we use Call far ► And Ret Far take 2 words IP,Cs leave the Flag ► So we Can use IRET

17 Working Int N ► Push flag ► IF ► TF ► Push cs ► IP [0:4*n] offset ► Cs [0:4*n+2] Segment ► ISR Execute 0 0

18 Iret ► Ip ► SP sp+2 ► Cs [ss:sp] ► Sp +2 ► Flag [ss:sp] ► Sp sp+2 ► Control return to Next instruction which is pointed by IP [ss:sp]

19 Example

20 Example

21 Example

22 Example

23 Example

24 Example

25 Example

26 Example

27 Lecture 22 ► For Example ► BOOK with its Content in Start Like ► Chapter 4 started from Page 240 ► Here Page 240 is Vector and Chapter 2 is Interrupt so the Processor go the page 240 Not 220 so in IVT has 256 chapter and Interrupt mechanism look up appropriate chapter num to read the desire page and find the Interrupt routine

28 VECTOR TABLE ► In table Content are Fixed always placed at the start of book so same case the Vector table position is fixed zero for IVT and occupy exactly 1 kilo byte of memory ► 256*4=1kb 256 is num of possible interrupts while size of one vector is 4 byte

29 IVT

30 Software / Hardware INT ► Software Interrupt Break the program flow ► Un programmed interruption is Hardware Int Reserved Interrupts of 8088 INT 0 INT 1 INT 2,INT 3,INT 4 These Five Interrupts are automatically tied with processor

31 INT 0 ► Is Same as when we Divide by 0 ► We know that when quotient did not fit in the destination register let say div Bl ► Quotient in AL ► Reminder Ah Divide Overflow ► System automatically call INT 0 Invoke when Divide Overflow

32 INT 1 (TRAP FLAG) ► Debugger Pressed F1 ► Trap Flag INT 1 Invoked ► F1 ► Trap Flag INT 1 Invoked ► Its set Trap flag and Disable other Interruption it is automatically generated after every instruction. ► Used for single stepping it is working like that sir one Instruction is executed now tell me what I can do it is working like that sir one Instruction is executed now tell me what I can do

33 INT 2 (NMI) ► Non Mask able Interrupt Real interrupt Comes Outside the processor ► Two Pins in the processor INT Pin & NMI PIN ► INT Pin Processor can be directed to lesson or not to listen ► NMI PIN tells about Fetal hardware Failure in the System ► Int Pin Can be Masked or ignored ► NMI pin Cannot be Masked ► Like Castrophic (Natural Disaster ) Comes and Processor must Listen and do Some Operation

34 INT 3 Debug Interrupt ► Single byte Opcode CC ► Replace any Instruction with Break Point ► It is Software Interrupt ► Detail is in Debugger Topic

35 INT 4 (Arithmetic Overflow) Change of Sign Bit ► It is Invoked when Unexpectedly sign Bit is Changed as a result of mathematical or logical instruction ► Overflow Flag signals a real overflow only if the number is treated as signed Number ► Not Automatically generated But as a Result of Special Instruction INTO (Interrupt on Overflow) if overflow flag is Set otherwise INTO behave as NO Operation (NOP) ► Review of OVERFLOW FLAG: ► Overflow flag is set during signed Arithmetic e.g ► addition or subtraction When the when the sign of destination changes Unexpectedly


37 Lecture 23 INTERRUPTS

38 BIOS And DOS Interrupts ► Bios provide Basic Building Block and DOS /OS Work on it & provide different Interfaces ► BIOS (basic Input output Services) ► When Computer is Switch on BIOS get control to a specified address ► For Booting Some Hardware Tests (Key Board, Hard drive etc) Are performed Boot time on screen giving BIOS Version, Detecting Basic Hardware.and then BOOT strap mean that Load OS from Hard disk & from there OS take Control & process to load its Components and Display a Command Prompt in the End

39 Continue ► There are two important programs OS & BIOS ► OS services are high level and Work on Bios ► Bios Services are Low level ► Direct Controlling the hardware is Further Low Level ► WE USE VIDEO By direct controlling Video Memory By passing BIOS

40 BIOS SERVICES ► BIOS services are Optionally with us.if we do not use there is no limitation on us we go & By Pass these Layer and access Hardware directly ► Sometime Bios Did Not Provide Some Sort of Services So we By Pass BIOS layer DOS Layer and Straightly go to Hardware

41 USELESS ► If BIOS did not Communicate With our program it is Useless so there Must some Mechanism way to communicate ► So we use INTERRUPT MECHANISM Interrupts Provide a standard interrupt Num for Caller & Flexibility to place A routine Anywhere in the Memory So INT 10 Video Services INT 16 Keyboard Services So Manufacturer place Code where ever he want and Service are exported

42 BIOS/ DOS SERVICES ► Keyboard Services are Exported through INT 16 ► Parallel Port Services Through INT 17 ► DOS has Single Entry point Through INT 21 ► The Sub services Concept Lies here Every Service Number has Further Sub Services ► Like INT 10 (VIDEO SERVICES) ► 00 For Video ► 01 for Set cursor size ► ……

43 BIOS SERVICES ► Services Num Is Usually given in AH Register While Sub service Num is In AL or BL BIOS INTERRUPT SERVICES: INT 0x10 Video Service INT 0x13 Disk Service INT 0x14 Serial Port Service INT 0x16 Key board Service INT 0x17 Parallel Port Service INT 0x1A Time & Date Service

44 0x10 Video SUB SERVICES ► 0x00 Video Mem ► 0x01 Set Cursor Size ► 0x02 Set Cursor Position ► 0x06 Scroll Screen Up ► 0x07 Scroll Screen Down ► 0x13 Write Character String

45 Example Cursor Screen Up 0x06 sub service


Download ppt "Assembly Language Lecture 21-23 Presented By Shery khan 10:00 to 11:00"

Similar presentations

Ads by Google