home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / stdlib.zip / TEST.ASM < prev    next >
Assembly Source File  |  1991-03-13  |  31KB  |  1,813 lines

  1.         include    stdlib.a
  2. ;****************************************************************************
  3. ;
  4. ; T  E  S  T       S  U  I  T  E      F  O  R   
  5. ;
  6. ;
  7. ; R  A  N  D  Y      H  Y  D  E ' S     S  T  A  N  D  A  R  D
  8. ;
  9. ; L  I  B  R  A  R  Y     F  O  R     A  S  S  E  M  B  L  Y   
  10. ;
  11. ; L  A  N  G  U  A  G  E     P  R  O  G  R  A  M  M  E  R  S
  12. ;
  13. ;****************************************************************************
  14. ;
  15. ;
  16. ; Global variables go here:
  17. ;
  18. dseg        segment    para public 'data'
  19. i        dw    -4321
  20. pi        dd    i
  21. u        dw    2345
  22. pu        dd    u
  23. l        dd    -1234567890
  24. pl        dd    l
  25. ul        dd    987654321
  26. pul        dd    ul
  27. ;
  28. ps        dd    s
  29. s        db    "Printf string",0
  30. TestString0    db    "This string gets printed by puts!",cr,lf,0
  31. TestString1    db    "This string gets used by the STRxxx Routines",cr,lf,0
  32. TestString2    db    "gets",0
  33. TestString3    db    "Hello there",0
  34. TestString4    db    "THIS STRING GETS USED BY THE STRXXX ROUTINES",cr,lf,0
  35. TestString5    db    "all lower case",cr,lf,0
  36. TestString6    db    "Clear out this string",0
  37. StringSet1    db    "Tabcdefghijklmnopqrst ",0
  38. StringSet2    db    "uvwxyz!",0
  39. InsStrSrc    db    "Insert This",0
  40. InsStrDest    db    "--><--",0
  41. RevStr1        db    "012345",0
  42. RevStr2        db    "0123456",0
  43. RevStr3        db    "1",0
  44. RevStr4        db    0
  45. buffer        db    256 dup (?)
  46. buffer2        db    256 dup (?)
  47. sfstr1        db    "1 -1 1 65000 100000 -100000 1 4000000000 0abc x",0
  48. sfstr2        db    "1, 2",0
  49. hex1        db    "12ab",0
  50. int1        db    "-12345",0
  51. int2        db    "65000",0
  52. lint1        db    "-2000000000",0
  53. lint2        db    "4000000000",0
  54. i1        dw    ?
  55. i2        dw    ?
  56. u1        dw    ?
  57. u2        dw    ?
  58. l1        dd    ?
  59. l2        dd    ?
  60. ul1        dd    ?
  61. ul2        dd    ?
  62. h1        dw    ?
  63. c1        db    ?
  64. c2        db    '!'
  65. MemAvail    dw    ?
  66. ;
  67. ; Allocate some character sets down here
  68. ;
  69.         set    charset, cs2, cs3, cs4
  70. ;
  71. dseg        ends
  72. ;
  73. ;
  74. ;
  75. ;
  76. cseg        segment    para public 'code'
  77.         assume    cs:cseg, ds:dseg
  78. ;
  79. ;
  80. lesi        macro    adrs
  81.         mov     di, seg adrs
  82.         mov    es, di
  83.         lea    di, adrs
  84.         endm
  85. ;
  86. ldxi        macro    adrs
  87.         mov    dx, seg adrs
  88.         lea    si, adrs
  89.         endm
  90. ;
  91. ; Variables that wind up being used by the standard library routines.
  92. ; The MemInit routine uses "PSP" and "zzzzzzseg" labels.  They must be
  93. ; present if you intend to use getenv, MemInit, malloc, and free.
  94. ;
  95. ;
  96.         public    PSP
  97. PSP        dw    ?
  98. ;
  99. cr        equ    13
  100. lf        equ    10
  101. ;
  102. ;
  103. ; Main is the main program.  Program execution always begins here.
  104. ;
  105. Main        proc
  106.         mov    cs:PSP, es        ;Save pgm seg prefix
  107.         mov    ax, seg dseg        ;Set up the segment registers
  108.         mov    ds, ax
  109.         mov    es, ax
  110.         mov    dx, 0            ;Allocate all available RAM.
  111.         MemInit
  112.         mov    MemAvail, cx
  113.         printf
  114.         db    "There are %x paragraphs of memory available."
  115.         db    cr,lf,lf,0
  116.         dd    MemAvail
  117. ;
  118. ;
  119. ;
  120. ;
  121. ;***************************************************************************
  122. ;
  123. ; Test the StrRev and StrRev2 routines here.
  124. ;
  125.         print
  126.         db    "Testing StrRev:",cr,lf,0
  127.         lesi    RevStr1
  128.         strrev
  129.         puts
  130.         putcr
  131.         strrev
  132.         puts
  133.         putcr
  134.                 putcr
  135. ;
  136.         lesi    RevStr2
  137.         strrev
  138.         puts
  139.         putcr
  140.         strrev
  141.         puts
  142.         putcr
  143.                 putcr
  144. ;
  145.         lesi    RevStr3
  146.         strrev
  147.         puts
  148.         putcr
  149.         strrev
  150.         puts
  151.         putcr
  152.                 putcr
  153. ;
  154.         lesi    RevStr4
  155.         strrev
  156.         puts
  157.         putcr
  158.         strrev
  159.         puts
  160.         putcr
  161. ;
  162. ;
  163.         print
  164.         db    "Testing StrRev2:",cr,lf,0
  165.         lesi    RevStr1
  166.         strrev2
  167.         puts
  168.         putcr
  169.         free
  170. ;
  171.         lesi    RevStr2
  172.         strrev2
  173.         puts
  174.         putcr
  175.         free
  176. ;
  177.         lesi    RevStr3
  178.         strrev2
  179.         puts
  180.         putcr
  181.         free
  182. ;
  183.         lesi    RevStr4
  184.         strrev2
  185.         puts
  186.         putcr
  187.         free
  188.         putcr
  189. ;
  190. ;
  191. ;***************************************************************************
  192. ;
  193. ; Test the STRINS and STRDEL routines here.
  194. ;
  195.         print
  196.         db    "Testing StrDel:",cr,lf,0
  197.         ldxi    buffer
  198.         lesi    InsStrDest
  199.         strcpy
  200.         mov    ax, 2
  201.         mov    cx, ax
  202.         strdel
  203.         puts
  204.         putcr
  205. ;
  206.         ldxi    buffer
  207.         lesi    InsStrDest
  208.         strcpy
  209.         mov    ax, 20
  210.         mov    cx, 2
  211.         strdel
  212.         puts
  213.         putcr
  214. ;
  215.         print
  216.         db    "Testing StrDel2:",cr,lf,0
  217.         lesi    InsStrDest
  218.         mov    ax, 2
  219.         mov    cx, ax
  220.         strdel2
  221.         puts
  222.         putcr
  223.         free
  224. ;
  225.         lesi    InsStrDest
  226.         mov    ax, 20
  227.         mov    cx, 2
  228.         strdel2
  229.         puts
  230.         putcr
  231.         free
  232. ;
  233.         print
  234.         db    "Testing StrInsl:",cr,lf,0
  235.         ldxi    buffer
  236.         lesi    InsStrDest
  237.         strcpy
  238. ;
  239.         mov    cx, 3
  240.         strinsl
  241.         db    "Hi there",0
  242.         puts
  243.         putcr
  244. ;
  245.         print
  246.         db    "Testing StrIns2l:",cr,lf,0
  247.         lesi    InsStrDest
  248.         mov    cx, 3
  249.         strins2l
  250.         db    "Ho ho ho!",0
  251.         puts
  252.         putcr
  253.         free
  254. ;
  255.         lesi    InsStrDest
  256.         mov    cx, 100
  257.         strins2l
  258.         db    "and a bottle of rum!",cr,lf,0
  259.         puts
  260.         putcr
  261.         free
  262. ;
  263.         print
  264.         db    "Testing STRINS2:",cr,lf,0
  265.         lesi    InsStrDest
  266.         ldxi    InsStrSrc
  267.         mov    cx, 3
  268.         strins2
  269.         jnc    GoodStrins2
  270.         print
  271.         db    "Could not allocate memory for StrIns2",cr,lf,0
  272.         jmp    short BadStrins2
  273. ;
  274. GoodStrins2:    puts
  275.         putcr
  276.         free
  277. ;
  278. BadStrIns2:    lesi    InsStrDest
  279.         ldxi    InsStrSrc
  280.         mov    cx, 100
  281.         strins2
  282.         jnc    GoodSI2
  283.         print
  284.         db    "Strins2:memory allocation error",cr,lf,0
  285.         jmp    short BSI2
  286. ;
  287. GoodSI2:    puts
  288.         putcr
  289.         free
  290. ;
  291. BSI2:        print
  292.         db    "Testing STRINS:",cr,lf,0
  293.         lesi    InsStrDest
  294.         ldxi    InsStrSrc
  295.         mov    cx, 3
  296.         strins
  297.         puts
  298.         putcr
  299.         lesi    InsStrDest
  300.         ldxi    InsStrSrc
  301.         mov    cx, 100
  302.         strins
  303.         puts
  304.         putcr
  305. ;
  306. ;
  307. ;***************************************************************************
  308. ;
  309. ; Test the character set routines down here:
  310. ;
  311.         print  
  312.         db    "Testing RangeSet:",cr,lf,0
  313.         mov    al, 'A'
  314.         mov    ah, 'F'
  315.         lesi    CharSet
  316.         rangeset
  317.         print
  318.         db    "Chars in set: ",0
  319.         call    PrintSet
  320. ;
  321.         print
  322.         db    cr,lf,lf,"Testing addstr, addstrl:",cr,lf,0
  323.         lesi    cs2
  324.         ldxi    StringSet2
  325.         addstr
  326.         addstrl
  327.         db    "aAbBcCdDeEfF",0
  328.         print
  329.         db    "Chars in set: ",0
  330.         call    PrintSet
  331. ;
  332.         print
  333.         db    cr,lf,lf,"Testing rmvstr, rmvstrl:",cr,lf,0
  334.         lesi    cs2
  335.         ldxi    StringSet2
  336.         rmvstr
  337.         rmvstrl
  338.         db    "ABCDEF",0
  339.         print
  340.         db    "Chars in set: ",0
  341.         call    PrintSet
  342. ;
  343.         print
  344.         db    cr,lf,lf,"Testing addchar/rmvchar:",cr,lf,0
  345.         lesi    cs2
  346.         mov    al, 'A'
  347.         addchar
  348.         mov    al, 'a'
  349.         rmvchar
  350.         print
  351.         db    "Chars in set: ",0
  352.         call    PrintSet
  353. ;
  354.         print
  355.         db    cr,lf,lf,"Testing emptyset:",cr,lf,0
  356.         emptyset
  357.         print
  358.         db    "Chars in set: ",0
  359.         call    PrintSet
  360. ;
  361.         print
  362.         db    cr,lf,lf,"Testing member:",cr,lf,0
  363.         addstrl
  364.         db    "ABCDEF",0
  365.         mov    al, 'A'
  366.         member
  367.         jne    NotInSet1
  368.         print
  369.         db    "A was not in the set",0
  370.         jmp    short NIS1
  371. ;
  372. NotInSet1:    print
  373.         db    "A is in the set",0
  374. NIS1:        putcr
  375.         mov    al, "G"
  376.         member
  377.         jne    NotInSet2
  378.         print
  379.         db    "G is not in the set",0
  380.         jmp    short NIS2
  381. ;
  382. NotInSet2:    print
  383.         db    "G is in the set",0
  384. NIS2:        putcr
  385. ;
  386.         print
  387.         db    cr,lf,lf,"Testing copyset:",cr,lf,0
  388.         mov    dx, es
  389.         mov    si, di
  390.         lesi    cs3
  391.         copyset
  392.         print
  393.         db    "Value in cs3: ",0
  394.         call    Printset
  395. ;
  396.         print    
  397.         db    cr,lf,lf,"Testing unionset:",cr,lf,0
  398.         addstrl
  399.         db    "ABCDEFuvwxyz",0
  400.         ldxi    cs2
  401.         setunion
  402.         print
  403.         db    "Chars in set: ",0
  404.         call    Printset
  405. ;
  406.         print
  407.         db    cr,lf,lf,"Testing set difference",cr,lf,0
  408.         ldxi    cs2
  409.         setdifference
  410.         print
  411.         db    "Chars in set: ",0
  412.         call    PrintSet
  413. ;
  414. ;
  415. ;
  416. ;***************************************************************************
  417. ;
  418. ; Test the STRxxx routines here.
  419. ;
  420. ;
  421. ;*Strspan
  422. ;
  423.         print
  424.         db    cr,lf,lf,"Testing strspan:",cr,lf,0
  425. ;
  426.         lesi    TestString1
  427.         ldxi    StringSet1
  428.         strspan
  429.         mov    i1, cx
  430.         printf
  431.         db    "TestString1 contains a character not found in "
  432.         db    "StringSet1 at position %d\n\n",0
  433.         dd    i1
  434. ;
  435. ;
  436. ;*Strspanl
  437. ;
  438.         print
  439.         db    "Testing strspanl:",cr,lf,0
  440. ;
  441.         lesi    TestString1
  442.         strspanl
  443.         db    "Tabcdefghijklmnopqrst ",0
  444.         mov    i1, cx
  445.         printf
  446.         db    "TestString1 contains a character not found in "
  447.         db    "the set at position %d\n\n",0
  448.         dd    i1
  449. ;
  450. ;
  451. ;*Strcspan
  452. ;
  453.         print
  454.         db    "Testing strcspan:",cr,lf,0
  455. ;
  456.         lesi    TestString1
  457.         ldxi    StringSet2
  458.         strcspan
  459.         mov    i1, cx
  460.         printf
  461.         db    "TestString1 contains a character found in "
  462.         db    "StringSet2 at position %d\n\n",0
  463.         dd    i1
  464. ;
  465. ;
  466. ;*Strcspanl
  467. ;
  468.         print
  469.         db    "Testing strcspanl:",cr,lf,0
  470. ;
  471.         lesi    TestString1
  472.         strcspanl
  473.         db    "uvwxyz!",0
  474.         mov    i1, cx
  475.         printf
  476.         db    "TestString1 contains a character not found in "
  477.         db    "the set at position %d\n\n",0
  478.         dd    i1
  479. ;
  480. ;
  481. ;*Strset, Strset2
  482. ;
  483.         print
  484.         db    "Testing Strset",cr,lf,0
  485. ;
  486.         lesi    TestString6
  487.         mov    al, '*'
  488.         strset
  489.         puts
  490. ;
  491. ;
  492.         print
  493.         db    cr,lf,lf,"Testing StrSet2:",cr,lf,0
  494.         mov    cx, 32
  495.         mov    al, '#'
  496.         strset2
  497.         puts
  498.         free
  499.         putcr
  500.         putcr
  501. ;
  502. ;
  503. ;*Strupr, Strupr2
  504. ;
  505.         printf
  506.         db    "Testing Strupr:\n"
  507.         db    "Before: %s",0
  508.         dd    TestString5
  509.         lesi    TestString5
  510.         strupr
  511.         printf
  512.         db    "After: %s",0
  513.         dd    TestString5
  514. ;
  515. ;
  516. ;*Strlwr, Strlwr2
  517. ;
  518.         printf
  519.         db    cr,lf,"Testing Strlwr:\n"
  520.         db    "Before: %s",0
  521.         dd    TestString5
  522.         lesi    TestString5
  523.         strlwr
  524.         printf
  525.         db    "After: %s",0
  526.         dd    TestString5
  527. ;
  528. ;
  529. ;
  530. ;*Strcmp, Strcmpl
  531. ;
  532.         print
  533.         db    "Testing Strcmp",cr,lf,0
  534. ;
  535.         lesi    TestString1
  536.         ldxi    TestString1
  537.         strcmp
  538.         jne    Sne1
  539.         print
  540.         db    "TestString1 == TestString1",cr,lf,0
  541.         jmp    short s2
  542. ;
  543. Sne1:        print
  544.         db    "TestString1 <> TestString1",cr,lf,0
  545. ;
  546. s2:        ldxi    TestString0
  547.         strcmp
  548.         jb    IsBelow
  549.         ja    IsAbove
  550.         printf
  551.         db    "'%s' is equal to '%s'\n",0
  552.         dd    TestString1, TestString0
  553.         jmp    short s3
  554. ;
  555. IsBelow:    printf
  556.         db    "%s is less than \n%s\n",0
  557.         dd    TestString1, TestString0
  558.         jmp    short s3
  559. ;
  560. IsAbove:    printf
  561.         db    "%s is greater than \n%s\n",0
  562.         dd    TestString1, TestString0
  563. ;
  564. S3:
  565. ;
  566.         print
  567.         db    cr,lf,"Testing Strcmpl",cr,lf,0
  568. ;
  569.         lesi    TestString2
  570.         strcmpl
  571.         db    "gets",0
  572.         jne    Sne1a
  573.         print
  574.         db    "TestString2 == 'gets'",cr,lf,0
  575.         jmp    short s2a
  576. ;
  577. Sne1a:        print
  578.         db    "TestString2 <> 'gets'",cr,lf,0
  579. ;
  580. s2a:        lesi    TestString2
  581.         strcmpl
  582.         db    "itsa",0
  583.         jb    IsBelowa
  584.         ja    IsAbovea
  585.         printf
  586.         db    "'%s' is equal to 'itsa'\n",0
  587.         dd    TestString2
  588.         jmp    short s3a
  589. ;
  590. IsBelowa:    printf
  591.         db    "'%s' is less than 'itsa'\n",0
  592.         dd    TestString2
  593.         jmp    short s3a
  594. ;
  595. IsAbovea:    printf
  596.         db    "'%s' is greater than 'itsa'\n",0
  597.         dd    TestString2
  598. ;
  599. S3a:
  600. ;
  601. ;
  602. ;*Stricmp, Stricmpl
  603. ;
  604.         print
  605.         db    cr,lf,"Testing Stricmp",cr,lf,0
  606. ;
  607.         lesi    TestString1
  608.         ldxi    TestString4
  609.         stricmp
  610.         jne    Sne1c
  611.         print
  612.         db    "TestString1 == TestString4",cr,lf,0
  613.         jmp    short s2c
  614. ;
  615. Sne1c:        print
  616.         db    "TestString1 <> TestString4",cr,lf,0
  617. ;
  618. s2c:        lesi    TestString1
  619.         ldxi    TestString4
  620.         stricmp
  621.         jb    IsBelowc
  622.         ja    IsAbovec
  623.         printf
  624.         db    "'%s' is equal to '%s'\n",0
  625.         dd    TestString1, TestString4
  626.         jmp    short s3c
  627. ;
  628. IsBelowc:    printf
  629.         db    "'%s' is less than '%s'\n",0
  630.         dd    TestString1, TestString4
  631.         jmp    short s3c
  632. ;
  633. IsAbovec:    printf
  634.         db    "'%s' is greater than '%s'\n",0
  635.         dd    TestString1, TestString4
  636. ;
  637. S3c:
  638. ;
  639. ;
  640.         print
  641.         db    "Testing Stricmpl",cr,lf,0
  642. ;
  643.         lesi    TestString2
  644.         stricmpl
  645.         db    "GETS",0
  646.         jne    Sne1d
  647.         print
  648.         db    "TestString2 == 'gets'",cr,lf,0
  649.         jmp    short s2d
  650. ;
  651. Sne1d:        print
  652.         db    "TestString2 <> 'gets'",cr,lf,0
  653. ;
  654. s2d:        lesi    TestString2
  655.         strcmpl
  656.         db    "itsa",0
  657.         jb    IsBelowd
  658.         ja    IsAboved
  659.         printf
  660.         db    "'%s' is equal to 'itsa'\n",0
  661.         dd    TestString2
  662.         jmp    short s3d
  663. ;
  664. IsBelowd:    printf
  665.         db    "'%s' is less than 'itsa'\n",0
  666.         dd    TestString2
  667.         jmp    short s3d
  668. ;
  669. IsAboved:    printf
  670.         db    "'%s' is greater than 'itsa'\n",0
  671.         dd    TestString2
  672. ;
  673. S3d:
  674. ;
  675. ;
  676. ;*Strcpy
  677. ;
  678.         lesi    TestString1
  679.         ldxi    Buffer
  680.         strcpy
  681.         puts
  682. ;
  683. ;*Strcpyl
  684. ;
  685.         print
  686.         db    "Testing Strcpyl:",cr,lf,0
  687. ;
  688.         ldxi    Buffer
  689.         strcpyl
  690.         db    "This is an strcpyl string",cr,lf,0
  691.         puts
  692.         ldxi    Buffer2
  693.         strcpy
  694.         puts
  695. ;
  696. ;*Strdup
  697. ;
  698.         lesi    TestString1
  699.         strdup          
  700.         puts
  701.         free
  702. ;
  703. ;*Strdupl
  704. ;
  705.         print
  706.         db    "Testing Strdupl:",cr,lf,0
  707. ;
  708.         strdupl
  709.         db    "This string is for strdupl",cr,lf,0
  710.         puts
  711.         free
  712. ;
  713. ;*Strlen
  714. ;
  715.         lesi    s
  716.         strlen
  717.         mov    i1, cx
  718.         printf
  719.         db    "Length of string: '%s' is %d\n",0
  720.         dd    s, i1
  721. ;
  722. ;*Strcat
  723. ;
  724.         print
  725.         db      "Testing strcat:",cr,lf,0
  726. ;
  727.         lesi    Buffer
  728.         strcpyl
  729.         db    "Test String 1 --",0
  730.         ldxi    TestString1
  731.         strcat
  732.         puts
  733. ;
  734. ;*Strcatl
  735. ;
  736.         print
  737.         db      "Testing strcatl:",cr,lf,0
  738. ;
  739.         lesi    Buffer
  740.         strcpyl
  741.         db    "Strcatl test --",0
  742.         strcatl
  743.         db    "More stuff for Strcatl",cr,lf,0
  744.         puts
  745. ;
  746. ;*Strcat2
  747. ;
  748.         print
  749.         db    "Testing strcat2:",cr,lf,0
  750. ;
  751.         lesi    TestString1
  752.         ldxi    TestString0
  753.         strcat2
  754.         puts
  755.         free
  756. ;
  757.         print
  758.         db    "Testing strcat2l:",cr,lf,0
  759. ;
  760.         lesi    TestString1
  761.         strcat2l
  762.         db    "Appended string",cr,lf,0
  763.         puts
  764.         free
  765. ;
  766. ;*Strchar
  767. ;                     
  768.         lesi    TestString1
  769.         mov    al, 'a'
  770.         StrChr
  771.         pushf
  772.         mov    i1, cx
  773.         printf
  774.         db    "Testing strchr:",cr,lf
  775.         db    "Searching for 'a' in '%s'\n"
  776.         db    "Found it at position %d\n",0
  777.         dd    TestString1, i1
  778.         popf
  779.         jnc    FndIt1
  780.         print
  781.         db    "Could not find character in string.",cr,lf,0
  782. ;
  783. FndIt1:        lesi    TestString1
  784.         mov    al, 'T'
  785.         StrChr
  786.         pushf
  787.         mov    i1, cx
  788.         printf
  789.         db    "Testing strchr:",cr,lf
  790.         db    "Searching for 'T' in '%s'\n"
  791.         db    "Found it at position %d\n",0
  792.         dd    TestString1, i1
  793.         popf
  794.         jnc    FndIt2
  795.         print
  796.         db    "Could not find character in string.",cr,lf,0
  797. FndIt2:
  798. ;
  799. ;
  800. ;*Strstr
  801. ;
  802.         print
  803.         db    "Testing strstr:",cr,lf,0
  804. ;
  805.         lesi    TestString1
  806.         ldxi    TestString2
  807.         strstr
  808.         jc    NotFnd2
  809.         mov    i1, cx
  810.         printf
  811.         db    "Found substring at position %i\n",0
  812.         dd    i1
  813.         jmp    short FndIt3
  814. ;
  815. NotFnd2:    print
  816.         db    "Didn't find substring #1.",cr,lf,0
  817. ;
  818. FndIt3:        ldxi    TestString3
  819.         strstr
  820.         jc    NotFnd3
  821.         print
  822.         db    "Error, found a string which isn't present!",cr,lf,0
  823. ;
  824. NotFnd3:
  825. ;
  826. ;
  827. ;*Strstrl
  828. ;
  829.         print
  830.         db    "Testing strstrl:",cr,lf,0
  831. ;
  832.         lesi    TestString1
  833.         strstrl
  834.         db    "gets",0
  835.         jc    NotFnd2a
  836.         mov    i1, cx
  837.         printf
  838.         db    "Found substring at position %i\n",0
  839.         dd    i1
  840.         jmp    short FndIt3a
  841. ;
  842. NotFnd2a:    print
  843.         db    "Didn't find substring #1.",cr,lf,0
  844. ;
  845. FndIt3a:    strstrl
  846.         db    "Hello There",0
  847.         jc    NotFnd3a
  848.         print
  849.         db    "Error, found a string which isn't present!",cr,lf,0
  850. ;
  851. NotFnd3a:
  852. ;     
  853. ;
  854. ;
  855. ;
  856.         putcr
  857.         putcr
  858. ;
  859. ;***************************************************************************
  860. ;
  861. ; Test IsAlNum, IsDigit, IsAlpha, IsLower, IsUpper, and IsxDigit here:
  862. ;
  863.         print
  864.         db    "Testing IsAlNum, IsDigit, IsAlpha, IsLower, "
  865.         db    "IsUpper, and IsXDigit",cr,lf,0
  866. ;
  867.         mov    cx, 26
  868.         mov    al, 'Z'
  869.         mov    ah, 'z'
  870. TstAlphaLp:    IsAlNum
  871.         jne    yALNumFail
  872.         IsAlpha
  873.         jne    ALFail
  874.         IsUpper
  875.         jne    UprFail
  876.         cmp    al, 'F'
  877.         ja    NotHex
  878.         IsXDigit
  879.         jne    XFail
  880. ;
  881. NotHex:        xchg    al, ah
  882.         IsAlNum
  883. yALNumFail:    jne    AlNumFail
  884.         IsAlpha
  885.         jne    ALFail
  886.         IsLower
  887.         jne    LwrFail
  888.         cmp    al, 'f'
  889.         ja    NotHex2
  890.         IsXDigit
  891.         jne    XFail
  892. ;
  893. NotHex2:    xchg    al, ah
  894.         dec    al
  895.         dec    ah
  896.         loop    TstAlphaLp
  897. ;
  898.         mov    cx, 10
  899.         mov    al, '9'
  900. TstDigLp:    IsDigit
  901.         jne    DigitFail
  902.         IsAlNum
  903.         jne    AlNumFail
  904.         IsXDigit
  905.         jne    XFail
  906.         dec    al
  907.         loop    TstDigLp
  908.         jmp    short TestBad
  909. ;
  910. ALNumFail:    jmp    short xALNumFail
  911. ALFail:        jmp    short xALFail
  912. UprFail:    jmp    xUprFail
  913. LwrFail:    jmp    xLwrFail
  914. XFail:        jmp    xXFail
  915. DigitFail:    jmp    xDigitFail
  916. ;
  917. TestBad:    mov    al, '1'
  918.         IsAlpha
  919.         je    ALFail
  920.         IsLower
  921.         je    LwrFail
  922.         IsUpper
  923.         je    UprFail
  924.         mov    al, '!'
  925.         IsDigit
  926.         je    DigitFail
  927.         IsAlNum
  928.         je    AlNumFail
  929.         IsXDigit
  930.         je    XFail
  931.         jmp    TestSPrintf
  932. ;
  933. xALNumFail:    print
  934.         db    "IsALNum has failed",cr,lf,0
  935.         jmp    TestSPrintf
  936. ;
  937. xALFail:    print
  938.         db    "IsAlpha has failed",cr,lf,0
  939.         jmp    short TestSPrintf
  940. ;
  941. xUprFail:    print
  942.         db    "IsUpper has failed",cr,lf,0
  943.         jmp    short TestSPrintf
  944. ;
  945. xLwrFail:    print
  946.         db    "IsLower has failed",cr,lf,0
  947.         jmp    short TestSPrintf
  948. ;
  949. xXFail:        print
  950.         db    "IsXDigit has failed",cr,lf,0
  951.         jmp    short TestSPrintf
  952. ;
  953. xDigitFail:    print
  954.         db    "IsDigit has failed",cr,lf,0
  955. ;
  956. ;***************************************************************************
  957. ;
  958. ; Testing sprintf and sbprintf here.
  959. ;
  960. TestSPrintf:    sprintf
  961.         db    "I= %i, I='%10i', I=%^i",cr,lf
  962.         db    "U= %u",cr,lf,0
  963.         dd    i,i,pi,u
  964.         puts
  965.         free
  966. ;
  967.         lesi    Buffer
  968.         sbprintf
  969.         db    "I= %i, I='%10i', I=%^i",cr,lf
  970.         db    "U= %u",cr,lf,0
  971.         dd    i,i,pi,u
  972.         puts
  973. ;
  974. ;***************************************************************************
  975. ;
  976. ; Testing various ITOxx routines here.
  977. ;
  978.         mov    ax, -1234
  979.         itoa
  980.         print
  981.         db    "ITOA: -1234 is ",0
  982.         puts
  983.         putcr
  984.         free            ;Free allocated storage.
  985. ;
  986. ;-----
  987. ;
  988.         mov    ax, 43210
  989.         utoa
  990.         print
  991.         db    "UTOA: 43210 is ",0
  992.         puts
  993.         putcr
  994.         free            ;Free allocated storage.
  995. ;
  996. ;-----
  997. ;
  998.         mov    ax, 0ABCDh
  999.         htoa
  1000.         print
  1001.         db    "HTOA: 0cdh is ",0
  1002.         puts
  1003.         putcr
  1004.         free            ;Free allocated storage.
  1005. ;
  1006. ;-----
  1007. ;
  1008.         mov    ax, 0ABCDh
  1009.         wtoa
  1010.         print
  1011.         db    "WTOA: 0abcdh is ",0
  1012.         puts
  1013.         putcr
  1014.         free            ;Free allocated storage.
  1015. ;
  1016. ;-----
  1017. ;
  1018.         mov    ax, -1234
  1019.         mov    dx, 0ffffh
  1020.         ltoa
  1021.         print
  1022.         db    "LTOA: -1234 is ",0
  1023.         puts
  1024.         putcr
  1025.         free
  1026. ;
  1027. ;-----
  1028. ;
  1029.         mov    ax, 1234
  1030.         mov    dx, 0
  1031.         ultoa
  1032.         print
  1033.         db    "ULTOA: 1234 is ",0
  1034.         puts
  1035.         putcr
  1036.         free
  1037. ;
  1038. ;
  1039. ;***************************************************************************
  1040. ;
  1041. ; Testing memory management routines here:
  1042. ;
  1043.         mov    cx, 256
  1044.         malloc
  1045.         IsPtr
  1046.         jnc    ValidPtr
  1047.         print
  1048.         db    "This is not a valid ptr (1)",cr,lf,0
  1049.         jmp    short x1
  1050. ;
  1051. ValidPtr:    print
  1052.         db    "Malloc returned a valid ptr",cr,lf,0
  1053. ;
  1054. x1:        inc    di
  1055.         IsPtr
  1056.         jc    InvalidPtr
  1057.         print
  1058.         db    "Incrementing a pointer didn't make it invalid",cr,lf,0
  1059.         jmp    short x2
  1060. ;
  1061. InvalidPtr:    print
  1062.         db    "Incrementing a pointer makes it invalid",cr,lf,0
  1063. ;
  1064. x2:        IsInHeap
  1065.         jc    BadIsIn
  1066.         print
  1067.         db    "Although incrementing it leaves it in the heap",cr,lf,0
  1068.         jmp    short x3
  1069. ;
  1070. BadIsIn:    print
  1071.         db    "Incrementing the pointer moved it out of the heap"
  1072.         db    cr,lf,0
  1073. ;
  1074. x3:        dec    di
  1075.         free
  1076.         jnc    GoodFree
  1077.         print
  1078.         db    "Free returned an error",cr,lf,0
  1079.         jmp    short x4
  1080. ;
  1081. GoodFree:    print
  1082.         db    "FREE did its job.",cr,lf,0
  1083. ;
  1084. x4:        mov    cx, 512
  1085.         malloc
  1086.         mov    cx, 256
  1087.         realloc
  1088.         jnc    GoodRealloc
  1089.         print
  1090.         db    "Realloc screwed up!",cr,lf,0
  1091.         jmp    x5
  1092. ;
  1093. GoodRealloc:    DupPtr
  1094.         free
  1095.         jnc    GF1
  1096.         print
  1097.         db    "Free choked after DupPtr",cr,lf,0
  1098.         jmp    short x5
  1099. ;
  1100. GF1:        free
  1101.         jnc    GF2
  1102.         print
  1103.         db    "Free choked after second call.",cr,lf,0
  1104.         jmp    short x5
  1105. ;
  1106. GF2:        free
  1107.         jc    x5
  1108.         print
  1109.         db    "Free DIDN'T return an error when it was "
  1110.         db    "supposed to.",cr,lf,0
  1111. ;
  1112. x5:
  1113. ;
  1114. ;
  1115. ;****************************************************************************
  1116. ;
  1117. ; Testing the ISIZE and LSIZE routines here:
  1118. ;
  1119.         mov    ax, -12345
  1120.         isize
  1121.         print
  1122.         db    "Size of -12345 (isize) is ",0
  1123.         puti
  1124.         mov    ax, 1234
  1125.         usize
  1126.         print
  1127.         db    cr,lf,"Size of 1234 (usize) is ",0
  1128.         puti
  1129. ;
  1130.         mov    dx, 0ffffh
  1131.         mov    ax, -12345
  1132.         lsize
  1133.         print
  1134.         db    cr,lf,"Size of -12345 (lsize) is ",0
  1135.         puti
  1136.         mov    ax, 1234
  1137.         xor    dx, dx
  1138.         ulsize
  1139.         print
  1140.         db    cr,lf,"Size of 1234 (ulsize) is ",0
  1141.         puti
  1142.         putcr
  1143. ;
  1144. ;****************************************************************************
  1145. ;
  1146. ; Test the "ATOxx" routines here.
  1147. ;
  1148.         print
  1149.         db    "Testing ATOH: ",0
  1150.         lesi    hex1
  1151.         atoh
  1152.         putw
  1153.         mov    al, ' '
  1154.         putc
  1155. ;
  1156.         atoh2
  1157.         putw
  1158.         putcr
  1159. ;
  1160.         print
  1161.         db    "Testing ATOI: ",0
  1162.         lesi    int1
  1163.         atoi
  1164.         puti
  1165.         mov    al, ' '
  1166.         putc
  1167.         atoi2
  1168.         puti
  1169.         putcr
  1170. ;
  1171.         print
  1172.         db    "Testing ATOU: ",0
  1173.         lesi    int2
  1174.         atou
  1175.         putu
  1176.         mov    al, ' '
  1177.         putc
  1178.         atou2
  1179.         putu
  1180.         putcr
  1181. ;
  1182.         print
  1183.         db    "Testing ATOL: ",0
  1184.         lesi    lint1
  1185.         atol
  1186.         putl
  1187.         mov    al, ' '
  1188.         putc
  1189.         atol2
  1190.         putl
  1191.         putcr
  1192. ;
  1193.         print
  1194.         db    "Testing ATOUL: ",0
  1195.         lesi    lint2
  1196.         atoul
  1197.         putul
  1198.         mov    al, ' '
  1199.         putc
  1200.         atoul2
  1201.         putul
  1202.         putcr
  1203. ;
  1204. ;
  1205. ;****************************************************************************
  1206. ;
  1207. ; Test SCANF here:
  1208. ;
  1209.         printf
  1210.         db    "Enter some text: ",0
  1211.         scanf
  1212.         db    "%s",0
  1213.         dd    buffer
  1214.         print
  1215.         db    "You entered: ",0
  1216.         lesi    buffer
  1217.         puts
  1218.         putcr
  1219. ;
  1220. ; Test SSCANF here:
  1221. ;
  1222.         printf
  1223.         db    "Before, c1=%c, c2=%c\n",0
  1224.         dd    c1,c2
  1225. ;
  1226.         lesi    sfstr1
  1227.         sscanf
  1228.         db    "%i %d %u %u %ld %li %lu %lu %x %c",0
  1229.         dd    i1,i2,u1,u2,l1,l2,ul1,ul2,h1,c1
  1230. ;
  1231.         printf
  1232.         db    "Values input by sscanf:\n"
  1233.         db    "i1=%d, i2=%d\n"
  1234.         db    "u1=%u, u2=%u\n"
  1235.         db    "l1=%ld, l2=%ld\n"
  1236.         db    "ul1=%lu, ul2=%lu\n"
  1237.         db    "h1=%x\n"
  1238.         db    "c1=%c,  c2=%c\n"
  1239.         db    0
  1240.         dd    i1,i2,u1,u2,l1,l2,ul1,ul2,h1,c1,c2
  1241. ;
  1242. ;
  1243.         print
  1244.         db    "Testing scanf character skipping:",cr,lf,0
  1245.         lesi    sfstr2
  1246.         sscanf
  1247.         db    "%i, %i",0
  1248.         dd    i1,i2
  1249.         printf
  1250.         db    "i1=%i, i2=%i\n",0
  1251.         dd    i1, i2
  1252. ;
  1253. ;
  1254. ;****************************************************************************
  1255. ;
  1256. ;
  1257. ;
  1258. ; Testing the PUTC routines here.
  1259. ;
  1260. ; The following code should print:
  1261. ;
  1262. ; aaa
  1263. ; aaa
  1264. ; aaa
  1265. ; aaaaaaaa
  1266. ;
  1267. ; aaaa
  1268. ; aaaaaaaa
  1269. ; aaaa
  1270. ;
  1271. ;
  1272.         mov    al, 'a'
  1273.         putc
  1274.         putc
  1275.         putc
  1276. ;
  1277.         putcr
  1278. ;
  1279.         putcstdout
  1280.         putcstdout
  1281.         putcstdout
  1282.         putcr
  1283. ;
  1284.         putcbios
  1285.         putcbios
  1286.         putcbios
  1287.         putcr
  1288. ;
  1289.         mov    di, cs
  1290.         mov    es, di
  1291.         lea    di, dblchars
  1292.         setoutadrs
  1293. ;
  1294.         putc
  1295.         putc
  1296.         putc
  1297.         putc
  1298.         putcr
  1299. ;
  1300.         getoutadrs
  1301.         cmp    di, offset dblchars
  1302.         jne    badtest
  1303.         mov    di, es
  1304.         cmp    di, seg dblchars
  1305.         jne    badtest
  1306. ;
  1307.         mov    di, seg sl_putcstdout
  1308.         mov    es, di
  1309.         lea    di, sl_putcstdout
  1310.         pushoutadrs
  1311.         putc
  1312.         putc
  1313.         putc
  1314.         putc
  1315.         putcr
  1316. ;
  1317.         popoutadrs
  1318.         putc
  1319.         putc
  1320.         putc
  1321.         putc
  1322.         putcr
  1323.         popoutadrs
  1324.         cmp    di, offset dblchars
  1325.         jne    badtest
  1326.         mov    di, es
  1327.         cmp    di, seg dblchars
  1328.         jne    badtest
  1329. ;
  1330.         putc
  1331.         putc
  1332.         putc
  1333.         putc
  1334.         putcr
  1335.         jmp    short goodtest
  1336. ;
  1337. badtest:    print
  1338.         db    "GetOutAdrs or PopOutAdrs did not return "
  1339.         db    "the proper address",cr,lf,0
  1340. ;
  1341. GoodTest:
  1342. ;
  1343. ;
  1344. ;****************************************************************************
  1345. ;
  1346. ; Test the remaining print routines here
  1347. ;
  1348.         print
  1349.         db    "This is a test of the print routine",cr,lf,0
  1350. ;
  1351.         print
  1352.         db    0
  1353. ;
  1354.         print
  1355.         db    "So is this!",cr,lf,0
  1356. ;
  1357.         lesi    TestString0
  1358.         puts
  1359. ;
  1360.         print
  1361.         db    "Hex value 0xfa output by PutH: ",0
  1362.         mov    al, 0fah
  1363.         puth
  1364. ;
  1365.         print
  1366.         db    cr,lf,"Hex value 0xfa12 output by PutW: ",0
  1367.         mov    ax, 0fa12h
  1368.         putw
  1369. ;
  1370.         print
  1371.         db    cr,lf,"Decimal value 0xffff output by puti: ",0
  1372.         mov    ax, 0ffffh
  1373.         puti
  1374.         print    
  1375.         db    cr,lf,"Decimal value 1 output by puti: ",0
  1376.         mov    ax, 1
  1377.         puti
  1378. ;
  1379.         print
  1380.         db    cr,lf,"Unsigned value 0ffffh output by putu: ",0
  1381.         mov    ax, 0ffffh
  1382.         putu
  1383.         print
  1384.         db    cr,lf,"Unsigned value 1 output by putu: ",0
  1385.         mov    ax, 1
  1386.         putu
  1387. ;
  1388.         print
  1389.         db    cr,lf,"Long value 0ffff1234 output by putL: ",0
  1390.         mov    ax, 1234h
  1391.         mov    dx, 0ffffh
  1392.         putl
  1393.         print    
  1394.         db    cr,lf,"Long value 01234ffff output by putL: ",0
  1395.         mov    dx, 1234h
  1396.         mov    ax, 0ffffh
  1397.         putl
  1398. ;
  1399.         print
  1400.         db    cr,lf,"Unsigned long value 1234ffff output by "
  1401.         db    "putUL: ",0
  1402.         putul
  1403.         print
  1404.         db    cr,lf,"Unsigned long value 0ffff1234 output by "
  1405.         db    "putUL: ",0
  1406.         mov    dx, 0ffffh
  1407.         mov    ax, 1234h
  1408.         putUL
  1409.         putcr
  1410. ;
  1411.         mov    cx, 10
  1412. islp1:        print
  1413.         db    "Outputting -2567 using a field width of ",0
  1414.         mov    ax, cx
  1415.         puti
  1416.         print
  1417.         db    " **",0
  1418.         mov    ax, -2567
  1419.         putisize
  1420.         print
  1421.         db    "** w/PutISize",cr,lf,0
  1422.         loop    islp1
  1423. ;
  1424.         mov    cx, 10
  1425. islp2:        print
  1426.         db    "Outputting -2567 using a field width of ",0
  1427.         mov    ax, cx
  1428.         puti
  1429.         print
  1430.         db    " **",0
  1431.         mov    ax, -2567
  1432.         putusize
  1433.         print
  1434.         db    "** w/PutUSize",cr,lf,0
  1435.         loop    islp2
  1436. ;
  1437.         mov    cx, 10
  1438. islp3:        print
  1439.         db    "Outputting -2567 using a field width of ",0
  1440.         mov    ax, cx
  1441.         puti
  1442.         print
  1443.         db    " **",0
  1444.         mov    ax, -2567
  1445.         mov    dx, 0ffffh
  1446.         putlsize
  1447.         print
  1448.         db    "** w/PutLSize",cr,lf,0
  1449.         loop    islp3
  1450.         print
  1451.         db    "Outputting 0ff001234h using PutLSize: ",0
  1452.         mov    dx, 0ff00h
  1453.         mov    ax, 1234h
  1454.         mov    cx, 10
  1455.         PutLSize
  1456.         putcr
  1457. ;
  1458.         mov    cx, 10
  1459. islp4:        print
  1460.         db    "Outputting -2567 using a field width of ",0
  1461.         mov    ax, cx
  1462.         puti
  1463.         print
  1464.         db    " **",0
  1465.         mov    ax, -2567
  1466.         mov    dx, 0ffffh
  1467.         putulsize
  1468.         print
  1469.         db    "** w/PutULSize",cr,lf,0
  1470.         loop    islp4
  1471.         print
  1472.         db    "Outputting 0ff001234h using PutULSize: ",0
  1473.         mov    dx, 0ff00h
  1474.         mov    ax, 1234h
  1475.         mov    cx, 10
  1476.         PutULSize
  1477.         putcr
  1478. ;
  1479. ;****************************************************************************
  1480. ;
  1481. ; Testing the PRINTF routine:
  1482. ;
  1483.         printf
  1484.         db    "This is a test of the printf routine w/o any "
  1485.         db    "operands.\n"
  1486.         db    "It tests the esc characters \\n, \\r, \\b, \\t, "
  1487.         db    "\0x0d, and \\\\.\n"
  1488.         db    "Test of \\r:\n"
  1489.         db    "Old line.\rNew line.\n"
  1490.         db    "Test of \t\ttab.\n"
  1491.         db    "Test of backspace\b\b\b\b\bs p a c e\n"
  1492.         db    "Test of return using \\0x0d:\n"
  1493.         db    "Old line.\0x0dNew line.\n\n",0
  1494. ;
  1495.         printf
  1496.         db    cr,lf
  1497.         db    "Test of integer output formats (using I):\n"
  1498.         db    "\%d\t\t-\t*%d*\n"
  1499.         db    "\%10d\t\t-\t*%10d*\n"
  1500.         db    "\%-10d\t\t-\t*%-10d*\n"
  1501.         db    "\%\\*10d\t\t-\t*%\*10d*\n"
  1502.         db    "\%\-\\*10d\t\t-\t*%-\*10d*\n"
  1503.         db    "\%^d\t\t-\t*%^d*\n"
  1504.         db    "\%10^d\t\t-\t*%10^d*\n"
  1505.         db    "\%-10^d\t\t-\t*%-10^d*\n"
  1506.         db    "\%\\*10^d\t\t-\t*%\*10^d*\n"
  1507.         db    "\%\-\\*10^d\t-\t*%-\*10^d*\n"
  1508.         db    0
  1509.         dd    i,i,i,i,i,pi,pi,pi,pi,pi
  1510. ;
  1511.         printf
  1512.         db    cr,lf
  1513.         db    "Test of unsigned integer output formats (using U):\n"
  1514.         db    "\%u\t\t-\t*%u*\n"
  1515.         db    "\%10u\t\t-\t*%10u*\n"
  1516.         db    "\%-10u\t\t-\t*%-10u*\n"
  1517.         db    "\%\\*10u\t\t-\t*%\*10u*\n"
  1518.         db    "\%\-\\*10u\t\t-\t*%-\*10u*\n"
  1519.         db    "\%^u\t\t-\t*%^u*\n"
  1520.         db    "\%10^u\t\t-\t*%10^u*\n"
  1521.         db    "\%-10^u\t\t-\t*%-10^u*\n"
  1522.         db    "\%\\*10^u\t\t-\t*%\*10^u*\n"
  1523.         db    "\%\-\\*10^u\t-\t*%-\*10^u*\n"
  1524.         db    0
  1525.         dd    u,u,u,u,u,pu,pu,pu,pu,pu
  1526. ;
  1527.         printf
  1528.         db    cr,lf
  1529.         db    "Test of unsigned long output formats (using UL):\n"
  1530.         db    "\%ul\t\t-\t*%lu*\n"
  1531.         db    "\%15lu\t\t-\t*%15lu*\n"
  1532.         db    "\%-15lu\t\t-\t*%-15lu*\n"
  1533.         db    "\%\\*15lu\t\t-\t*%\*15lu*\n"
  1534.         db    "\%\-\\*15lu\t-\t*%-\*15lu*\n"
  1535.         db    "\%^lu\t\t-\t*%^lu*\n"
  1536.         db    "\%15^lu\t\t-\t*%15^lu*\n"
  1537.         db    "\%-15^lu\t\t-\t*%-15^lu*\n"
  1538.         db    "\%\\*15^lu\t-\t*%\*15^lu*\n"
  1539.         db    "\%\-\\*15^lu\t-\t*%-\*15^lu*\n"
  1540.         db    0
  1541.         dd    ul,ul,ul,ul,ul,pul,pul,pul,pul,pul
  1542. ;
  1543.         printf
  1544.         db    cr,lf
  1545.         db    "Test of long output formats (using L):\n"
  1546.         db    "\%ld\t\t-\t*%ld*\n"
  1547.         db    "\%15ld\t\t-\t*%15ld*\n"
  1548.         db    "\%-15ld\t\t-\t*%-15ld*\n"
  1549.         db    "\%\\*15ld\t\t-\t*%\*15ld*\n"
  1550.         db    "\%\-\\*15ld\t-\t*%-\*1ld*\n"
  1551.         db    "\%^ld\t\t-\t*%^ld*\n"
  1552.         db    "\%15^ld\t\t-\t*%15^ld*\n"
  1553.         db    "\%-15^ld\t\t-\t*%-15^ld*\n"
  1554.         db    "\%\\*15^ld\t-\t*%\*15^ld*\n"
  1555.         db    "\%\-\\*15^ld\t-\t*%-\*15^ld*\n"
  1556.         db    0
  1557.         dd    l,l,l,l,l,pl,pl,pl,pl,pl
  1558. ;
  1559.         printf
  1560.         db    cr,lf
  1561.         db    "Test of hexadecimal output (byte) using I:\n"
  1562.         db    "\%h\t\t-\t*%h*\n"
  1563.         db    "\%5h\t\t-\t*%5h*\n"
  1564.         db    "\%-5h\t\t-\t*%-5h*\n"
  1565.         db    "\%\\*5h\t\t-\t*%\*5h*\n"
  1566.         db    "\%\-\\*5h\t\t-\t*%-\*5h*\n"
  1567.         db    "\%^h\t\t-\t*%^h*\n"
  1568.         db    "\%5^h\t\t-\t*%5^h*\n"
  1569.         db    "\%-5^h\t\t-\t*%-5^h*\n"
  1570.         db    "\%\\*5^h\t\t-\t*%\*5^h*\n"
  1571.         db    "\%\-\\*5^h\t\t-\t*%-\*5^h*\n"
  1572.         db    0
  1573.         dd    i,i,i,i,i,pi,pi,pi,pi,pi
  1574. ;
  1575.         printf
  1576.         db    cr,lf
  1577.         db    "Test of hexadecimal output (word) using I:\n"
  1578.         db    "\%x\t\t-\t*%x*\n"
  1579.         db    "\%5x\t\t-\t*%5x*\n"
  1580.         db    "\%-5x\t\t-\t*%-5x*\n"
  1581.         db    "\%\\*5x\t\t-\t*%\*5x*\n"
  1582.         db    "\%\-\\*5x\t\t-\t*%-\*5x*\n"
  1583.         db    "\%^x\t\t-\t*%^x*\n"
  1584.         db    "\%5^x\t\t-\t*%5^x*\n"
  1585.         db    "\%-5^x\t\t-\t*%-5^x*\n"
  1586.         db    "\%\\*5^x\t\t-\t*%\*5^x*\n"
  1587.         db    "\%\-\\*5^x\t\t-\t*%-\*5^x*\n"
  1588.         db    0
  1589.         dd    i,i,i,i,i,pi,pi,pi,pi,pi
  1590. ;
  1591.         printf
  1592.         db    cr,lf
  1593.         db    "Test of hexadecimal output (long) using UL:\n"
  1594.         db    "\%lx\t\t-\t*%lx*\n"
  1595.         db    "\%15lx\t\t-\t*%15lx*\n"
  1596.         db    "\%-15lx\t\t-\t*%-15lx*\n"
  1597.         db    "\%\\*15lx\t\t-\t*%\*15lx*\n"
  1598.         db    "\%\-\\*15lx\t-\t*%-\*15lx*\n"
  1599.         db    "\%^lx\t\t-\t*%^lx*\n"
  1600.         db    "\%15^lx\t\t-\t*%15^lx*\n"
  1601.         db    "\%-15^lx\t\t-\t*%-15^lx*\n"
  1602.         db    "\%\\*15^lx\t-\t*%\*15^lx*\n"
  1603.         db    "\%\-\\*15^lx\t-\t*%-\*15^lx*\n"
  1604.         db    0
  1605.         dd    ul,ul,ul,ul,ul,pul,pul,pul,pul,pul
  1606. ;
  1607.         printf
  1608.         db    cr,lf
  1609.         db    "Test of character output using S:\n"
  1610.         db    "\%c\t\t-\t*%c*\n"
  1611.         db    "\%5c\t\t-\t*%5c*\n"
  1612.         db    "\%-5c\t\t-\t*%-5c*\n"
  1613.         db    "\%\\*5c\t\t-\t*%\*5c*\n"
  1614.         db    "\%\-\\*5c\t\t-\t*%-\*5c*\n"
  1615.         db    "\%^c\t\t-\t*%^c*\n"
  1616.         db    "\%5^c\t\t-\t*%5^c*\n"
  1617.         db    "\%-5^c\t\t-\t*%-5^c*\n"
  1618.         db    "\%\\*5^c\t\t-\t*%\*5^c*\n"
  1619.         db    "\%\-\\*5^c\t\t-\t*%-\*5^c*\n"
  1620.         db    0
  1621.         dd    s,s,s,s,s,ps,ps,ps,ps,ps
  1622. ;
  1623.         printf
  1624.         db    cr,lf
  1625.         db    "Test of string output using s:\n"
  1626.         db    "\%s\t\t-\t*%s*\n"
  1627.         db    "\%15s\t\t-\t*%15s*\n"
  1628.         db    "\%-15s\t\t-\t*%-15s*\n"
  1629.         db    "\%\\*15s\t\t-\t*%\*15s*\n"
  1630.         db    "\%\-\\*15s\t\t-\t*%-\*15s*\n"
  1631.         db    "\%^s\t\t-\t*%^s*\n"
  1632.         db    "\%15^s\t\t-\t*%15^s*\n"
  1633.         db    "\%-15^s\t\t-\t*%-15^s*\n"
  1634.         db    "\%\\*15^s\t\t-\t*%\*15^s*\n"
  1635.         db    "\%\-\\*15^s\t-\t*%-\*15^s*\n"
  1636.         db    0
  1637.         dd    s,s,s,s,s,ps,ps,ps,ps,ps
  1638. ;
  1639. ;****************************************************************************
  1640. ;
  1641. ; Test the input routines here.
  1642. ;
  1643.         print
  1644.         db    "Testing GETC- Press any key: ",0
  1645.         getc
  1646.         print
  1647.         db    cr,lf,"You pressed: '",0
  1648.         putc
  1649.         print
  1650.         db    "' : ",0
  1651.         putw
  1652.         print
  1653.         db    cr,lf,"Testing GetcStdIn- Press any key:",0
  1654.         GetcStdIn
  1655.         print
  1656.         db    cr,lf,"You pressed: '",0
  1657.         putc
  1658.         print
  1659.         db    "' : ",0
  1660.         putw
  1661.         print
  1662.         db    cr,lf,"Testing GetcBIOS- Press any key:",0
  1663.         getcBIOS
  1664.         print
  1665.         db    cr,lf,"You pressed: '",0
  1666.         putc
  1667.         print
  1668.         db    "' : ",0
  1669.         putw
  1670. ;
  1671.         print
  1672.         db    cr,lf,"Redirecting input, reading: ",0
  1673.         lesi    ReturnA
  1674.         SetInAdrs
  1675.         getc
  1676.         print
  1677.         db    cr,lf,"Getc returned: '",0
  1678.         putc
  1679.         print
  1680.         db    "' : ",0
  1681.         putw
  1682.         print
  1683.         db    cr,lf,"Pushing address, changing to 'B': ",0
  1684.         lesi    ReturnB
  1685.         PushInAdrs
  1686.         getc
  1687.         print
  1688.         db    cr,lf,"Getc returned: '",0
  1689.         putc
  1690.         print
  1691.         db    "' : ",0
  1692.         putw
  1693.         print
  1694.         db    cr,lf,"Popping address: ",0
  1695.         PopInAdrs
  1696.         cmp    di, offset ReturnB
  1697.         jne    BadPopIn
  1698.         mov    di, es
  1699.         cmp    di, seg ReturnB
  1700.         je    GoodPopIn
  1701. BadPopIn:    print
  1702.         db    cr,lf,"Did not return the proper address",cr,lf,0
  1703. GoodPopIn:    print
  1704.         db    cr,lf,"Popping address again, should read from kbd: "
  1705.         db    0
  1706.         PopInAdrs
  1707.         getc
  1708.         print
  1709.         db    cr,lf,"Getc returned: '",0
  1710.         putc
  1711.         print
  1712.         db    "' : ",0
  1713.         putw
  1714.         putcr
  1715. ;
  1716. ;****************************************************************************
  1717. ;
  1718. ; Test GETS here:
  1719. ;
  1720.         print
  1721.         db    "Testing GETS, enter a line of text: ",0
  1722.         gets
  1723.         jnc    goodgets
  1724.         print
  1725.         db    "Bad gets call",cr,lf,0
  1726. ;
  1727. goodgets:    print
  1728.         db    "You entered: ",0
  1729.         puts
  1730.         putcr
  1731. ;
  1732. ;
  1733. ;***************************************************************************
  1734. ;
  1735. ;
  1736. ;
  1737. Quit:        mov     ah, 4ch
  1738.         int     21h
  1739. ;
  1740. ;
  1741. Main        endp
  1742. ;
  1743. ;
  1744. dblchars    proc    far
  1745.         putcstdout
  1746.         putcstdout
  1747.         ret
  1748. dblchars    endp
  1749. ;
  1750. ;
  1751. ReturnA        proc    far
  1752.         mov    ax, "A"
  1753.         ret
  1754. ReturnA        endp
  1755. ;
  1756. ReturnB        proc    far
  1757.         mov    ax, "B"
  1758.         ret
  1759. ReturnB        endp
  1760. ;
  1761. ;
  1762. ; Printset- Prints the characters in the set passed in es:di
  1763. ;
  1764. PrintSet    proc
  1765.         push    es
  1766.         push    ds
  1767.         push    di
  1768.         push    si
  1769.         push    dx
  1770.         push    ax
  1771. ;
  1772.         mov    dx, es        ;dx:si := es:di
  1773.         mov    si, di
  1774. ;
  1775.         createsets
  1776.         copyset
  1777. PrLoop:        rmvitem
  1778.         cmp    al, 0
  1779.         jz    PrDone
  1780.         putc
  1781.         jmp    PrLoop
  1782. ;
  1783. PrDone:        free
  1784.         pop    ax
  1785.         pop    dx
  1786.         pop    si
  1787.         pop    di
  1788.         pop    ds
  1789.         pop    es
  1790.         ret
  1791. PrintSet    endp
  1792. ;
  1793. ;
  1794. cseg            ends
  1795. ;
  1796. ;
  1797. ; Allocate a reasonable amount of space for the stack (2k).
  1798. ;
  1799. sseg        segment    para stack 'stack'
  1800. stk        db    256 dup ("stack   ")
  1801. sseg        ends
  1802. ;
  1803. ;
  1804. ;
  1805. ; zzzzzzseg must be the last segment that gets loaded into memory!
  1806. ;
  1807. zzzzzzseg    segment    para public 'zzzzzz'
  1808. LastBytes    db    16 dup (?)
  1809. heap        db    1024 dup (?)
  1810. zzzzzzseg    ends
  1811.         end    Main
  1812.