INTERRUPT for Clock Tick Counter Returns Negative Value

ID: Q59725


The information in this article applies to:
  • Microsoft Visual Basic Standard and Professional Editions for MS-DOS, version 1.0
  • Microsoft QuickBASIC for MS-DOS, versions 4.0, 4.0b, 4.5
  • Microsoft BASIC Compiler for MS-DOS, versions 6.0, 6.0b
  • Microsoft BASIC Professional Development System (PDS) for MS-DOS, versions 7.0, 7.1


SUMMARY

Interrupt 1Ah, with Function 0, returns the current value of the clock tick counter in registers CX and DX. When the low-order portion of the clock tick counter (returned in DX) exceeds 32,767, it becomes negative when stored as an integer in Basic, because 32,767 is the maximum value for a 2-byte signed integer. Listed below is an example to convert the negative value to the equivalent unsigned long integer value.


MORE INFORMATION

For a more complete description of converting negative signed integers to unsigned integers, query on the following words:

CALL and INTERRUPT and negative and signed and integer
The following Basic program outputs only positive values by removing the sign bit and adding the remaining number plus 1 to 32,767:

Example


' To try this example in VBDOS.EXE:
' 1. From the File menu, choose New Project.
' 2. Copy the code example to the Code window.
' 3. Press F5 to run the program.

' To run this program in the VBDOS.EXE environment, you must invoke
' the environment with the /L switch to load the default Quick
' library for Visual Basic for MS-DOS 1.0:
' VBDOS.EXE /L

' To use CALL INTERRUPT in this program, you must do the following:
' If you run this program in QB.EXE, use QB /L QB.QLB.
' If you run this program in QBX.EXE, use QBX /L QBX.QLB.
' LINK with QB.LIB (or QBX.LIB for Basic PDS 7.0).

' Use the following include file for Visual Basic for MS-DOS 1.0:
REM $INCLUDE: 'vbdos.bi'
' Use the following include file for QuickBasic for MS-DOS:
' $INCLUDE: 'qb.bi'
' Use the following include file for Basic PDS for MS-DOS:
' $INCLUDE: 'qbx.bi'

DIM inregs AS regtype, outregs AS regtype
LOCATE 23, 1: PRINT "Push any key to end program."
DO
inregs.ax = 0
CALL interrupt(&H1A, inregs, outregs)
high& = outregs.cx
low& = outregs.dx
IF low& < 0 THEN              ' If the low-order portion is negative:
  low& = low& AND &H7FFF      ' remove sign bit.
  low& = low& + &H7FFF + 1    ' Add remaining number plus 1 to 32,767.
END IF
LOCATE 24, 1: PRINT high&; ":"; low&; "   ";
LOOP UNTIL INKEY$ <> ""
END 

Additional query words: VBmsdos QuickBas BasicCom 1.00 4.00 4.00b 4.50 6.00 6.00b 7.00 7.10

Keywords :
Version : MS-DOS:1.0,4.0,4.0b,4.5; :6.0,6.0b,7.0,7.1
Platform : MS-DOS
Issue type :


Last Reviewed: December 9, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.