简体   繁体   中英

Slowing down a program (in c and assembly) using interrupts

I want to slow down a program using interrupts according to these conditions :

  • if I press the up arrrow on the keyboard the speed will increase
  • if I press the down arrow on the keyboard the speed will decrease

I want to do it by using interrupts : if the speed should decrease I will mask more interrupts and if the speed should increase I will unmask interrupts.
I know how to reach to the keyboard interrupt and to mask and unmask interrupts.
I just don't know how to reach the program speed. I am writing the code in c and assembly.

One thing you can do is to intercept one of the interrupts such as the BIOS clock tick int 08h or (better) MS-DOS int 1Ch handler called at about 18 hertz. Then add time-wasting loops based on a variable that is controlled by certain keyboard events.

Make sure you re-enable interrupts before each delay.

At the end of the program you are responsible for restoring the original interrupt vector.

You can't speed a program up faster than its starting speed without adjusting the emulation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM