How can I make own software interrupts work

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Posts: 3
Joined: Thu Jan 29, 2009 1:57 pm
Location: Germany

How can I make own software interrupts work

Post by Hristic » Thu Jan 29, 2009 2:11 pm

Can anyone tell me how to install an interrupt routine?
It should be executed 10000 times per second. I know
how to include asm into my source, but i want to
execute it in the background.

I hope somebody can help me with my problem.

User avatar
Posts: 97
Joined: Mon Mar 17, 2008 11:14 am
Location: Estonia, Rapla

Post by TmEE » Mon Feb 02, 2009 11:38 am

Set up the system timer and use ON TIMER(1) function of QB. Be sure to restore the state of the timer when you're done...
Mida sa loed ? Nagunii aru ei saa :P

Posts: 185
Joined: Mon Jun 30, 2008 4:10 pm


Post by iamdenteddisk » Fri Feb 06, 2009 5:11 pm

first you need to find a working inturupt source I use inturuptX found on the downloads/utilitys section of petes QB, it you can add as a sub to your programs, it only works with qb4.5 and it's the only routine I have found to work with intell machines under WinXP. now if you are using an inturpreter version of qb then you need the call absolute routine and it you include as a library and qlb file and it is a terrible mess to get to work plus you have to pay for the use of the lib to have the ability to compile and absolute wont work with QB4.5 this only comes from using librarys and I wish you good luck with it.

I prefer the QB4.5 for its built in compiler and support help over the erlier qb or the later Fb there are others who will argue these point's but I myself didn't have such a good experiance with 4.5 untill I found a file called codepage.bas which unlocked it to work correctly. then I was realy free and able to do what I wanted to do.

Good luck with it.
I will look back on this post another time and if you reply that you use qb.45 for sure then I could probably help you further and you can find this out by looking in the qb online help in the editor..

Posts: 11
Joined: Sat May 24, 2008 10:51 pm

Post by Yazar » Wed Mar 04, 2009 7:46 am

if you want to run your code in background using an interrupt;
First you've to find an interrupt that you can replace your code. Then you should set the run time.

For example we insert our code into INTERRUPT 9 and every keyboard action invokes our code. While finishing our program we restore the original code. You must find an interrupt that can be callable 10000 times from system and is not critical. The other way is using ON TIMER which is the best fit for your needs I guess.

To replace your code to an existing interrupt you'll have to find the SEGMENT:OFFSET off the original code, record them and then write your sub codes SEGMENT:OFFSET. The interrupt vector table is at segment 0000... But I don't know how to find a 10000 times callable interrupt. Maybe you should try TSR's...

The INT 9h code's adress is at 0000:0024h. ( 9 * 4 = 36 = 24h )

My_Segment% = VARSEG(Asm$) ' = BSS
My_Offset% = SADD(Asm$)

Old_Offset% = Peek(&H24)
Old_Segment% = Peek(&H26)

'Y O U M U S T D I S A B L E T H E I N T E R R U P T S B Y C L E A R I
'N G T H E I N T E R R U P T F L A G
'Inline asm we use CLI

Poke &H24, My_Offset%
Poke &H26, My_Segment%

'Now enable the interrupts again.
'The 24h and 26h can be vise versa, I mean I don't remember which data
'was first. The segment or offset. But somehow this code shows the right
'addressing I gues...

Your code (main module) should restore the original codes adress to the interrupt vector
table before quitting. And your sub code must send value 20h to port 20h for end inturrupt signal.

Search for an interrupt that runs 10000 times in a second and if doesn't crashes just replace your code. I hope you learn more about interrupts and share them here with us...

User avatar
Posts: 2396
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Fri Mar 06, 2009 2:03 am

We INTERRUPT this thread to say that Yazar is most likely a Forum terrorist with coitus Interruptus on his mind!

God, help us all............, but ON TIMER he may just post something useful.

I never liked any of the ON ..... crap! Sounds too much like GOTO !
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX :
Get my Q-Basics demonstrator: ...

Posts: 185
Joined: Mon Jun 30, 2008 4:10 pm


Post by iamdenteddisk » Tue Mar 10, 2009 7:24 am

I think all methods are valued experiance and I like the "on event" inturupts because it means you can inturupt your code
"emulating threding" qb multitasking? hmmm? - very valuable.

I thought the question was how do inturupts work I guess, I jumped the gun going streight to bios inturupt's. but I though it summed it up well.

Post Reply