home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXLIB8F.ZIP / EMX / LIB / GCC / PROBE.S < prev    next >
Encoding:
Text File  |  1993-01-02  |  1.2 KB  |  32 lines

  1. / probe.s (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes
  2.  
  3.         .globl ___probe
  4.  
  5. / void __probe (size_t n)
  6.  
  7. / Note: this function does not modify any registers and removes
  8. /       its argument from the stack.
  9. /       Do not call this function from a C program!
  10.  
  11.         .text
  12.         .align  2, 0x90
  13. ___probe:
  14.         xchgl   1*4(%esp), %ebx         / save %ebx, put n into %ebx
  15.         pushl   %eax                    / save %eax
  16.         movl    %esp, %eax
  17.         subl    %ebx, %eax              / low address -> %eax
  18.         andl    $-4, %eax               / round down
  19.         movl    %esp, %ebx              / high address -> %ebx
  20.         .align  2, 0x90
  21. 1:      subl    $0x1000, %ebx           / move down
  22.         cmpl    %eax, %ebx              / low address reached?
  23.         jb      2f
  24.         testl   %eax, (%ebx)            / reference the page
  25.         jmp     1b                      / repeat
  26.  
  27.         .align  2, 0x90
  28. 2:      testl   %eax, (%eax)            / reference last page
  29.         popl    %eax                    / restore %eax
  30.         movl    1*4(%esp), %ebx         / restore %ebx
  31.         ret     $4                      / return, remove argument from stack
  32.