Help, software interrupts 
Author Message
 Help, software interrupts

tmarys.demon.co.uk enquired...

TM> How can I call an interupt routine from basic. I need to set the
  > registers,  call then get the values back.  Is this possible?

I notice that all your other replies have assumed that you're using
a compiler such as QuickBASIC or powerbasic. If you really do mean
interpreted BASIC (ie BASICA or GW-BASIC) then here's some code
that implements interrupt calls in those dialects as well. By a
happy coincidence, the example program also answers the person who
wanted to know how to find the amount of free disk space on his
drive but it can be adapted to use any DOS or BIOS call...

--- cut here ---------------------------------------------------------------
100 ' DISKINFO.BAS  demonstrates how to use interrupt services in GW-BASIC
110 '
120 '   Author:     Christy Gemmell
130 '   Date:       12/6/1988
140 '
150 DEFINT A-Z: CLS
160 DIM REG.IN(7), REG.OUT(7)
170 AX = 0: BX = 1: CX = 2: DX = 3: SI = 4: DI = 5: DS = 6: ES = 7
180 SYSINT$ = SPACE$(116)
190 FOR X = 1 TO 116
200     READ A$: MID$(SYSINT$, X, 1) = CHR$(VAL("&H" + A$))
210 NEXT
220 '
230 INPUT "Which drive - <Enter> for default"; D$
240 IF D$ = "" THEN DRIVE = 0: GOTO 270         ' Default drive
250 IF D$ < "A" OR D$ > "Z" THEN 230
260 DRIVE = ASC(D$) - 64
270 REG.IN(AX) = 256 * &H36
280 REG.IN(DX) = DRIVE
290 INT.NO = &H21
300 '
310 DEF SEG: X = VARPTR(SYSINT$)
320 SYSINT! = PEEK(X + 1) + 256 * PEEK(X + 2)
330 CALL SYSINT!(INT.NO, REG.IN(0), REG.OUT(0))
340 IF REG.OUT(AX) = -1 THEN PRINT "Invalid drive": GOTO 230
350 SPC = REG.OUT(AX): F = REG.OUT(BX)
360 BPS = REG.OUT(CX): C = REG.OUT(DX)
370 CD! = -((C < 0) * (65536! + C) + ((C > = 0) * C))
380 FC! = -((F < 0) * (65536! + F) + ((F > = 0) * F))
390 '
400 PRINT: PRINT "Logical Disk Setup"
410 PRINT "------------------------------"
420 PRINT "Bytes per sector    :" BPS
430 PRINT "Sectors per cluster :" SPC
440 PRINT "Clusters per disk   :" CD!
450 PRINT "------------------------------"
460 PRINT "Total disk space    : ";
470 PRINT USING "###########,"; BPS * SPC * CD!
480 PRINT "Disk free space     : ";
490 PRINT USING "###########,"; BPS * SPC * FC!
500 '
510 DATA 55, 8B, EC, 8B, 5E, 0A, 8B, 07, 8B, 5E, 06, 8B, CB
520 DATA 8B, 5E, 08, 06, 1E, E8, 05, 00, 00, 00, CD, 00, C3
530 DATA 5D, 88, 46, 03, 89, 4E, 00, 8B, 4F, 04, 8B, 57, 06
540 DATA 8B, 77, 08, 8B, 7F, 0A, 8B, 47, 0E, 3D, FF, FF, 74
550 DATA 02, 8E, C0, 8B, 47, 0C, 3D, FF, FF, 74, 02, 8E, D8
560 DATA 36, 8B, 07, 36, 8B, 5F, 02, E8, CC, FF, 53, 8B, 5E
570 DATA 00, 36, 89, 07, 36, 8F, 47, 02, 8C, D8, 36, 89, 47
580 DATA 0C, 1F, 8C, C0, 89, 47, 0E, 07, 89, 4F, 04, 89, 57
590 DATA 06, 89, 77, 08, 89, 7F, 0A, 5D, CA, 06, 00, 00
--- and here ---------------------------------------------------------------

All we need now is a QBasic version.

+------------------------+-----------------------------------------------+
|     _/_/_/_/  _/_/_/_/ | Christy Gemmell, Singular Software            |
|    _/        _/        | 11 Abingdon Road, Leicester LE2 1HA, England. |


| _/_/_/_/  _/_/_/_/     | Phone: +44-0116-254-7681                      |
+------------------------+-----------------------------------------------+

 * 1st 2.00o #323 * I'm here to chew gum and kick ass...



Mon, 01 Dec 1997 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Need to write 32-bit DLL to do 16-bit calls to a software interrupt

2. How do I get the size of a file using Interrupt or Interrupt

3. help on Interrupt

4. Help with Interrupt method

5. Help With Interrupt

6. Interrupts help!!

7. Help Needed w/ interrupts

8. Help needed for Qbasic interrupts.

9. Need Help With Interrupt/InterruptX

10. Require help with QB4.5 interrupt use

11. Help with interrupt, please...

12. HELP! Cancel or interrupt while app is running

 

 
Powered by phpBB® Forum Software