BBS: Inland Empire Archive
Date: 02-03-93 (13:00) Number: 339
From: MARK GRAHAM Refer#: NONE
To: IAN MACLENNAN Recvd: NO
Subj: Help on interrupts. Conf: (2) Quik_Bas
On 02-01-93 Ian Maclennan wrote to All...
IM> I am looking for help on using certain interrupts with
IM> Quickbasic 4.5.
IM> I can use some, but I seem to be unable to acess ones that use such
IM> registers as AH, BH, AL etc.
IM> This is really troubleing me as I am unable to use many interrupts.
No prob. ALL the standard registers (AX, BX, CX, DX) of the 80x86
series are 16 bits (an integer to QB) broken into high byte (AH,
BH, CH, DH) and low byte (AL, BL, CL, DL). The segment registers
(CS, SS, DS, ES), index registers (SI, DI), and alternate stack
pointer (BP) are also 16 bits, but because they are used for
indexing, there is no reason to break them into smaller chunks.
When calling interrupts from QB, a data structure is created from
which the registers are loaded immediately before the interrupt is
called, and to which the registers are saved immediately after
execution of the interrupt.
QB has TWO different interrupt calls, and each has its own data
structure (these are in the include file QB.BI, by the way). The
routine INTERRUPT loads and saves the registers AX, BX, CX, DX,
BP, SI, DI, and flags. This data structure is called RegType. The
INTERRUPTX routine loads and saves all the registers that
INTERRUPT does, plus DS and ES, and should be used only when DS or
ES need to point at some data structure. This data structure is
Now, to your question, the registers AH and AL map to the high and
low bytes of the AX variable. The confusing part is that QB
insists that all two-byte integers are signed (positive and
negative), so if bit 7 of AH is set, the number is negative. As
for loading the registers, the hex prefix, &H, works nicely, and
avoids the effort of sign conversion. So, if you wanted a function
named Foo that loaded AH with 23 hex and AL with 45 hex, executed
interrupt 10 hex, and returned the integer -1 if and only if CL is
22 hex on return from the interrupt and zero otherwise, you could
do the following:
DIM regs AS RegType
regs.ax = &H2345
INTERRUPT &H10, regs, regs
Foo% = ((regs.cx AND 255) = &H22)
... OFFLINE 1.38
--- GEcho 1.00/beta+
* Origin: The Extinguisher BBS, (916)334-4470 North Highlands, CA (1:203/540)