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

  1. ; Assembler interface to Turbo Pascal - MULKEY
  2. ;
  3. ; Copyright 1988 by Mark R. Boler  -  All Rights Reserved
  4.  
  5. TITLE     MULKEY
  6.  
  7. DATA      SEGMENT WORD PUBLIC
  8.  
  9.           EXTRN   KeyOnly    : BYTE
  10.           EXTRN   IndexError : BYTE
  11.           EXTRN   LastErrCode: WORD
  12.           EXTRN   MulPtr     : WORD
  13.  
  14. DATA      ENDS
  15.  
  16. CODE      SEGMENT WORD PUBLIC
  17.  
  18.           ASSUME  cs:CODE, ds:DATA
  19.  
  20.           PUBLIC  HandleActive, AdjOp    ; near functions
  21.           PUBLIC  SetErr                 ; far procedure
  22.  
  23. TRUE      EQU     1
  24. MaxMulkey EQU     40
  25. GetEqualOp         EQU 5
  26. GetHighestOp       EQU 13
  27. GetDirectOp        EQU 23
  28. BeginTransactionOp EQU 19
  29. StepDirectOp       EQU 24
  30. GetKeyOp           EQU 50
  31.  
  32. ; FUNCTION HandleActive(Handle: WORD): BOOLEAN; EXTERNAL;
  33.  
  34. Handle    EQU     WORD PTR ss:[bx + 2]   ; near procedure
  35.  
  36. HandleActive      PROC NEAR
  37.           mov     bx, sp                 ; set up stack frame in bx
  38.           mov     ax, Handle             ; get handle in ax
  39.           or      ax, ax                 ; see if handle is 0
  40.           jz      SHORT NoGood           ; jump if handle was 0
  41.           cmp     ax, MaxMulkey          ; see if handle > MaxMulkey
  42.           ja      SHORT SetNoGood        ; jump if handle > MaxMulkey
  43.           mov     bx, ax                 ; put handle in bx
  44.           dec     bx                     ; 0 base the handle
  45.           shl     bx, 1                  ; scale it for 4 byte pointers
  46.           shl     bx, 1
  47.           mov     ax, [bx + MulPtr]      ; get first word into ax
  48.           or      ax, [bx + MulPtr + 2]  ; OR with the next word
  49.           jz      SHORT NoGood           ; jump if both words were 0
  50.           mov     al, TRUE               ; set resturn value to TRUE
  51.           ret     2                      ; clean up and return to caller
  52. SetNoGood:
  53.           xor     al, al                 ; return FALSE
  54. NoGood:
  55.           ret     2                      ; clean up and return to caller
  56. HandleActive      ENDP
  57.  
  58. ; FUNCTION AdjOp(Op: WORD; LockAttr: FLockAttrib): WORD; EXTERNAL;
  59.  
  60. OpCode    EQU     WORD  PTR ss:[bx + 4]  ; near function
  61. LockAttr  EQU     BYTE  PTR ss:[bx + 2]
  62.  
  63. AdjOp     PROC    NEAR
  64.           mov     bx, sp                 ; set up stack frame in bx
  65.           mov     ax, OpCode             ; get op code into ax
  66.           cmp     ax, GetEqualOp         ; if op code > getEqualOp then return
  67.           jb      SHORT AdjDone
  68.           mov     dl, LockAttr           ; get lock attribute in dl
  69.           mov     bx, ax                 ; save op code in bx
  70.           or      dl, dl                 ; if lock attrib = 0 then jump past
  71.           jz      SHORT CkKey
  72.           cmp     ax, GetHighestOp
  73.           jbe     SHORT AdjustIt         ; jump forward to adjust
  74.           cmp     ax, GetDirectOp
  75.           je      SHORT AdjustIt         ; jump forward to adjust
  76.           cmp     ax, StepDirectOp
  77.           je      SHORT AdjustIt         ; jump forward to adjust
  78.           cmp     ax, BeginTransactionOp
  79.           jne     SHORT CkKey            ; jump if we are not to adjust
  80. AdjustIt:
  81.           add     ax, 100                ; add 100 to op code
  82.           test    dl, 00000001B          ; if bit is not set then add another
  83.           jnz     SHORT WaitLocks        ; jump if only wait locks
  84.           add     ax, 100                ; add another 100
  85. WaitLocks:
  86.           cmp     dl, 3                  ; see if multi locks
  87.           jb      SHORT CkKey            ; jump if not multi locks
  88.           add     ax, 200                ; adjust op code for multi locks
  89. CkKey:
  90.           cmp     KeyOnly, 0             ; if keyonly = 0 then return now
  91.           jnz     SHORT SetKey
  92. AdjDone:
  93.           ret     4                      ; clean up and return to caller
  94. SetKey:
  95.           cmp     bx, GetHighestOp       ; if op code > gethighestop
  96.           ja      SHORT AdjDone          ; then return now
  97.           add     ax, GetKeyOp           ; adjust the op code
  98.           ret     4                      ; clean up and return to caller
  99. AdjOp     ENDP
  100.  
  101. ; PROCEDURE SetErr(Status: WORD); EXTERNAL;
  102.  
  103. Status    EQU     WORD PTR ss:[bx + 4]   ; far procedure
  104.  
  105. SetErr    PROC    FAR
  106.           mov     bx, sp                 ; set up stack frame in bx
  107.           mov     ax, Status             ; get status in ax
  108.           mov     LastErrCode, ax        ; store LastErrCode variable
  109.           or      ax, ax                 ; see if ax = 0
  110.           jnz     SHORT SetError         ; jump if not zero
  111.           mov     IndexError, al         ; set IndexError variable to FALSE
  112.           retf    2                      ; clean up and return to caller
  113. SetError:
  114.           mov     IndexError, TRUE       ; set IndexError variable to TRUE
  115.           retf    2                      ; clean up and return to caller
  116. SetErr    ENDP
  117.  
  118. CODE      ENDS
  119.  
  120.           END
  121.