home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / CLIPB52.ZIP / MARTIN.ZIP / UDF3.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-06-02  |  1.8 KB  |  60 lines

  1. TITLE   UDF3.ASM - Assembly Language functions for CLIPPER
  2. ;                  by Gregory A. Martin
  3. ;       These functions may be freely used, but may not be published.
  4.  
  5. INCLUDE EXTENDA.INC
  6.  
  7. PUSH_ALL macro
  8.   $gen <                push ds>
  9.   $gen <                push es>
  10.   $gen <                push si>
  11.   $gen <                push di>
  12. endm
  13.  
  14. POP_ALL macro
  15.   $gen <                pop di>
  16.   $gen <                pop si>
  17.   $gen <                pop es>
  18.   $gen <                pop ds>
  19. endm
  20.  
  21.  
  22. CLpublic <INCOUNT>
  23.  
  24.  
  25. ;----------------------------------
  26. ;  InCount
  27. ;-----------------------------------
  28. CLfunc long INCOUNT <char string, char character>
  29. CLcode
  30.                 PUSH_ALL
  31.  
  32.                 Ccall   _parclen <1, 0> ; get character length
  33.                 cmp     ax,     0       ; null string?
  34.                 je      InCount_End
  35.  
  36.                 lds     si,     character
  37.                 mov     bl,     [si]
  38.                 lds     si,     string  ; load ptr to string
  39.                 mov     cx,     ax      ; move count to cx
  40.                 mov     ax,     0       ; load long int with 0
  41. InCount_For:    cmp     byte ptr [si], bl  ; compare char to return
  42.                 jne     InCount_Skip
  43.                 inc     ax              ; increment count
  44. InCount_Skip:   inc     si              ; increment pointer
  45.                 jz      InCount_Inc     ; increment dataseg if needed
  46. InCount_Next:   loop    InCount_For
  47.                 jmp     InCount_End
  48.  
  49. InCount_Inc:    mov     bx,     ds
  50.                 add     bx,     4096    ; add 64K to ds seg
  51.                 mov     ds,     bx
  52.                 jmp     InCount_Next
  53.                 
  54. InCount_End:    POP_ALL
  55.                 mov     bx,     0
  56.                 CLret bx ax
  57.  
  58.  
  59. END
  60.