<--- Turn the page     (contents page)     Turn the page --->


Basic

Using the registers in Basic




There is a basic style way of using the registers and calling interrupts that makes it easy to use for the novice. In this column, I will explain the use of this technique.

For each example, we need to remember to load the supplied quick library, QB.QLB. To do this, at the command line, enter:

QB /L QB.QLB yourfile
where yourfile is the filename that you want to call your new program.

The first example we will only care about the registers on entry to the DOS call. We won't care about the return registers. In this example, we will simply print a string to the screen.
  '$INCLUDE: 'QB.BI'

  DIM inreg AS RegTypeX, outreg AS RegTypeX

  ' print a string to the screen using a DOS call
  DemoStr$ = "Hello, World!" + CHR$(36)

  inreg.ax = &H900
  inreg.dx = SADD(DemoStr$)
  inreg.ds = VARSEG(DemoStr$)
  CALL INTERRUPTX(&H21, inreg, outreg)
Notice that we used the SADD command instead of the VARPTR command. When getting the offset of a string, the SADD command should be used. When getting an offset of a variable, the VARPTR command should be used.

With the next example, we will use the return register values as our data and we will get the current disk drive.
  ' get current disk drive letter
  inreg.ax = &H1900
  CALL INTERRUPTX(&H21, inreg, outreg)
  PRINT "Current Drive Letter: ";
  PRINT CHR$((outreg.ax AND &HFF) + ASC("A"))
Notice that on return, we only need the value in the AL register, so we need to clear out the AH portion of the expression. ¥



<--- Turn the page     (contents page)     Turn the page --->

Page 10