BBS: Inland Empire Archive
Date: 06-14-92 (20:44)             Number: 459
From: MATT HART                    Refer#: NONE
  To: PHIL HODGES                   Recvd: NO  
Subj: Interrupts                     Conf: (2) Quik_Bas
 PH> = &H3000

DOS interrupt services generall expect the function in AH.
The 8086 registers are:
     AX - two bytes  AH is the Most Significant Byte and AL is the
                     Least Significant Byte.  Together, AH and AL make up
                     AX.  To place a value into AH or AL seperately, you
                     must calculate it and put it all into AX.

AH = &H30
AL = 0

Regs.AX = AH*256 + AL         ' The *256 puts AH into the MSB of AX.

Of course, it is much easier to just:

Regs.AX = &H3000

 PH> CALL INTERRUPT(&H21, Regs, Regs)

Interrupt 21h, with Regs as the incoming register
information, and Regs also containing the outgoing register
information.  Many programmers, myself included, use two
types : InRegs and OutRegs

DIM InRegs AS RegType
DIM OutRegs AS RegType
CALL INTERRUPT (&H21, InRegs, OutRegs)

 PH> MajorVersion = MOD 256

The MOD function (modulo division) returns the remainder of divided by 256, in this case, AL.  So:

     AX MOD 256 = AL
     AX \ 256 = AX

Note the \ is used rather than /.  The backslash \ division
is Integer division and throws out any remainder.  Remember
using AH*256 to get AH and AL into AX?  Well, AX\256 gets
it back:

     AH*256+AL = AX
     AH*256 = AX-AL
     AH = (AX-AL)/256
But with integer division, the AL remainder is thrown out:
     AH = AX\256

 PH> MinorVersion = \ 256
 PH> PRINT USING "Current DOS version #!##"; MajorVersion; "."; MinorVersion

 PH>  BH = original equipment manufacturers serial number
 PH>  BL:CX =24-bit user serial number (optional, OEM dependent)

If you wanted BH, you would use:

BH = Regs.bx \ 256

As a 24 bit serial number, is must be represent by at least
3 bytes, so you can use a long integer (4 bytes)

BLCX& = (Regs.bx MOD 256)*256*256 +

Using 256*256 puts BL into the MSB range - like this:

     BL               CH               CL
     1 1 1 1 1 1 1 1  1 1 1 1 1 1 1 1  1 1 1 1 1 1 1 1

And you have your 24 bit serial number too.
 * Origin: Midnight Micro!  V.32/REL  (918)451-3306 (1:170/600)
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