Category : Databases and related files
Archive   : BTRV410.ZIP
Filename : BTRIEVE.ASM
; BTRIEVE.ASM Binary module for accessing Btrieve functions
;
;------- Set up LEM equates
;
TString equ 0 ;Data types
TShort equ 1
TLong equ 2
TReal equ 4
Procedure equ 0 ;Procedure/Function flags
Function equ 1
NameLength = 0 ;Initialize namelength to 0
;
;------- Set up a few macros
;
Routine macro Rname, Rproc, Rtype, Rparms ;;Define a 'Routine' macro
local LblStart
LblStart db &Rname
NameLength = $-LblStart ;;Find length of string
if NameLength gt 12 ;;if greater-than 12
.ERR ;; error condition
%OUT routine name is too long ;; end compile
else ;;otherwise
db 13-NameLength dup (0) ;; pad with 0's
dw &Rproc ;; put in offset
db &Rtype ;; put in type
db &Rparms ;; put in # of parameters
endif ;;end if
endm ;;end macro
;
Parameter macro Plbl, Ptype ;;Set up a 'Parameter' macro
db &Ptype ;;Type = String,Short,Long,Real
&Plbl dd 0 ;;Address of parameter data
&Plbl&L dw 0 ;;Length of parameter data
endm ;;end macro
;
;------- Set up some equates for this module
;
BTR_ERR equ 20 ;General Btrieve Error
BTR_INT equ 07bh ;Btrieve Interrupt
BTR_VEC equ BTR_INT*4 ;Offset of Btrieve Interrupt
Bin segment byte public 'CODE'
;------- To make BTRIEVE.BIN
; masm BTRIEVE;
; link BTRIEVE;
; exe2bin BTRIEVE;
;
ASSUME Cs:Bin,Ds:Bin,Es:Bin
;
;------- Binary Module Header
db 'BIO' ;BINARY SIGNATURE
LibVector dd 0 ;RESERVED DOUBLEWORD
dw BinEnd ;LENGTH OF MODULE
db 1 ;# PROCEDURES IN THIS MODULE
Routine 'BTRIEVE', Btrieve, Function, 6
Parameter OpCode, TShort
Parameter PosBlk, TString
Parameter DataBuf, TString
Parameter DataLen, TShort
Parameter KeyBuf, TString
Parameter KeyNum, TShort
Status dw 0,0 ;Returned status
DB_Off dw 0 ;offset of data buffer
DB_Seg dw 0 ;segment of data buffer
Data_Len dw 0 ;length of data buffer
PB_Off dw 0 ;offset of position block
PB_Seg dw 0 ;segment of position block
FCB_Off dw 0 ;offset of FCB
FCB_Seg dw 0 ;segment of FCB
OP_Code dw 0 ;Operation Code
KB_Off dw 0 ;offset of key buffer
KB_Seg dw 0 ;segment of key buffer
Key_Len db 0 ;length of key buffer
Key_Num db 0 ;key number to be used
STAT_Off dw 0 ;offset of Status
STAT_Seg dw 0 ;segment of Status
ID dw 06173h ;Interface ID
Public Btrieve
Btrieve proc far ;
push es ;Save registers
push ds ;
push si ;
push di ;
push dx ;
push cx ;
push bx ;
push ax ;
mov Status,0 ;start with no error
; First, verify that the Btrieve Record Manager is loaded
xor bx,bx ;zero BX
mov es,bx ;copy BX to ES
mov bx,BTR_VEC
cmp word ptr es:[bx],33h ;check for Btrieve loaded
jz BtrieveOK ;if loaded, can continue
mov Status,BTR_ERR ;otherwise, set error
jmp BtrieveOut ;and leave routine
BtrieveOK:
call SetupBtrv ;set up parameters for Btrieve
mov dx,offset DB_Off ;set DX to point to offset
int BTR_INT ;perform Btrieve interrupt
BtrieveOut:
pop ax ;Restore registers
pop bx ;
pop cx ;
pop dx ;
pop di ;
pop si ;
pop ds ;
pop es ;
mov bx, offset Bin:Status ;point to return value
mov ax, TLong ;indicate type of return value
ret ;Far return to Clarion
Btrieve endp
;
; SetupBtrv - Local routine to perform initialization of parameters
;
SetupBtrv proc near
les bx,OpCode ;get address of OP Code
push es:[bx] ;push Op Code
pop [OP_Code] ;pop back into storage
les bx,PosBlk ;get address of Position Block
push es ;push segment
push bx ;push offset
pop [PB_Off] ;pop offset back into storage
pop [PB_Seg] ;pop segment back into storage
les bx,DataBuf ;get address of Data Buffer
push es ;push segment
push bx ;push offset
pop [DB_Off] ;pop offset back into storage
pop [DB_Seg] ;pop segment back into storage
les bx,DataLen ;get address of Data Length
push es:[bx] ;push Data Length
pop [Data_Len] ;pop back into storage
les bx,KeyBuf ;get address of Key Buffer
push es ;push segment
push bx ;push offset
pop [KB_Off] ;pop offset back into storage
pop [KB_Seg] ;pop segment back into storage
mov bx,KeyBufL ;get length of Key Buffer
mov Key_Len,bl ;put length in storage
les bx,KeyNum ;get address of Key Number
mov bx,word ptr es:[bx] ;get Key Number
mov Key_Num,bl ;put Key Number in storage
mov bx,offset Bin:Status ;get offset of status
push cs ;push segment
push bx ;push offset
pop [STAT_Off] ;pop offset back into storage
pop [STAT_Seg] ;pop segment back into storage
ret ;near return to caller
SetupBtrv endp
BinEnd equ $ ;Mark end of binary module
Bin Ends
End
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/