call INTERRUPT

General FreeBASIC programming questions.
Post Reply
blahboybang
Posts: 385
Joined: Oct 16, 2005 0:15
Location: USA
Contact:

call INTERRUPT

Post by blahboybang »

What happened to the "call interrupt" that existed in qbasic?
blahboybang
Posts: 385
Joined: Oct 16, 2005 0:15
Location: USA
Contact:

Post by blahboybang »

Oh, I get it. Interrupts are done in assembly, qbasic just put it in a function form to make it easier. Does anyone know how to make a similar interrupt function?
jofers
Posts: 1525
Joined: May 27, 2005 17:18

Post by jofers »

No. Windows and Linux place limits on the amount of hardware access you have, so you can't just, say, stick a keyboard TSR on there.

Instead, you have dynamically loadable libraries and function pointers. Check out the "DyLibLoad" and "DyLibSymbol" functions. You can also "thread" functions so they run in the background and can poll events.
blahboybang
Posts: 385
Joined: Oct 16, 2005 0:15
Location: USA
Contact:

Post by blahboybang »

Is there a library that allows an interrupt call, or a such function in the windows api?
Fragmeister
Posts: 545
Joined: Nov 08, 2005 14:36

Post by Fragmeister »

what exactly is it that you're trying to do?
1000101
Posts: 2556
Joined: Jun 13, 2005 23:14
Location: SK, Canada

Post by 1000101 »

For all intents and purposes, interrupts don't exist in win32/linux/dos32. They do, but only at the hardware level software (ring 0), not at the user-level software (ring 3). You are several layers of accessability to high.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Post by MichaelW »

With the DOS32 version of FreeBASIC you can call interrupts using an interface that is very similar to that of the InterruptX routine for QuickBASIC. This is one of the examples from Version 0.13 Beta:

Code: Select all

''
'' simple DOS graphics example to demonstrate DOS-specific features
''

Option Explicit

#include "dos/dpmi.bi"
#include "dos/go32.bi"
#include "dos/sys/farptr.bi"


Dim regs As __dpmi_regs

Dim buffer(320 * 200 - 1) As UByte

Dim i As Integer


' set VGA mode 13h
'  320x200x8bpp
'  chain4 (linear)

regs.x.ax = &H13
__dpmi_int(&H10, @regs)

Do While Len(InKey) = 0
	
	__dpmi_yield
	
	For i = @buffer(0) To @buffer(320 * 200 - 1)
		Poke i, Int(Rnd * 256)
	Next i
	
	dosmemput @buffer(0), 320 * 200, &HA0000
	
Loop

' set a standard text mode
regs.x.ax = &H03
__dpmi_int(&H10, @regs)
Within limits, these interrupt calls will work under Windows.
Antoni
Posts: 1393
Joined: May 27, 2005 15:40
Location: Barcelona, Spain

Post by Antoni »

Interrupts exist only in DOS, so they are not portable, so they are out of FB.

Non-portable things must be achieved thru external libraries, as MichaelW's example shows.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Post by D.J.Peters »

Interrupt services are exist on both win and lin many C calls from runtime libs are "only" stubs in the right service with argument and type checking.
for example the Linux C call open ends in int &80 service in FB inlineassembler looks like this.

Code: Select all

function SYS_OPEN(byval device as string,byval flag as integer=0,byval mode as integer=0) as integer 
asm 
  mov eax, _OPEN 
  mov ebx, [device] 
  mov ecx, [flag] 
  mov edx, [mode] 
  int &H80 
  mov [function],eax 
end asm 
end function 
dim as integer hFile
hFile=open("myfile")
But of course this has nothing to do with 16 bit DOS int's from qbasic.
and i sugest you use the FB runtime (it's the stubs to the C runtime lib) it is more save and compatbile.

Joshy
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Post by MichaelW »

For what little the information may be worth, there is a narrow range of interrupts, starting with interrupt 50h, than can, at least normally, be used from a Windows program running under Windows 98 SE (possibly all Windows 9x, but I tested only 98 SE). The call will not generate a fault, it will be passed down to the normal real mode handler, and an IRET will return control to the Windows program with whatever the handler left in the registers. This will not work for interrupts outside the range, and it will not work for any interrupt under NT/2000/XP.
VirusScanner
Posts: 775
Joined: Jul 01, 2005 18:45

Post by VirusScanner »

For interrupts that you can call, use inline assembly. For example, a debug breakpoint:
asm int 3
Post Reply