Interrupts

 BBS: Inland Empire Archive
Date: 06-15-92 (08:35)             Number: 493
From: SCOTT WUNSCH                 Refer#: NONE
  To: PHIL HODGES                   Recvd: NO  
Subj: Interrupts                     Conf: (2) Quik_Bas
PH>    In order to further myself as a programmer (and to prove to
PH> myself that you don't have to know C to use complicated DOS
. . .
PH> example for CALL INTERRUPT helped a little (but WHY did they use
PH> INT86OLD ???).  Still, I'm not totally clear on this.
     ^
  Backward compatability.

'$INCLUDE: 'QB.BI'             'Needed to use CALL INTERRUPT
DIM Regs AS RegType            'Prepare register structure
Regs.ax = &H3000               'High byte of AX (AH) set to 30h
CALL INTERRUPT(&H21, Regs, Regs) 'Call interrupt 21h
MajorVersion = Regs.ax MOD 256 'MOD 256 to extract low byte (AL)
MinorVersion = Regs.ax \ 256   '\ 256 to extract high byte (AH)
PRINT USING "Current DOS version #!##"; MajorVersion; "."; MinorVersion

PH>   The book says that 21H function 30H gets the DOS version number.
PH> From the above example I can conclude that the H is 00, therefore
PH> &H3000 is function 30H.  Seems easy enough to understand.

  Sorry, not so easy.  The H simply identifies the number as
hexidecimal.

PH>   What I _don't_ understand is how the above code works. The book
PH> lists the returns as:
PH>   AL = major version number
PH>   AH = minor version number
PH>   BH = original equipment manufacturers serial number
PH>   BL:CX =24-bit user serial number (optional, OEM dependent)
                ^^^ ?! Never heard of that!

  The AL and AH are actually low and high bytes of AX.  You see,
integers (all registers are this) are composed of two bytes.  The
'high' byte of AX is therefore AH.  The low byte of CX would be
CL.  OK, when using hexidecimal numbers, it's easy to see high and
low bytes.  For example, in &H3000, the 30 is the high byte (AH), 00
is the low (AL).  That's where the &H3000 came from.
  Now, to extract the high and low bytes, you must use something
like the 'MOD 256' and '\ 256' in the example program (I commented
it for you).

PH> So... any help?

  You saw it! ;)

                                   -= Scott \\'unsch =-

... It's so BASIC it's gotta work!

--- Maximus/2 2.01wb
 * Origin: The Green Zone - Regina, Sask, Canada (1:140/23)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET