home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH15 / STRDEMO.ASM < prev    next >
Encoding:
Assembly Source File  |  1996-03-25  |  2.6 KB  |  177 lines

  1. ; StrDemo.asm-    Demonstration of some of the various UCR Standard Library 
  2. ;        string routines.
  3.  
  4.         include        stdlib.a
  5.         includelib     stdlib.lib
  6.  
  7. dseg        segment    para public 'data'
  8.  
  9. MemAvail    dw    ?
  10. String        byte    256 dup (0)
  11.  
  12. dseg        ends
  13.  
  14.  
  15.  
  16. cseg        segment    para public 'code'
  17.         assume    cs:cseg, ds:dseg
  18.  
  19.  
  20. Main        proc
  21.         mov    ax, seg dseg        ;Set up the segment registers
  22.         mov    ds, ax
  23.         mov    es, ax
  24.  
  25.         MemInit
  26.         mov    MemAvail, cx
  27.         printf
  28.         db    "There are %x paragraphs of memory available."
  29.         db    cr,lf,lf,0
  30.         dd    MemAvail
  31.  
  32. ; Demonstration of StrTrim:
  33.  
  34.         print
  35.         db    "Testing strtrim on 'Hello there   '",cr,lf,0
  36.         strdupl
  37. HelloThere1    db    "Hello there   ",0
  38.         strtrim
  39.         mov    al, "'"
  40.         putc
  41.         puts
  42.         putc
  43.         putcr
  44.         free
  45.  
  46. ;Demonstration of StrTrimm:
  47.  
  48.         print
  49.         db    "Testing strtrimm on 'Hello there   '",cr,lf,0
  50.         lesi    HelloThere1
  51.         strtrimm
  52.         mov    al, "'"
  53.         putc
  54.         puts
  55.         putc
  56.         putcr
  57.         free
  58.  
  59. ; Demonstration of StrBdel
  60.  
  61.         print
  62.         db    "Testing strbdel on '  Hello there   '",cr,lf,0
  63.         strdupl
  64. HelloThere3    db    "  Hello there   ",0
  65.         strbdel
  66.         mov    al, "'"
  67.         putc
  68.         puts
  69.         putc
  70.         putcr
  71.         free
  72.  
  73. ; Demonstration of StrBdelm
  74.  
  75.         print
  76.         db    "Testing strbdelm on '  Hello there   '",cr,lf,0
  77.         lesi    HelloThere3
  78.         strbdelm
  79.         mov    al, "'"
  80.         putc
  81.         puts
  82.         putc
  83.         putcr
  84.         free
  85.  
  86.  
  87. ; Demonstrate StrCpyl:
  88.  
  89.         ldxi    string
  90.         strcpyl
  91.         byte    "Copy this string to the 'String' variable",0
  92.  
  93.         printf
  94.         byte    "STRING = '%s'",cr,lf,0
  95.         dword    String
  96.  
  97. ; Demonstrate StrCatl:
  98.  
  99.         lesi    String
  100.         strcatl
  101.         byte    ". Put at end of 'String'",0
  102.  
  103.         printf
  104.         byte    "STRING = ",'"%s"',cr,lf,0
  105.         dword    String
  106.  
  107. ; Demonstrate StrChr:
  108.  
  109.         lesi    String
  110.         mov    al, "'"
  111.         strchr
  112.  
  113.         print
  114.         byte    "StrChr: First occurrence of ", '"', "'"
  115.         byte    '" found at position ',0
  116.         mov    ax, cx
  117.         puti
  118.         putcr
  119.  
  120. ; Demonstrate StrStrl:
  121.  
  122.         lesi    String
  123.         strstrl
  124.         byte    "String",0
  125.  
  126.         print
  127.         byte    'StrStr: First occurrence of "String" found at position ',0
  128.  
  129.         mov    ax, cx
  130.         puti
  131.         putcr
  132.  
  133. ; Demo of StrSet
  134.  
  135.         lesi    String
  136.         mov    al, '*'
  137.         strset
  138.  
  139.         printf
  140.         byte    "Strset:  '%s'",cr,lf,0
  141.         dword    String
  142.  
  143. ; Demo of strlen
  144.  
  145.         lesi    String
  146.         strlen
  147.  
  148.         print
  149.         byte    "String length = ",0
  150.         puti
  151.         putcr
  152.  
  153.  
  154.  
  155.  
  156. Quit:        mov     ah, 4ch
  157.         int     21h
  158. Main        endp
  159.  
  160. cseg        ends
  161.  
  162. ; Allocate a reasonable amount of space for the stack (2k).
  163.  
  164. sseg        segment    para stack 'stack'
  165. stk        db    256 dup ("stack   ")
  166. sseg        ends
  167.  
  168.  
  169.  
  170. ; zzzzzzseg must be the last segment that gets loaded into memory!
  171.  
  172. zzzzzzseg    segment    para public 'zzzzzz'
  173. LastBytes    db    16 dup (?)
  174. heap        db    1024 dup (?)
  175. zzzzzzseg    ends
  176.         end    Main
  177.