home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
clarion
/
tktools.zip
/
TKTOOLS.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-02-26
|
24KB
|
556 lines
; BOF TkTools.ASM
.XALL
PAGE 60,120
;╒═══════════════════════════════════════════════════════════════════════╕
;│ Module Notes │
;├───────────────────────────────────────────────────────────────────────┤
;│ Module : TKTools.asm │
;│ Purpose : Miscellaneous DOS/BIOS functiions and procedures │
;│ Notice : Copyright (c) 1989, Anthony M. Kirk │
;│ Duly noted herein if portions copyright by other authors. │
;│ (Face it, there are only so many ways to do some things.) │
;│ Rights : This module is hereby placed into the PUBLIC DOMAIN. │
;│ No blame : This module has no WARRANTY, either express or implied. │
;│ Warning? : Use it at your own risk. I have been without problems. │
;│ │
;│ Appology?: Since I've picked up what I know about Assembly by having │
;│ flashbacks of 370 Assembler, reading other's code, and by │
;│ purchasing "Norton's Guide to Assembly" (something I will │
;│ recommend to any programmer!), it probably "ain't purty"! │
;│ This module does what I need it to, but I can't say it'll │
;│ do what you need. I hope you can get some use out of it. │
;╞═══════════════════════════════════════════════════════════════════════╡
;│ Function and Procedure List │
;├───────────────────────────────────────────────────────────────────────┤
;│ Interrupt(RegisterGroup) ... Perform Interrupt Using Passed Registers │
;│ DosVer() ................................. Return Current Dos Version │
;│ GetDriveChar() .......................... Return Current Drive Letter │
;│ GetDriveNmbr() .......................... Return Current Drive Number │
;│ GetDriveCap(DriveNumber) ............ Return Capacity of Passed Drive │
;│ GetDriveFree(DriveNumber) ......... Return Free Bytes of Passed Drive │
;│ SetDriveChar(DriveLetter) ........ Set Current Drive to Passed Letter │
;│ SetDriveNmbr(DriveNumber) ........ Set Current Drive to Passed Number │
;│ GetActivFlop() .............. Get Active Floppy on Single Drive Units │
;│ SetActivFlop() .............. Set Active Floppy on Single Drive Units │
;│ FloppyCount() .............. Return number of Floppy Drives Installed │
;│ SetBlkToHigh ............ Sets blinking to high intensity background │
;│ SetHighToBlk ............ Sets high intensity background to blinking │
;│ │
;╞═══════════════════════════════════════════════════════════════════════╡
;│ Function and Procedure Notes │
;├───────────────────────────────────────────────────────────────────────┤
;│ Procedure: Interrupt(RegisterGroup) │
;│ Purpose : Perform interrupt with passed registers │
;│ │
;│ Parms : Registers GROUP,PRE(Reg) │
;│ AX GROUP │
;│ AL BYTE │
;│ AH BYTE │
;│ . ! End AX │
;│ BX GROUP │
;│ BL BYTE │
;│ BH BYTE │
;│ . ! End BX │
;│ CX GROUP │
;│ CL BYTE │
;│ CH BYTE │
;│ . ! End CX │
;│ DX GROUP │
;│ DL BYTE │
;│ DH BYTE │
;│ . ! End DX │
;│ SI SHORT │
;│ DI SHORT │
;│ DS SHORT │
;│ ES SHORT │
;│ INT BYTE │
;│ FLAGS SHORT │
;│ . ! End GROUP Registers │
;│ │
;│ Returns : None (Register group, passed by address, changed directly) │
;├───────────────────────────────────────────────────────────────────────┤
;│ Function : DosVer() │
;│ Purpose : Get current DOS version │
;│ │
;│ Parms : None │
;│ │
;│ Returns : DOS Version │
;│ Type : STRING │
;│ Format : 'x.xx' │
;│ Example : DOS 3.30 returns "3.30" │
;├───────────────────────────────────────────────────────────────────────┤
;│ Function : GetDriveChar() │
;│ Purpose : Character of current drive │
;│ │
;│ Parms : None │
;│ │
;│ Returns : Character of current drive │
;│ Type : STRING │
;│ Format : 'A' │
;├───────────────────────────────────────────────────────────────────────┤
;│ Function : GetDriveNmbr() │
;│ Purpose : Number of current drive │
;│ │
;│ Parms : None │
;│ │
;│ Returns : Number of current drive │
;│ Type : LONG │
;│ Example : A returns 0, B returns 1, etc. │
;├───────────────────────────────────────────────────────────────────────┤
;│ Function : GetDriveCap(DriveNumber) │
;│ Purpose : Capacity of passed drive │
;│ │
;│ Parms : Drive Number (0=default, 1=A, 2=B, etc.) │
;│ (NOTE: numbers are "+1" of other drive numbers) │
;│ │
;│ Returns : Capacity of passed drive number │
;│ Type : LONG │
;├───────────────────────────────────────────────────────────────────────┤
;│ Function : GetDriveFree(DriveNumber) │
;│ Purpose : Free bytes on passed drive │
;│ │
;│ Parms : Drive Number (0=default, 1=A, 2=B, etc.) │
;│ (NOTE: numbers are "+1" of other drive numbers) │
;│ │
;│ Returns : Free bytes on passed drive number │
;│ Type : LONG │
;├───────────────────────────────────────────────────────────────────────┤
;│ Function : SetDriveChar(DriveChar) │
;│ Purpose : Setting current drive by letter │
;│ │
;│ Parms : Drive Letter (A,B, etc.) │
;│ │
;│ Returns : 1=Okay, 0=Error │
;│ (Allows use of "IF SetDriveChar('C')" for True/False) │
;│ Type : LONG │
;├───────────────────────────────────────────────────────────────────────┤
;│ Function : SetDriveNmbr(DriveNumber) │
;│ Purpose : Setting current drive by number │
;│ │
;│ Parms : Drive Number (0=A, 2=B, etc.) │
;│ │
;│ Returns : 1=Okay, 0=Error │
;│ (Allows use of "IF SetDriveNmbr(2)" for True/False) │
;│ Type : LONG │
;├───────────────────────────────────────────────────────────────────────┤
;│ Function : GetActivFlop() │
;│ Purpose : Determine active floppy on single floppy drive units │
;│ │
;│ Parms : None │
;│ │
;│ Returns : Drive Number (00h = A, 01h = B, FFh = not determined = A ) │
;│ Type : LONG │
;├───────────────────────────────────────────────────────────────────────┤
;│ Function : SetActivFlop(DriveNumber) │
;│ Purpose : Sets active floppy on single floppy drive units │
;│ │
;│ ********************************************************************* │
;│ ** This function VERY useful to insure that users do ** │
;│ ** NOT get the "Insert diskette in drive A" message. ** │
;│ ** You can force DOS to think A: is the active drive ** │
;│ ********************************************************************* │
;│ │
;│ Parms : Drive Number (00h = A, 01h = B) │
;│ │
;│ Returns : 1=Okay, 0=Error │
;│ (Allows use of "IF SetActivFlop(0)" for True/False) │
;│ Type : LONG │
;├───────────────────────────────────────────────────────────────────────┤
;│ Function : FloppyCount() │
;│ Purpose : Determines the number of floppy drives installed │
;│ │
;│ Parms : None │
;│ │
;│ Returns : Number of floppy drives installed │
;│ Type : LONG │
;├───────────────────────────────────────────────────────────────────────┤
;│ Procedure: SetBlkToHigh │
;│ Purpose : Changes blinking on EGA/VGA to high intensity background │
;│ │
;│ Parms : None │
;├───────────────────────────────────────────────────────────────────────┤
;│ Procedure: SetHighToBlk │
;│ Purpose : Changes high intensity background to blinking on EGA/VGA │
;│ │
;│ Parms : None │
;└───────────────────────────────────────────────────────────────────────┘
; Clarion LEM Equates
TString EQU 0 ; String
TShort EQU 1 ; Signed Word (16 bits)
TLong EQU 2 ; Signed Double Word (32 bits)
TReal EQU 4 ; Double Precision Float (8087)
Procedure EQU 0 ; LEM Procedure
Function EQU 1 ; LEM Function
; LEM Macro - Routine 'RtnName', RtnLabel, RtnType, ParmCount
Routine MACRO RNAME, RPROC, RTYPE, RPARMS
LOCAL LBLSTRT, X1 ;* Macro local symbol defs
LBLSTRT DB &RNAME ; Routine name
NAMELTH = $-LBLSTRT ;* Len of Routine name - 13
X1 EQU 13-NAMELTH ;* Store number of nulls needed
DB &X1 DUP (0) ; Pad rest of name with nulls
DW &RPROC ; Offset of proc within module
DB &RTYPE ; Type, Proc(0) or Func(1)
DB &RPARMS ; Number of parameters
ENDM ; End of macro
; LEM Macro - Parameter ParmLabel, ParmType
Parameter MACRO PLBL, PTYPE
DB &PTYPE ; Parameter Type
&PLBL DD 0 ; Parameter Address
&PLBL&L DW 0 ; Parameter Length
ENDM
; LEM Setup
TKTools SEGMENT BYTE ; Load on a BYTE boundary
ASSUME CS:TKTools,DS:TKTools ; Reg used for effective addr
; LEM Module Header
DB 'BIO' ; LEM signature
LIBVEC DD 0 ; Reserved, runtime lib vector
DW TKEnd ; Length of LEM Module
DB 13 ; Number of proc/funcs in LEM
; Interrupt Procedure Definition
Routine 'INTERRUPT',INTERRUPT,Procedure,1
Parameter PIntRegs,TString
; DosVer Function Definition
Routine 'DOSVER',DOSVER,Function,0
; GetDriveChar Function Definition
Routine 'GETDRIVECHAR',GETDRIVECHAR,Function,0
; GetDriveNmbr Function Definition
Routine 'GETDRIVENMBR',GETDRIVENMBR,Function,0
; GetDriveCap Function Definition
Routine 'GETDRIVECAP',GETDRIVECAP,Function,1
Parameter PDrvCap,TShort
; GetDriveFree Function Definition
Routine 'GETDRIVEFREE',GETDRIVEFREE,Function,1
Parameter PDrvFree,TShort
; SetDriveChar Function Definition
Routine 'SETDRIVECHAR',SETDRIVECHAR,Function,1
Parameter PSetDrChr,TString
; SetDriveNmbr Function Definition
Routine 'SETDRIVENMBR',SETDRIVENMBR,Function,1
Parameter PSetDrNum,TShort
; GetActivFlop Function Definition
Routine 'GETACTIVFLOP',GETACTIVFLOP,Function,0
; SetDriveNmbr Function Definition
Routine 'SETACTIVFLOP',SETACTIVFLOP,Function,1
Parameter PSetActNum,TShort
; FloppyCount Function Definition
Routine 'FLOPPYCOUNT',FLOPPYCOUNT,Function,0
; SetBlkToHigh Procedure Definition
Routine 'SETBLKTOHIGH',SETBLKTOHIGH,Procedure,0
; SetHighToBlk Procedure Definition
Routine 'SETHIGHTOBLK',SETHIGHTOBLK,Procedure,0
; Work Area
XRetLong LABEL DWORD ; Long return value
XRetShort LABEL WORD ; Short return value
XRetByte DB 0 ; Byte return value
DB 3 DUP(0) ; Fill area for return value
; Interrupt Procedure Code
Interrupt PROC FAR
LES BX,DWORD PTR PIntRegs ; Load address of passed regs
MOV AL,BYTE PTR ES:[BX+16] ; Get Interrupt Number passed
LEA SI,IntVec ; Make an int instruction
MOV BYTE PTR [SI],AL ; Move
PUSH WORD PTR ES:[BX+2] ; Push passed BX onto stack
PUSH WORD PTR ES:[BX+14] ; Push passed ES onto stack
MOV AX,WORD PTR ES:[BX+0] ;
MOV CX,WORD PTR ES:[BX+4] ;
MOV DX,WORD PTR ES:[BX+6] ;
MOV SI,WORD PTR ES:[BX+8] ;
MOV DI,WORD PTR ES:[BX+10] ;
MOV DS,WORD PTR ES:[BX+12] ;
POP ES ; Pop ES
POP BX ; POp BX
DB 0CDh ; Interrupt OPCode
IntVec: DB 10h ; Interrupt Vector
PUSHF ; Push Flags
PUSH ES ; Save Registers: Push ES
PUSH DS ; Push DS onto stack
PUSH BX ; Push BX onto stack
PUSH CS ; Push CS onto stack
POP DS ; Pop CS into DS
LES BX,DWORD PTR PIntRegs ; Load address of group
MOV WORD PTR ES:[BX+0],AX ; Move AX value into group
POP WORD PTR ES:[BX+2] ; Pop BX value into group
MOV WORD PTR ES:[BX+4],CX ; Move CX into group
MOV WORD PTR ES:[BX+6],DX ; Move DX into group
MOV WORD PTR ES:[BX+8],SI ; Move SI into group
MOV WORD PTR ES:[BX+10],DI ; Move DI into group
POP WORD PTR ES:[BX+12] ; Pop DS
POP WORD PTR ES:[BX+14] ; Pop ES
POP WORD PTR ES:[BX+17] ; Pop flags into group
RET ; Return to Clarion
Interrupt ENDP
; DosVer Function Code
DosVer PROC FAR
MOV AH,30h ; Set for DOSVer func
INT 21H ; Perform interrupt
ADD AL,'0' ; Make major an ascii number
MOV BYTE PTR XRetLong,AL ; Move Major
MOV BYTE PTR XRetLong+1,'.' ; Move Decimal place
MOV AL,AH ; Move to low byte
SUB AH,AH ; Clear high byte
MOV BX,0Ah ; Get ready to divide by 10
DIV BX ; Divide Minor by 10 (into AX)
ADD AL,'0' ; Make it an ascii number
ADD AH,'0' ; Make it an ascii number
MOV BYTE PTR XRetLong+2,AL ; Move third char to string
MOV BYTE PTR XRetLong+3,AH ; Move fourth char to string
MOV AL,TString ; Set to string return val
MOV BX,OFFSET TKTools:XRetLong ; Set address
MOV CX,4 ; Set length of string
RET ; Return to Clarion
DosVer ENDP
; GetDriveChar Function Code
GetDriveChar PROC FAR
MOV AH,19h ; Set for current drive
INT 21H ; Perform interrupt
ADD AL,'A' ; Returns A=0, so add 65 (A)
MOV XRetByte,AL ; Move to return string
MOV AL,TString ; Set return type to string
MOV CX,1 ; Set length to 1
MOV BX,OFFSET TKTools:XRetByte ; Set address of value
RET ; Return to Clarion
GetDriveChar ENDP
; GetDriveNmbr Function Code
GetDriveNmbr PROC FAR
CALL ClrRetLong ; Clear return value
MOV AH,19h ; Set for current drive
INT 21H ; Perform interrupt
MOV XRetByte,AL ; Move to return string
MOV AL,TLong ; Set return type to long
MOV BX,OFFSET TKTools:XRetByte ; Set address of value
RET ; Return to Clarion
GetDriveNmbr ENDP
; GetDriveCap Function Code
GetDriveCap PROC FAR
CALL ClrRetLong ; Clear return value
LES DI,PDrvCap ; Point to passed disk
MOV DL,ES:[DI] ; Move passed disk
MOV AH,36h ; Set for disk free space
INT 21h ; Perform interrupt
PUSH DX ; Push DX (clusters)
SUB DX,DX ; Clear DX
MUL CX ; Multiply AX by CX
POP CX ; Pop old DX into CX
MUL CX ; Multiply AX by CX (old DX)
MOV WORD PTR XRetLong,AX ; Move to return string
MOV WORD PTR XRetLong+2,DX ; Move to return string
MOV AL,TLong ; Set return type to long
MOV BX,OFFSET TKTools:XRetLong ; Set address of value
RET ; Return to Clarion
GetDriveCap ENDP
; GetDriveFree Function Code
GetDriveFree PROC FAR
CALL ClrRetLong ; Clear return value
LES DI,PDrvCap ; Point to passed disk
MOV DL,ES:[DI] ; Move passed disk
MOV AH,36h ; Set for disk free space
INT 21h ; Perform interrupt
SUB DX,DX ; Clear DX
MUL CX ; Multiply AX by CX (bytes)
MUL BX ; Multiply AX by BX (free cl)
MOV WORD PTR XRetLong,AX ; Move to return string
MOV WORD PTR XRetLong+2,DX ; Move to return string
MOV AL,TLong ; Set return type to long
MOV BX,OFFSET TKTools:XRetLong ; Set address of value
RET ; Return to Clarion
GetDriveFree ENDP
; SetDriveChar Function Code
SetDriveChar PROC FAR
CALL ClrRetLong ; Clear return value
MOV XRetByte,01h ; Set return val to OKAY
MOV AH,19h ; Set for current drive
INT 21h ; Perform interrupt
LES DI,PSetDrChr ; Point to passed drive ltr
MOV DL,ES:[DI] ; Move passed disk
CMP DL,'a' ; Compare character to 'a'
JL NotLower1 ; Skip lower to upper section
SUB DL,32 ; Make it upper case
NotLower1: SUB DL,'A' ; Make char a number
CMP AL,DL ; Compare current to passed
JE EndSetDrChr ; Skip setting if same
MOV AH,0Eh ; Set for set default disk
INT 21h ; Perform interrupt
MOV AH,19h ; Set for current drive
INT 21h ; Perform interrupt
CMP AL,DL ; Check current same as passed
JE EndSetDrChr ; Leave OKAY in return code
MOV XRetByte,00h ; Move error to return code
EndSetDrChr: MOV AL,TLong ; Set return type to long
MOV BX,OFFSET TKTools:XRetByte ; Set address of value
RET ; Return to Clarion
SetDriveChar ENDP
; SetDriveNmbr Function Code
SetDriveNmbr PROC FAR
CALL ClrRetLong ; Clear return value
MOV XRetByte,01h ; Clear return val to OKAY
MOV AH,19h ; Set for current drive
INT 21h ; Perform interrupt
LES DI,PSetDrNum ; Point to passed drive ltr
MOV DL,ES:[DI] ; Move passed disk
CMP AL,DL ; Compare current to passed
JE EndSetDrNum ; Skip setting if same
MOV AH,0Eh ; Set for set default disk
INT 21h ; Perform interrupt
MOV AH,19h ; Set for current drive
INT 21h ; Perform interrupt
CMP AL,DL ; Check current same as passed
JE EndSetDrNum ; Leave OKAY in return code
MOV XRetByte,00h ; Move error to return code
EndSetDrNum: MOV AL,TLong ; Set return type to long
MOV BX,OFFSET TKTools:XRetByte ; Set address of value
RET ; Return to Clarion
SetDriveNmbr ENDP
; GetActivFlop Function Code
GetActivFlop PROC FAR
CALL ClrRetLong ; Clear return value
PUSH SI ; Save SI
PUSH DS ; Save DS
SUB AX,AX ; Clear register (00h)
MOV DS,AX ; And move it to DS
MOV SI,0504h ; Store Offset (504h)
MOV BL,[SI] ; PEEK byte into BL
POP DS ; Restore DS
POP SI ; Restore SI
MOV XRetByte,BL ; Store in CurDrv retn area
MOV AL,TLong ; Set return type to long
MOV BX,OFFSET TKTools:XRetByte ; Set address of value
RET ; Return to Clarion
GetActivFlop ENDP
; SetActivFlop Function Code
SetActivFlop PROC FAR
CALL ClrRetLong ; Clear return value
MOV XRetByte,00h ; Clear return val to ERROR
LES DI,PSetActNum ; Point to passed disk
MOV BL,ES:[DI] ; Move passed disk
CMP BL,01h ; Compare passed to 01 (B)
JG EndSetActFl ; Skip around the poke
MOV XRetByte,01h ; Set return val to OKAY
PUSH SI ; Save SI
PUSH DS ; Save DS
SUB AX,AX ; Clear register (00h)
MOV DS,AX ; And move it to DS
MOV SI,0504h ; Store Offset (504h)
MOV [SI],BL ; POKE byte from BL
POP DS ; Restore DS
POP SI ; Restore SI
EndSetActFl: MOV AL,TLong ; Set return type to long
MOV BX,OFFSET TKTools:XRetByte ; Set address of ret code
RET ; Return to Clarion
SetActivFlop ENDP
; FloppyCount Function Code
FloppyCount PROC FAR
CALL ClrRetLong ; Clear return value
INT 11H ; Perform equip-list int
MOV BX,AX ; Store AX in BX
AND BX,01h ; See if ANY floppies
CMP BX,01h ; If ANY floppies, True
JNE RetFloppy ; No floppies, return
MOV CL,6 ; Set to shift 6 bits
SHR AX,CL ; Shift right by 6 bits
AND AX,00000011b ; Pull out floppy count bits
ADD AX,1 ; Subtract one from AX
MOV XRetShort,AX ; Move to return string
RetFloppy: MOV AX,TLong ; Set return type to long
MOV BX,OFFSET TKTools:XRetShort ; Set address of value
RET ; Return to Clarion
FloppyCount ENDP
; SetBlkToHigh Function
SetBlkToHigh PROC FAR
MOV AH,10h ;
MOV AL,03h ;
MOV BL,00h ; 00h in BL makes high-intens
INT 10h ; Call interrupt
RET
SetBlkToHigh ENDP
; SetBlkToHigh Function
SetHighToBlk PROC FAR
MOV AH,10h
MOV AL,03h
MOV BL,01h ; 01h in BL makes blinking
INT 10h ; Call interrupt
RET
SetHighToBlk ENDP
; ClrRetLong Procedure (LOCAL)
ClrRetLong PROC NEAR ; Clear return val to nulls
MOV AX,DS ; Save DS to give to ES
MOV ES,AX ; Now get AX into ES
MOV DI,OFFSET XRetLong ; Get address of val (ES:DI)
CLD ; Clear dir flag (forward)
SUB AX,AX ; Init value to 0
MOV CX,2 ; Set to length (2*2)
REPNZ STOSW ; Store 0 in all 128 bytes
RET ; Return to caller
ClrRetLong ENDP
; Ending Labels
TKEnd LABEL BYTE
TKTools ENDS
END
; EOF TkTools.ASM