home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 038 / pmd110.zip / WMEM.DIF < prev    next >
Text File  |  1994-11-14  |  4KB  |  160 lines

  1. *** c:\bp\rtl\sys\wmem.asm    Wed Oct 28 07:00:00 1992
  2. --- wmem.asm    Thu Aug 25 01:01:00 1994
  3. ***************
  4. *** 41,44 ****
  5. --- 41,49 ----
  6.       ENDIF
  7.   
  8. + ;;MemCheck externals
  9. +         EXTRN   CheckMEM:BYTE,StoreAlloc:DWORD,FreeAlloc:DWORD
  10.   ; Local variables
  11.   
  12. ***************
  13. *** 45,48 ****
  14. --- 50,57 ----
  15.   AllocSize    DW    ?
  16.   
  17. + ;; Memchecker variable
  18. + MemSize         DW      ?
  19.   DATA    ENDS
  20.   
  21. ***************
  22. *** 186,192 ****
  23.   NewMemory:
  24.   
  25.       OR    AX,AX
  26.       JE    @@7
  27. !     MOV    AllocSize,AX
  28.   @@1:    CMP    AX,HeapLimit
  29.       JB    @@2
  30. --- 195,220 ----
  31.   NewMemory:
  32.   
  33. + ;; memchecker code
  34. +         mov     [MemSize],ax
  35.       OR    AX,AX
  36.       JE    @@7
  37. ! ;; memchecker code
  38. ! ;; add 8 or 16 bytes to allocated memory for overflow checking
  39. !         cmp     CheckMem,0             ; is MemCheck code enabled?
  40. !         je      @@m1
  41. !         cmp     ax,65512               ; 65536-8-16
  42. !         ja      @@CheckUpperArea
  43. !         add     ax,16
  44. !         jmp     short @@m1
  45. ! @@CheckUpperArea:
  46. !         cmp     ax,65520               ; 65536-8-8
  47. !         ja      @@m1
  48. !         add     ax,8
  49. ! @@m1:
  50. !         MOV    AllocSize,AX
  51.   @@1:    CMP    AX,HeapLimit
  52.       JB    @@2
  53. ***************
  54. *** 218,222 ****
  55.   @@7:    XOR    AX,AX
  56.       CWD
  57. ! @@6:    RET
  58.   
  59.   ; Allocate global block
  60. --- 246,295 ----
  61.   @@7:    XOR    AX,AX
  62.       CWD
  63. ! @@6:
  64. ! ;; memchecker code
  65. !         jc      @@NoCheck         ; if error do not check
  66. !         cmp     CheckMem,0        ; is MemCheck code enabled
  67. !         je      @@NoCheck
  68. !         mov     cx,MemSize
  69. !         jcxz    @@NoCheck         ; if size = 0, don't check
  70. !         cmp     dx,0              ; check if returned pointer is nil
  71. !         je      @@NoCheck         ; don't check
  72. !         cmp     cx,65520          ; is there room for upper memory check?
  73. !         ja      @@StorePointer
  74. !         mov     si,ax             ; save ax
  75. !         mov     es,dx
  76. !         mov     di,ax
  77. !         add     di,cx
  78. !         cmp     cx,65512
  79. !         ja      @@m2
  80. !         add     di,8              ; correct if we have a lower memory also
  81. ! @@m2:   mov     ax,0cccch         ; fill last 8 bytes with 0CCh
  82. !         mov     cx,4
  83. !         cld
  84. !         rep     stosw
  85. !         mov     ax,si             ; restore ax
  86. !         mov     cx,MemSize
  87. !         cmp     cx,65512          ; is there room for lower memory check?
  88. !         ja      @@StorePointer
  89. !         mov     es,dx
  90. !         mov     di,ax
  91. !         mov     ax,0cccch         ; fill first 8 bytes with 0CCh
  92. !         mov     cx,4
  93. !         cld
  94. !         rep stosw
  95. !         mov     ax,di             ; first 8 bytes are skipped
  96. ! @@StorePointer:
  97. !         push    dx                ; push ptr
  98. !         push    ax
  99. !         push    [MemSize]         ; else push size
  100. !         call    dword ptr [StoreAlloc]
  101. ! @@NoCheck:
  102. !         RET
  103. ! ;ENDP
  104.   
  105.   ; Allocate global block
  106. ***************
  107. *** 356,359 ****
  108. --- 429,457 ----
  109.   DisMemory:
  110.   
  111. + ;; memchecker code
  112. +         cmp     CheckMem,0
  113. +         je      @@DisMemoryStart
  114. +         or      ax,ax                  ; if Size = 0
  115. +         jne     @@m1
  116. +         jmp     @@4                    ; then no check
  117. + @@m1:
  118. +         push    bx                     ; push ptr
  119. +         push    cx
  120. +         push    ax                     ; push size
  121. +         call    dword ptr [FreeAlloc]
  122. + ;; add the extra overflow memory area size
  123. +         cmp     ax,65512               ; 65536-8-16
  124. +         ja      @@UpperArea
  125. +         add     ax,16
  126. +         sub     cx,8
  127. +         jmp     short @@DisMemoryStart
  128. + @@UpperArea:
  129. +         cmp     ax,65520               ; 65536-8-8
  130. +         ja      @@DisMemoryStart
  131. +         add     ax,8
  132. + @@DisMemoryStart:
  133.       OR    AX,AX
  134.       JE    @@4
  135. ***************
  136. *** 429,432 ****
  137. --- 527,531 ----
  138.   @@9:    MOV    HeapList,AX
  139.       JMP    @@6
  140.   
  141.   CODE    ENDS
  142.