MICROPROCESSOR AND ASSEMBLY LANGUAGE LECTURE12 ANIMATION WITH TIMER

MICROPROCESSOR AND ASSEMBLY LANGUAGE LECTURE-12 -ANIMATION WITH TIMER INTERRUPT MUHAMMAD HAFEEZ DEPARTMENT OF COMPUTER SCIENCE GC UNIVERSITY LAHORE

TODAY’S AGENDA l l User Interrupt Procedures Animation using Timer Interrupt

MOVING OBJECTS IN A GAME l l 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 ?

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

USER INTERRUPT PROCEDURE l l A better approach is to write a routine for BIOS INT 1 CH that is called by another BIOS INT 08 h that is triggered by hardware and ticked by a timer circuit on your IBM machine every 18. 2 seconds. INT 08 H always executes INT 1 CH 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

USER INTERRUPT PROCEDURE l l How can we store the existing address of interrupt? ?

GET INTERRUPT VECTOR l l l l Obtain interrupt vector from vector table INPUT: AH = 35 H AL = INTERRUPT NUMBER OUTPUT: ES: BX (INTERRUPT VECTOR)

SET INTERRUPT VECTOR l l l l Store interrupt vector into vector table INPUT: AH = 25 H AL = INTERRUPT NUMBER DS: DX INTERRUPT VECTOR OUTPUT: NONE

WRITING USER INTERRUPT PROCEDURE l l 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

CALL USER INTERRUPT PROCEDURE IN USER PROGRAM l l 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

SEG AND OFFSET PSEUDO-OPS l OFFSET: l l 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: l This pseudo-op can be used to get segment address of user procedure

SEG AND OFFSET PSEUDO-OPS l OFFSET: l l 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: l This pseudo-op can be used to get segment address of user procedure
- Slides: 12