Docsity

CS401 Assembly Language Programming, Lecture notes of Assembly Language Programming

Toggle sidebar
bg1
Software Interrupts
8.1. INTERRUPTS
Interrupts in reality are events that occurred outside the processor and the
processor must be informed about them. Interrupts are asynchronous and
unpredictable. Asynchronous means that the interrupts occur, independent
of the working of the processor, i.e. independent of the instruction currently
executing. Synchronous events are those that occur side by side with
another activity. Interrupts must be asynchronous as they are generated by
the external world which is unaware of the happenings inside the processor.
True interrupts that occur in real time are asynchronous with the execution.
Also it is unpredictable at which time an interrupt will come. The two
concepts of being unpredictable and asynchronous are overlapping.
Unpredictable means the time at which an interrupt will come cannot be
predicted, while asynchronous means that the interrupt has nothing to do
with the currently executing instruction and the current state of the
processor.
The 8088 processor divides interrupts into two classes. Software interrupts
and hardware interrupts. Hardware interrupts are the real interrupts
generated by the external world as discussed above. Software interrupts on
the contrary are not generated from outside the processor. They just provide
an extended far call mechanism. Far call allows us to jump anywhere in the
whole megabyte of memory. To return from the target we place both the
segment and offset on the stack. Software interrupts show a similar
behavior. It however pushes one more thing before both the segment and
offset and that is the FLAGS register. Just like the far call loads new values
in CS and IP, the interrupt call loads new values in CS, IP, and FLAGS.
Therefore the only way to retain the value of original FLAGS register is to
push and pop as part of interrupt call and return instructions. Pushing and
popping inside the routine will not work as the routine started with an
already tampered value.
The discussion of real time interrupts is deferred till the next chapter. They
play the critical part in control applications where external hardware must
be control and events and changes therein must be appropriately responded
by the processor. To generate an interrupt the INT instruction is used. The
routine that executes in response to an INT instruction is called the interrupt
service routine (ISR) or the interrupt handler. Taking example from real time
interrupts the routine to instruct an external hardware to close the valve of a
boiler in response to an interrupt from the pressure sensor is an interrupt
routine.
The software interrupt mechanism in 8088 uses vectored interrupts
meaning that the address of the interrupt routine is not directly mentioned
in an interrupt call, rather the address is lookup up from a table. 8088
provides a mechanism for mapping interrupts to interrupt handlers.
Introducing a new entry in this mapping table is called hooking an interrupt.
Syntax of the INT instruction is very simple. It takes a single byte
argument varying from 0-255. This is the interrupt number informing the
processor, which interrupt is currently of interest. This number correlates to
pf2

Partial preview of the text

Download CS401 Assembly Language Programming and more Lecture notes Assembly Language Programming in PDF only on Docsity!

Software Interrupts

8.1. INTERRUPTS Interrupts in reality are events that occurred outside the processor and the processor must be informed about them. Interrupts are asynchronous and unpredictable. Asynchronous means that the interrupts occur, independent of the working of the processor, i.e. independent of the instruction currently executing. Synchronous events are those that occur side by side with another activity. Interrupts must be asynchronous as they are generated by the external world which is unaware of the happenings inside the processor. True interrupts that occur in real time are asynchronous with the execution. Also it is unpredictable at which time an interrupt will come. The two concepts of being unpredictable and asynchronous are overlapping. Unpredictable means the time at which an interrupt will come cannot be predicted, while asynchronous means that the interrupt has nothing to do with the currently executing instruction and the current state of the processor. The 8088 processor divides interrupts into two classes. Software interrupts and hardware interrupts. Hardware interrupts are the real interrupts generated by the external world as discussed above. Software interrupts on the contrary are not generated from outside the processor. They just provide an extended far call mechanism. Far call allows us to jump anywhere in the whole megabyte of memory. To return from the target we place both the segment and offset on the stack. Software interrupts show a similar behavior. It however pushes one more thing before both the segment and offset and that is the FLAGS register. Just like the far call loads new values in CS and IP, the interrupt call loads new values in CS, IP, and FLAGS. Therefore the only way to retain the value of original FLAGS register is to push and pop as part of interrupt call and return instructions. Pushing and popping inside the routine will not work as the routine started with an already tampered value. The discussion of real time interrupts is deferred till the next chapter. They play the critical part in control applications where external hardware must be control and events and changes therein must be appropriately responded by the processor. To generate an interrupt the INT instruction is used. The routine that executes in response to an INT instruction is called the interrupt service routine (ISR) or the interrupt handler. Taking example from real time interrupts the routine to instruct an external hardware to close the valve of a boiler in response to an interrupt from the pressure sensor is an interrupt routine. The software interrupt mechanism in 8088 uses vectored interrupts meaning that the address of the interrupt routine is not directly mentioned in an interrupt call, rather the address is lookup up from a table. 8088 provides a mechanism for mapping interrupts to interrupt handlers. Introducing a new entry in this mapping table is called hooking an interrupt. Syntax of the INT instruction is very simple. It takes a single byte argument varying from 0-255. This is the interrupt number informing the processor, which interrupt is currently of interest. This number correlates to

the interrupt handler routine by a routing or vectoring mechanism. A few interrupt numbers in the start are reserved and we generally do not use them. They are related to the processor working. For example INT 0 is the