home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / ASM / GRDBDL17.ZIP / SEARCH.ASM < prev    next >
Encoding:
Assembly Source File  |  1998-10-26  |  2.4 KB  |  162 lines

  1. ;
  2. ; GRDP
  3. ;
  4. ; Copyright(c) LADsoft
  5. ;
  6. ; David Lindauer, camille@bluegrass.net
  7. ;
  8. ;
  9. ; SEARCH.ASM
  10. ;
  11. ; Function: Search memory
  12. ;
  13.     ;MASM MODE
  14.     .MODEL SMALL
  15.     .386
  16.  
  17.  
  18. include    eprints.inc 
  19. include    einput.inc 
  20. include    emtrap.inc 
  21. include    eoptions.inc
  22.  
  23.     PUBLIC    search
  24.     EXTRN    paddr:PROC
  25.     .data
  26. PSParglen    dw    0    ;#bytes in GRDBPSP:80h buffer
  27.  
  28.  
  29.     .CODE
  30. search    PROC
  31.     push    es
  32.     mov    [PSParglen],0
  33.     call    WadeSpace
  34.     jz    errx
  35.     call    ReadAddress    ; read address
  36.     jc    errx
  37.     mov    ecx,ebx
  38.     call    defDS        ; get DS
  39.     call    WadeSpace
  40.     jz    errx
  41.     push    ecx
  42.     mov    di,dx
  43.     push    di
  44.     call    ReadAddress    ; read len
  45.     pop    di
  46.     pop    ecx
  47.     jc    errx
  48.     or    edx,edx
  49.     jnz    hasseg2
  50.     mov    dx,di        ;default to first seg
  51. hasseg2:
  52.     mov    es,[psp]
  53.     push    di
  54.     mov    di,80h
  55. grablp:                ; read rest of params
  56.     call    WadeSpace
  57.     jz    grabdone
  58.     cmp    al,"'"
  59.     jz    readstring
  60.     cmp    al,'"'
  61.     jnz    readnum
  62. readstring:                 ; read a quoted string
  63.     inc    si
  64. readstringlp:
  65.     lodsb
  66.     cmp    al,13
  67.     jz    grabdone
  68.     cmp    al,'"'
  69.     jz    grablp
  70.     cmp    al,"'"
  71.     jz    grablp
  72.     stosb
  73.     inc    [PSParglen]
  74.     cmp    [PSParglen],080h
  75.     jnc    errx
  76.     jmp    readstringlp
  77.  
  78. readnum:            ; read an (8-bit) number
  79.     push    di
  80.     push    cx
  81.     call    ReadNumber
  82.     pop    cx
  83.     pop    di
  84.     jc    errx2
  85.     stosb
  86.     inc    [PSParglen]
  87.     cmp    [PSParglen],080h
  88.     jnc    errx
  89.     jmp    grablp
  90.  
  91. grabdone:                           ; all params got now
  92.     pop    di
  93.         test    [optdwordcommand],1     ; if not in flat real
  94.         jnz     gp2
  95.         movzx   ebx,bx                  ; make them 16-bit
  96.         movzx   ecx,cx
  97. gp2:
  98.     test    [PSParglen],0ffh        ; see if any search
  99.     jz    errx
  100.     movzx    edi,di
  101.     movzx    eax,dx             ; calculate length
  102.     shl    eax,4
  103.     add    ebx,eax
  104.     mov    edx,edi
  105.     mov    eax,edx
  106.     shl    eax,4
  107.     add    eax,ecx
  108.     sub    ebx,eax            ; ds:cx = start, ebx = len
  109.     push    ebx
  110.     call    CRLF
  111.     pop    ebx
  112.     pop    es
  113.     mov    esi,ecx
  114. noseg:
  115.         test    [optdwordcommand],1     ; if not in flat real
  116.         jnz     go1
  117.     cmp    si,8000h    ; adjust DS to keep search in bounds
  118.     jc    go1
  119.     sub    si,8000h
  120.         add    dx,800h
  121. go1:
  122. ;    call    ScanKey        ; I put this in for debug, but,
  123. ;    jnz    nofill2        ; good for mistakes too...
  124.     push    es
  125.     mov    es,[psp]
  126.     movzx    ecx,[PSParglen]
  127.     push    ds
  128.     mov    ds,dx
  129.     push    esi
  130.     mov    edi,80h
  131.     db    67h
  132.     repe    cmpsb
  133.     pop    esi
  134.     pop    ds
  135.     pop    es
  136.     jnz    nomatch
  137.     push    ebx
  138.     push    dx
  139.     mov    eax,esi
  140.     call    paddr
  141.     pop    dx
  142.     call    crlf
  143.     pop    ebx
  144. nomatch:
  145.     inc    esi
  146.     dec    ebx
  147.     jne    noseg
  148.     clc
  149.     ret
  150. nofill:
  151.     pop    es
  152. nofill2:
  153.     clc
  154.     ret
  155. errx2:
  156.     pop    di
  157. errx:
  158.     pop    es
  159.     stc
  160.     ret
  161. search    endp
  162. end