home *** CD-ROM | disk | FTP | other *** search
- TITLE Btrieve Record Manager, Copyright (c) 1982 SoftCraft, Inc.
- SUBTTL FORXFACE - Interface to FORTRAN, Btrieve Version 4
- PAGE
- ;-----------------------------------------------------------------
- ;FOR_XFACE
- ; This routine interfaces between FORTRAN programs and
- ; Btrieve assembly routines.
- ;
- ; Calling Procedure from FORTRAN
- ; ISTAT = ITRV (FUNCTION, CUR_BLOCK, DATA_BUF, DATA_LEN,
- ; KEY_BUF, KEY_NUMBER)
- ; where
- ; ITRV - return status from request (INTEGER)
- ; FUNCTION - function number for request (INTEGER)
- ; CUR_BLOCK - address of user's currency block (128 bytes)
- ; DATA_BUF - address of data buffer
- ; DATA_LEN - length of data buffer (INTEGER)
- ; KEY_BUF - address of key buffer (255 bytes)
- ; KEY_NUMBER - key number to be processed (INTEGER)
- ;-----------------------------------------------------------------
- ;
- PUBLIC ITRV
- ; Define parameter offsets on stack
- ;
- PARM_OFF = 10
- FUNCTION = PARM_OFF + 20
- CUR_BLOCK = PARM_OFF + 16
- DATA_BUF = PARM_OFF + 12
- DATA_LEN = PARM_OFF + 8
- KEY_BUFFER = PARM_OFF + 4
- KEY_NUM = PARM_OFF
- ;
- ; Define offsets withing the currency block where FCB
- ; and currency information are found
- ;
- FCB = 0
- CUR = 38
- ;
- FOR_ID EQU 0AAAAH ;FORTRAN id
- VAR_ID EQU 06176H ;Variable data buffer ID
- BTR_ERR EQU 20 ;Return status when Btrieve not initialized
- BTR_INT EQU 07BH
- BTR2_INT EQU 02FH
- MULTI_FUNCTION EQU 0ABH
- BTR_OFFSET EQU 033H
- BTR_VECTOR EQU BTR_INT * 4 ;Absolute vector offset for interrupt
- POS_LEN_ERR EQU 23 ;Invalid position block length error code
- ;
- XFACE SEGMENT PUBLIC 'CODE'
- ASSUME CS:XFACE,DS:XFACE
-
- PUBLIC USER_BUF_ADDR
- PUBLIC USER_BUF_LEN
- PUBLIC USER_CUR_ADDR
- PUBLIC USER_FCB_ADDR
- PUBLIC USER_FUNCTION
- PUBLIC USER_KEY_ADDR
- PUBLIC USER_KEY_LENGTH
- PUBLIC USER_KEY_NUMBER
- PUBLIC USER_STAT_ADDR
- PUBLIC XFACE_ID
-
-
- USER_BUF_ADDR DD ?
- USER_BUF_LEN DW ?
- USER_CUR_ADDR DD ?
- USER_FCB_ADDR DD ?
- USER_FUNCTION DW ?
- USER_KEY_ADDR DD ?
- USER_KEY_LENGTH DB ?
- USER_KEY_NUMBER DB ?
- USER_STAT_ADDR DD ?
- XFACE_ID DW ?
-
-
- ;
- STAT DW 0
- ;
- PROCID DW 0 ;Process Id for use by BMulti
- MULTI DW 0
- VSET DW 0
- ;
- ITRV PROC FAR
- ;
- ; save callers segment and establish current segments
- ;
- PUSH BP ;save callers registers
- PUSH DS
- PUSH ES
- MOV BP,SP ;set base parm list
- PUSH CS ;set up data segment
- POP DS
- ;
- ; ensure Btrieve has been initialized
- ;
- PUSH ES
- PUSH BX
- MOV AX,3500H + BTR_INT
- INT 21H
- CMP BX,BTR_OFFSET ;Has Btrieve been intitalized?
- POP BX
- POP ES
- JE FOR_10 ; Yes
- MOV STAT,BTR_ERR ;Set return status
- JMP FOR_20 ;Skip interrupt since invalid
- FOR_10:
- CMP VSET,0
- JNE FOR_11
- INC VSET
- PUSH AX
- MOV AX,3000H
- INT 21H
- CMP AL,3
- POP AX
- JB FOR_11
- MOV AX,MULTI_FUNCTION * 256
- INT BTR2_INT
- CMP AL,'M'
- JNE FOR_11
- INC MULTI
- FOR_11:
- ;
- ; get function parameter
- ;
- LES SI,[BP]+FUNCTION ;get function code
- MOV SI,ES:[SI]
- MOV USER_FUNCTION,SI
- ;
- ; get address of callers status word from parameter
- ;
- LEA CX,STAT ;get address of status word
- MOV WORD PTR USER_STAT_ADDR,CX
- MOV WORD PTR USER_STAT_ADDR[2],DS
- ;
- ; get users currency block which contains:
- ; - diskette FCB
- ; - currency information
- ;
- LES BX,[BP]+CUR_BLOCK ;ES:BX => address of currency block
- LEA AX,[BX]+FCB ;get diskette FCB addr
- MOV WORD PTR USER_FCB_ADDR,AX
- LEA AX,[BX]+CUR ;get currency block addr
- MOV WORD PTR USER_CUR_ADDR,AX
- MOV WORD PTR USER_FCB_ADDR[2],ES
- MOV WORD PTR USER_CUR_ADDR[2],ES
- ;
- ; get address of data buffer
- ;
- LES BX,[BP]+DATA_BUF ;AX => data buffer
- MOV WORD PTR USER_BUF_ADDR,BX
- MOV WORD PTR USER_BUF_ADDR[2],ES
- ;
- ; get callers data buffer length
- ;
- PUSH ES
- LES BX,[BP]+DATA_LEN
- MOV AX,ES:[BX]
- MOV USER_BUF_LEN,AX
- POP ES
- ;
- ; get callers key buffer address
- ;
- LES BX,[BP]+KEY_BUFFER ;get key buffer addr
- MOV WORD PTR USER_KEY_ADDR,BX
- MOV WORD PTR USER_KEY_ADDR[2],ES
- ;
- ; get callers key buffer length
- ;
- ;get key length
- MOV USER_KEY_LENGTH,255
- ;
- ; get key number parameter
- ;
- LES SI,dword ptr [BP]+KEY_NUM ;get key number
- MOV BX,ES:[SI]
- MOV USER_KEY_NUMBER,BL
- ;
- ; set language and go process request
- ;
- MOV XFACE_ID,VAR_ID ;get FORTRAN id
- LEA DX,USER_BUF_ADDR ;DX => user parms
- ;
- ;
- ;
- CMP MULTI,0
- JE NOT_MULTI
- MAKE_CALL:
- ;
- ; Set up additional registers for BMulti
- ;
- XOR AX,AX
- INC AX ;Initialize function setting for BMulti
- MOV BX,PROCID ;Set Process id for BMulti
- OR BX,BX ;Do we need to get a process id?
- JE CALL_MULTI ; Yes, let BMulti know
- INC AX ;Tell BMulti you have a process id
- CALL_MULTI:
- MOV AH,MULTI_FUNCTION
- INT BTR2_INT
- CMP AL,0
- JE DONE_CALL
- MOV AX,200H
- INT 7FH
- JMP SHORT MAKE_CALL
- DONE_CALL:
- CMP PROCID,0
- JNE FOR_12
- MOV PROCID,BX
- JMP FOR_12
- NOT_MULTI:
- INT BTR_INT ;process request
- FOR_12:
- PUSH ES
- LES BX,[BP]+DATA_LEN
- MOV AX,USER_BUF_LEN
- MOV ES:[BX],AX
- POP ES
- FOR_20:
- ;
- ; restore callers stack and segment before returning
- ;
- MOV AX,STAT ;Set function return code
- MOV DX,0
- POP ES
- POP DS
- POP BP
- RET 24 ;return to caller
- ;
- ITRV ENDP
- XFACE ENDS
- END