Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microprocessor and Assembly Language

Similar presentations


Presentation on theme: "Microprocessor and Assembly Language"— Presentation transcript:

1 Microprocessor and Assembly Language
Lecture-12-Animation with Timer Interrupt Muhammad Hafeez Department of Computer Science GC University Lahore

2 Today’s Agenda User Interrupt Procedures
Animation using Timer Interrupt

3 Moving Objects in a Game
Game’s objects can be moved by displaying an object, erasing it and then displaying it at another new place CPU speed it fast that we cannot see the movement of object or cannot produce appropriate delays One way to approach this kind of task is to write loops Can you write one ?

4 User Interrupt Procedure
A better approach is to write a routine for BIOS INT 1CH that is called by another BIOS INT 08h that is triggered by hardware and ticked by a timer circuit on your IBM machine every 18.2 seconds. INT 08H always executes INT 1CH instructions before it returns (IRET) Never overwrite existing ISR of 1CH with your own code, it will crash the system However, there is a way…

5 User Interrupt Procedure
A better approach is to write a routine for BIOS INT 1CH that is called by another BIOS INT 08h that is triggered by hardware and ticked by a timer circuit on your IBM machine every 18.2 seconds. INT 08H always executes INT 1CH instructions before it returns (IRET) Never write code on existing ISR as it will crash the system However, Interrupt Procedure can be written while saving the existing ISR address from vector table and then load IVT with user interrupt procedure

6 User Interrupt Procedure
How can we store the existing address of interrupt??

7 Get Interrupt Vector Obtain interrupt vector from vector table INPUT:
AH = 35H AL = INTERRUPT NUMBER OUTPUT: ES:BX (INTERRUPT VECTOR)

8 Set Interrupt Vector Store interrupt vector into vector table INPUT:
AH = 25H AL = INTERRUPT NUMBER DS:DX INTERRUPT VECTOR OUTPUT: NONE

9 Writing user Interrupt Procedure
We can write the code for user interrupt in a separate procedure This procedure must end with IRET instead of RET instruction As this interrupt procedure will be called using IVT so it does not know the location of Data Segment (DS) Hence, if any variable needs to be used in this user interrupt procedure the DS needs to be set before using that variable

10 Call User Interrupt Procedure in User Program
User interrupt procedure that is a function written in user current code segment needs to loaded in IVT For that we have to have IP and CS of under interrupt procedure to be replaced in IVT

11 Seg and Offset Pseudo-ops
It has been used as to get the offset address of data segment variable, it can also be used to get offset address of procedure where the code is written SEG: This pseudo-op can be used to get segment address of user procedure

12 Seg and Offset Pseudo-ops
It has been used as to get the offset address of data segment variable, it can also be used to get offset address of procedure where the code is written SEG: This pseudo-op can be used to get segment address of user procedure


Download ppt "Microprocessor and Assembly Language"

Similar presentations


Ads by Google