home *** CD-ROM | disk | FTP | other *** search
/ Datatid 1999 #6 / Datatid_1999-06.iso / internet / Tango352Promo / P.SQL / PTKPKG.1 / MF2BTRV.ASM < prev    next >
Encoding:
Assembly Source File  |  1997-02-13  |  6.8 KB  |  169 lines

  1. ;*************************************************************************
  2. ;
  3. ;  Copyright 1982-1997 Pervasive Software Inc. All Rights Reserved
  4. ;
  5. ;*************************************************************************
  6. ;*************************************************************************
  7. ;   MF2BTRV.ASM
  8. ;      This program is the interface between Micro Focus COBOL\2 animated
  9. ;      programs and Btrieve.  It is loaded by the COBOL runtime, and uses
  10. ;      Intel byte-order.
  11. ;
  12. ;      It is important to note that the COBOL\2 animator passes stack
  13. ;      parameters from left to right, while the non-animated COBOL/2
  14. ;      interface passes parameters from right to left.  However, COBOL/2
  15. ;      passes integers in the Intel hi-lo format for both animated and
  16. ;      non-animated applications.
  17. ;
  18. ;      Note that MF2BTRV.OBJ & CSUPPORT.OBJ have been dropped.  Use
  19. ;      COBRBTRV.OBJ in place of these.
  20. ;
  21. ;      Calling Procedure from COBOL
  22. ;      CALL "MF2BTRV" USING FUNCTION, STATUS, POSITION-BLOCK, DATA-BUFFER,
  23. ;                     DATA-LEN, KEY-VALUE, KEY-NUMBER.
  24. ;           where
  25. ;              FUNCTION       - pointer to function    PIC 9999 COMP-5 (hi-lo)
  26. ;              STATUS         - pointer to ret status  PIC 9999 COMP-5 (hi-lo)
  27. ;              POSITION-BLOCK - pointer to 128-byte position block
  28. ;              DATA-BUFFER    - pointer to data buffer
  29. ;              DATA-LEN       - pointer to length of data buffer
  30. ;              KEY-VALUE      - pointer to key buffer
  31. ;              KEY-NUMBER     - pointer to key number PIC 9999 COMP-5  (lo-hi)
  32. ;
  33. ;        IMPORTANT
  34. ;        ---------
  35. ;        Pervasive Software Inc., invites you to modify this file
  36. ;        if you find it necessary for your particular situation.  However,
  37. ;        we cannot provide technical support for this module if you
  38. ;        do modify it.
  39. ;
  40. ;*************************************************************************
  41.         PUBLIC  _BTRV
  42. ;*************************************************************************
  43. ;       Define parameter offsets on stack
  44. ;*************************************************************************
  45. PARM_OFF   = 6
  46. FUNCTION   = PARM_OFF + 24
  47. STATUS     = PARM_OFF + 20
  48. POS_BLK    = PARM_OFF + 16
  49. DATA_REC   = PARM_OFF + 12
  50. DATA_LEN   = PARM_OFF + 8
  51. KEY_BUFFER = PARM_OFF + 4
  52. KEY_NUM    = PARM_OFF + 0
  53. ;*************************************************************************
  54. ;       Define offets within position block where FCB and
  55. ;       currency information are stored.
  56. ;*************************************************************************
  57. FCB        EQU 0
  58. CUR        EQU 38
  59. VAR_ID     EQU 06176H                   ;Variable record interface id
  60. BTR_ERR    EQU 20                       ;status - Btrieve not initialized
  61. BTR_INT    EQU 07BH
  62. BTR_OFFSET EQU 033H
  63. BTR_VECTOR EQU BTR_INT * 4              ;Absolute vector offset for interrupt
  64.  
  65. ;*************************************************************************
  66. ;   Code Segment
  67. ;*************************************************************************
  68. CODE    SEGMENT 'CODE'
  69.         ASSUME CS:CODE,DS:CODE
  70.  
  71. _BTRV    proc    far
  72.     jmp    cob_0
  73.  
  74. USER_BUF_ADDR   DD      ?               ;callers data buffer offset
  75. USER_BUF_LEN    DW      ?               ;length of callers data buffer
  76. USER_CUR_ADDR   DD      ?               ;callers currency info offset
  77. USER_FCB_ADDR   DD      ?               ;disk FCB for current request
  78. USER_FUNCTION   DW      ?               ;requested function
  79. USER_KEY_ADDR   DD      ?               ;callers key buffer offset
  80. USER_KEY_LENGTH DB      ?               ;length of key buffer
  81. USER_KEY_NUMBER DB      ?               ;key of reference for request
  82. USER_STAT_ADDR  DD      ?               ;callers status word offset
  83. XFACE_ID        DW      ?               ;language identifier
  84.  
  85. cob_0:  push    bp
  86.         mov     bp,sp
  87.         push    es
  88.         push    ds
  89.         push    si
  90.  
  91.         ;set up to access data within this code segment
  92.         push    cs
  93.         pop     ds
  94.  
  95.         ;see if Btrieve has been initialized
  96.         push    es
  97.         push    bx
  98.         mov     ax,3500h + BTR_INT
  99.         int     21h
  100.         cmp     bx,BTR_OFFSET
  101.         pop     bx
  102.         pop     es
  103.         je      cob_1                           ;Has Btrieve been initialized?
  104.         les     si,dword ptr [bp]+STATUS        ;  N, BX = status offset
  105.         mov     ax,BTR_ERR
  106.         mov     es:[si],ax                      ;Set return status
  107.         jmp     cob_2                           ;go to exit
  108. COB_1:
  109.        ;get function parameter
  110.         les     si,dword ptr [bp]+FUNCTION      ;get function address
  111.         mov     cx,es:[si]                      ;get function number
  112.         mov     USER_FUNCTION,cx
  113.  
  114.         ;get address of callers status word from parameter
  115.         les     cx,dword ptr [bp]+STATUS        ;get address of status word
  116.         mov     word ptr USER_STAT_ADDR,cx
  117.         mov     word ptr USER_STAT_ADDR+2,es
  118.  
  119.         ;get position block
  120.         les     si,dword ptr [bp]+POS_BLK       ;SI = address of position block
  121.         lea     ax,es:[si]+FCB                  ;get diskette file block addr
  122.         mov     word ptr USER_FCB_ADDR,ax
  123.         mov     word ptr USER_FCB_ADDR+2,es
  124.         lea     ax,es:[si]+CUR                  ;get currency block addr
  125.         mov     word ptr USER_CUR_ADDR,ax
  126.         mov     word ptr USER_CUR_ADDR+2,es
  127.  
  128.         ;get data buffer
  129.         les     si,dword ptr [bp]+DATA_REC
  130.         mov     word ptr USER_BUF_ADDR,si
  131.         mov     word ptr USER_BUF_ADDR+2,es
  132.  
  133.         ;get data buffer length
  134.         les     si,dword ptr [bp]+DATA_LEN      ;get length address
  135.         mov     cx,es:[si]                      ;get length
  136.         mov     USER_BUF_LEN,cx
  137.  
  138.         ;get callers key buffer address and length
  139.         les     si,dword ptr [bp]+KEY_BUFFER    ;get key buffer addr
  140.         mov     word ptr USER_KEY_ADDR,si
  141.         mov     word ptr USER_KEY_ADDR+2,es
  142.         mov     USER_KEY_LENGTH,255             ;set key length to max
  143.  
  144.         ;get key number parameter
  145.         les     si,dword ptr [bp]+KEY_NUM       ;get key number address
  146.         mov     cx,es:[si]                      ;get key number
  147.         mov     USER_KEY_NUMBER,cl
  148.  
  149.         ;set language and go process request
  150.         mov     XFACE_ID,VAR_ID                 ;get interface id
  151.         lea     dx,USER_BUF_ADDR                ;DX => user parms
  152.  
  153.         int     BTR_INT                         ;process request
  154.  
  155.         mov     cx,USER_BUF_LEN
  156.         les     si,dword ptr [bp]+DATA_LEN      ;get length address
  157.         mov     es:[si],cx                      ;reset length in user's space
  158. COB_2:
  159.         pop     si
  160.         pop     ds
  161.         pop     es
  162.         pop     bp
  163.         ret
  164. _BTRV   ENDP
  165.  
  166. CODE    ENDS
  167.         END
  168.  
  169.