home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / btree / mulkey / multrans.asm < prev    next >
Encoding:
Assembly Source File  |  1988-04-05  |  3.7 KB  |  107 lines

  1. ; Assembler interface to Turbo Pascal - MULKEY
  2. ;
  3. ; Copyright 1988 by Mark R. Boler  -  All Rights Reserved
  4.  
  5. TITLE     MULTRANS
  6.  
  7. DATA      SEGMENT WORD PUBLIC
  8.  
  9.           ASSUME  DS:DATA
  10.  
  11.           EXTRN   TransActive: BYTE
  12.           EXTRN   TransLocks : BYTE
  13.           EXTRN   IndexError : BYTE
  14.           EXTRN   LastErrCode: WORD
  15.  
  16. DATA      ENDS
  17.  
  18. CODE      SEGMENT WORD PUBLIC
  19.  
  20.           ASSUME  CS:CODE
  21.  
  22.           EXTRN   AdjOp : NEAR
  23.           EXTRN   SetErr: FAR
  24.           EXTRN   Btrv  : FAR
  25.  
  26.           PUBLIC  BeginTransaction
  27.           PUBLIC  AbortTransaction
  28.           PUBLIC  EndTransaction
  29.  
  30. FALSE     EQU     0
  31. TRUE      EQU     1
  32. LocalSize EQU     2
  33. BeginTransactionOp EQU 19
  34. EndTransactionOp   EQU 20
  35. AbortTransactionOp EQU 21
  36.  
  37. ; CallBtrv calls btrieve with dummy arguments for these procs and then SetErr
  38. ; call with:   ax = op code
  39.  
  40. CallBtrv  PROC    NEAR
  41.           sub     sp, LocalSize          ; make local data area
  42.           mov     bx, sp                 ; make bx = OFFSET of local data area
  43.           push    ax                     ; push op code in ax
  44.           push    ss                     ; dummy 1 - local data area
  45.           push    bx
  46.           push    ss                     ; dummy 2 - local data area
  47.           push    bx
  48.           push    ss                     ; dummy 3 - local data area
  49.           push    bx
  50.           push    ss                     ; dummy 4 - local data area
  51.           push    bx
  52.           mov     ax, LocalSize * 256    ; push 0
  53.           push    ax
  54.           mov     al, ah                 ; push local size
  55.           push    ax
  56.           call    Btrv                   ; call the routine
  57.           mov     bx, sp                 ; ss:[bx] = local data
  58.           mov     ss:[bx], ax            ; send status to seterr
  59.           call    SetErr                 ; call it and remove local data
  60.           ret                            ; return to caller
  61. CallBtrv  ENDP
  62.  
  63. ; PROCEDURE AbortTransaction; EXTERNAL;
  64.  
  65. AbortTransaction  PROC FAR
  66.           mov     ax, AbortTransactionOp ; load op code
  67.           call    CallBtrv               ; call local routine
  68.           mov     TransActive, FALSE     ; set it = FALSE
  69.           retf                           ; return to caller
  70. AbortTransaction  ENDP
  71.  
  72. ; PROCEDURE EndTransaction; EXTERNAL;
  73.  
  74. EndTransaction    PROC FAR
  75.           mov     ax, EndTransactionOp   ; load op code
  76.           call    CallBtrv               ; call local routine
  77.           cmp     IndexError, FALSE      ; if index error then jump
  78.           jne     SHORT EndError         ; else set and return
  79.           mov     TransActive, FALSE
  80.           retf                           ; return to caller
  81. EndError:
  82.           push    LastErrCode            ; save last error code
  83.           call    AbortTransaction       ; abort it if we can't end it
  84.           call    SetErr                 ; set last error code before abort
  85.           retf                           ; return to caller
  86. EndTransaction    ENDP
  87.  
  88. ; PROCEDURE BeginTransaction; EXTERNAL;
  89.  
  90. BeginTransaction  PROC FAR
  91.           cmp     TransActive, FALSE     ; see if a transaction is active
  92.           jz      SHORT BNotActive       ; jump if not
  93.           call    EndTransaction         ; end the current transaction first
  94. BNotActive:
  95.           mov     ax, BeginTransactionOp ; load op code
  96.           call    CallBtrv               ; call local routine
  97.           mov     al, IndexError         ; TransActive:= NOT IndexError
  98.           not     al
  99.           and     al, 00000001B
  100.           mov     TransActive, al
  101.           retf                           ; return to caller
  102. BeginTransaction  ENDP
  103.  
  104. CODE      ENDS
  105.  
  106.           END
  107.