home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / asm / ucrstdlb / test.asm < prev    next >
Assembly Source File  |  1991-10-11  |  31KB  |  1,865 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.         strrevm
  167.         puts
  168.         putcr
  169.         free
  170. ;
  171.         lesi    RevStr2
  172.         strrevm
  173.         puts
  174.         putcr
  175.         free
  176. ;
  177.         lesi    RevStr3
  178.         strrevm
  179.         puts
  180.         putcr
  181.         free
  182. ;
  183.         lesi    RevStr4
  184.         strrevm
  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.         strdelm
  221.         puts
  222.         putcr
  223.         free
  224. ;
  225.         lesi    InsStrDest
  226.         mov    ax, 20
  227.         mov    cx, 2
  228.         strdelm
  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.         strinsml
  250.         db    "Ho ho ho!",0
  251.         puts
  252.         putcr
  253.         free
  254. ;
  255.         lesi    InsStrDest
  256.         mov    cx, 100
  257.         strinsml
  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.         strinsm
  269.         jnc    GoodStrins2
  270.         print
  271.         db    "Could not allocate memory for StrInsm",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.         strinsm
  282.         jnc    GoodSI2
  283.         print
  284.         db    "Strinsm: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 StrSetm:",cr,lf,0
  494.         mov    cx, 32
  495.         mov    al, '#'
  496.         strsetm
  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 strcatm:",cr,lf,0
  750. ;
  751.         lesi    TestString1
  752.         ldxi    TestString0
  753.         strcatm
  754.         puts
  755.         free
  756. ;
  757.         print
  758.         db    "Testing strcatml:",cr,lf,0
  759. ;
  760.         lesi    TestString1
  761.         strcatml
  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 sprintfm here.
  959. ;
  960. TestSPrintf:    sprintfm
  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.         sprintf
  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.         itoam
  980.         print
  981.         db    "ITOAM: -1234 is ",0
  982.         puts
  983.         putcr
  984.         free            ;Free allocated storage.
  985. ;
  986. ;-----
  987. ;
  988.         lesi    buffer
  989.         itoa
  990.         print
  991.         db    "ITOA: -1234 is ",0
  992.         puts
  993.         putcr
  994. ;
  995. ;-----
  996. ;
  997.         lesi    buffer
  998.         itoa2
  999.         itoa2
  1000.         lesi    buffer
  1001.         printf
  1002.         db    "ITOA2: -1234-1234 is %s\n",0
  1003.         dd    buffer
  1004. ;
  1005. ;-----
  1006. ;
  1007.         mov    ax, 43210
  1008.         utoam
  1009.         print
  1010.         db    "UTOAM: 43210 is ",0
  1011.         puts
  1012.         putcr
  1013.         free            ;Free allocated storage.
  1014. ;
  1015. ;-----
  1016. ;
  1017.         lesi    buffer
  1018.         mov    ax, 43210
  1019.         utoa
  1020.         print
  1021.         db    "UTOA: 43210 is ",0
  1022.         puts
  1023.         putcr
  1024. ;
  1025. ;-----
  1026. ;
  1027.         lesi    buffer
  1028.         utoa2
  1029.         utoa2
  1030.         printf
  1031.         db    "UTOA2: 4321043210 is %s\n",0
  1032.         dd    buffer
  1033. ;
  1034. ;-----
  1035. ;
  1036.         lesi    buffer
  1037.         mov    ax, 0ABCDh
  1038.         htoa
  1039.         print
  1040.         db    "HTOA: 0cdh is ",0
  1041.         puts
  1042.         putcr
  1043.         mov    ax, 0ABCDh
  1044.         htoam
  1045.         print
  1046.         db    "HTOAM: 0cdh is ",0
  1047.         puts
  1048.         putcr
  1049.         free            ;Free allocated storage.
  1050. ;
  1051. ;-----
  1052. ;
  1053.         lesi    buffer
  1054.         mov    ax, 0ABCDh
  1055.         wtoa
  1056.         print
  1057.         db    "WTOA: 0abcdh is ",0
  1058.         puts
  1059.         putcr
  1060.         mov    ax, 0ABCDh
  1061.         wtoam
  1062.         print
  1063.         db    "WTOAM: 0abcdh is ",0
  1064.         puts
  1065.         putcr
  1066.         free            ;Free allocated storage.
  1067. ;
  1068. ;-----
  1069. ;
  1070.         mov    ax, -1234
  1071.         mov    dx, 0ffffh
  1072.         ltoam
  1073.         print
  1074.         db    "LTOAM: -1234 is ",0
  1075.         puts
  1076.         putcr
  1077.         free
  1078. ;
  1079. ;-----
  1080. ;
  1081.         mov    ax, 1234
  1082.         mov    dx, 0
  1083.         ultoam
  1084.         print
  1085.         db    "ULTOAM: 1234 is ",0
  1086.         puts
  1087.         putcr
  1088.         free
  1089. ;
  1090. ;
  1091. ;***************************************************************************
  1092. ;
  1093. ; Testing memory management routines here:
  1094. ;
  1095.         mov    cx, 256
  1096.         malloc
  1097.         IsPtr
  1098.         jnc    ValidPtr
  1099.         print
  1100.         db    "This is not a valid ptr (1)",cr,lf,0
  1101.         jmp    short x1
  1102. ;
  1103. ValidPtr:    print
  1104.         db    "Malloc returned a valid ptr",cr,lf,0
  1105. ;
  1106. x1:        inc    di
  1107.         IsPtr
  1108.         jc    InvalidPtr
  1109.         print
  1110.         db    "Incrementing a pointer didn't make it invalid",cr,lf,0
  1111.         jmp    short x2
  1112. ;
  1113. InvalidPtr:    print
  1114.         db    "Incrementing a pointer makes it invalid",cr,lf,0
  1115. ;
  1116. x2:        IsInHeap
  1117.         jc    BadIsIn
  1118.         print
  1119.         db    "Although incrementing it leaves it in the heap",cr,lf,0
  1120.         jmp    short x3
  1121. ;
  1122. BadIsIn:    print
  1123.         db    "Incrementing the pointer moved it out of the heap"
  1124.         db    cr,lf,0
  1125. ;
  1126. x3:        dec    di
  1127.         free
  1128.         jnc    GoodFree
  1129.         print
  1130.         db    "Free returned an error",cr,lf,0
  1131.         jmp    short x4
  1132. ;
  1133. GoodFree:    print
  1134.         db    "FREE did its job.",cr,lf,0
  1135. ;
  1136. x4:        mov    cx, 512
  1137.         malloc
  1138.         mov    cx, 256
  1139.         realloc
  1140.         jnc    GoodRealloc
  1141.         print
  1142.         db    "Realloc screwed up!",cr,lf,0
  1143.         jmp    x5
  1144. ;
  1145. GoodRealloc:    DupPtr
  1146.         free
  1147.         jnc    GF1
  1148.         print
  1149.         db    "Free choked after DupPtr",cr,lf,0
  1150.         jmp    short x5
  1151. ;
  1152. GF1:        free
  1153.         jnc    GF2
  1154.         print
  1155.         db    "Free choked after second call.",cr,lf,0
  1156.         jmp    short x5
  1157. ;
  1158. GF2:        free
  1159.         jc    x5
  1160.         print
  1161.         db    "Free DIDN'T return an error when it was "
  1162.         db    "supposed to.",cr,lf,0
  1163. ;
  1164. x5:
  1165. ;
  1166. ;
  1167. ;****************************************************************************
  1168. ;
  1169. ; Testing the ISIZE and LSIZE routines here:
  1170. ;
  1171.         mov    ax, -12345
  1172.         isize
  1173.         print
  1174.         db    "Size of -12345 (isize) is ",0
  1175.         puti
  1176.         mov    ax, 1234
  1177.         usize
  1178.         print
  1179.         db    cr,lf,"Size of 1234 (usize) is ",0
  1180.         puti
  1181. ;
  1182.         mov    dx, 0ffffh
  1183.         mov    ax, -12345
  1184.         lsize
  1185.         print
  1186.         db    cr,lf,"Size of -12345 (lsize) is ",0
  1187.         puti
  1188.         mov    ax, 1234
  1189.         xor    dx, dx
  1190.         ulsize
  1191.         print
  1192.         db    cr,lf,"Size of 1234 (ulsize) is ",0
  1193.         puti
  1194.         putcr
  1195. ;
  1196. ;****************************************************************************
  1197. ;
  1198. ; Test the "ATOxx" routines here.
  1199. ;
  1200.         print
  1201.         db    "Testing ATOH: ",0
  1202.         lesi    hex1
  1203.         atoh
  1204.         putw
  1205.         mov    al, ' '
  1206.         putc
  1207. ;
  1208.         atoh2
  1209.         putw
  1210.         putcr
  1211. ;
  1212.         print
  1213.         db    "Testing ATOI: ",0
  1214.         lesi    int1
  1215.         atoi
  1216.         puti
  1217.         mov    al, ' '
  1218.         putc
  1219.         atoi2
  1220.         puti
  1221.         putcr
  1222. ;
  1223.         print
  1224.         db    "Testing ATOU: ",0
  1225.         lesi    int2
  1226.         atou
  1227.         putu
  1228.         mov    al, ' '
  1229.         putc
  1230.         atou2
  1231.         putu
  1232.         putcr
  1233. ;
  1234.         print
  1235.         db    "Testing ATOL: ",0
  1236.         lesi    lint1
  1237.         atol
  1238.         putl
  1239.         mov    al, ' '
  1240.         putc
  1241.         atol2
  1242.         putl
  1243.         putcr
  1244. ;
  1245.         print
  1246.         db    "Testing ATOUL: ",0
  1247.         lesi    lint2
  1248.         atoul
  1249.         putul
  1250.         mov    al, ' '
  1251.         putc
  1252.         atoul2
  1253.         putul
  1254.         putcr
  1255. ;
  1256. ;
  1257. ;****************************************************************************
  1258. ;
  1259. ; Test SCANF here:
  1260. ;
  1261.         printf
  1262.         db    "Enter some text: ",0
  1263.         scanf
  1264.         db    "%s",0
  1265.         dd    buffer
  1266.         print
  1267.         db    "You entered: ",0
  1268.         lesi    buffer
  1269.         puts
  1270.         putcr
  1271. ;
  1272. ; Test SSCANF here:
  1273. ;
  1274.         printf
  1275.         db    "Before, c1=%c, c2=%c\n",0
  1276.         dd    c1,c2
  1277. ;
  1278.         lesi    sfstr1
  1279.         sscanf
  1280.         db    "%i %d %u %u %ld %li %lu %lu %x %c",0
  1281.         dd    i1,i2,u1,u2,l1,l2,ul1,ul2,h1,c1
  1282. ;
  1283.         printf
  1284.         db    "Values input by sscanf:\n"
  1285.         db    "i1=%d, i2=%d\n"
  1286.         db    "u1=%u, u2=%u\n"
  1287.         db    "l1=%ld, l2=%ld\n"
  1288.         db    "ul1=%lu, ul2=%lu\n"
  1289.         db    "h1=%x\n"
  1290.         db    "c1=%c,  c2=%c\n"
  1291.         db    0
  1292.         dd    i1,i2,u1,u2,l1,l2,ul1,ul2,h1,c1,c2
  1293. ;
  1294. ;
  1295.         print
  1296.         db    "Testing scanf character skipping:",cr,lf,0
  1297.         lesi    sfstr2
  1298.         sscanf
  1299.         db    "%i, %i",0
  1300.         dd    i1,i2
  1301.         printf
  1302.         db    "i1=%i, i2=%i\n",0
  1303.         dd    i1, i2
  1304. ;
  1305. ;
  1306. ;****************************************************************************
  1307. ;
  1308. ;
  1309. ;
  1310. ; Testing the PUTC routines here.
  1311. ;
  1312. ; The following code should print:
  1313. ;
  1314. ; aaa
  1315. ; aaa
  1316. ; aaa
  1317. ; aaaaaaaa
  1318. ;
  1319. ; aaaa
  1320. ; aaaaaaaa
  1321. ; aaaa
  1322. ;
  1323. ;
  1324.         mov    al, 'a'
  1325.         putc
  1326.         putc
  1327.         putc
  1328. ;
  1329.         putcr
  1330. ;
  1331.         putcstdout
  1332.         putcstdout
  1333.         putcstdout
  1334.         putcr
  1335. ;
  1336.         putcbios
  1337.         putcbios
  1338.         putcbios
  1339.         putcr
  1340. ;
  1341.         mov    di, cs
  1342.         mov    es, di
  1343.         lea    di, dblchars
  1344.         setoutadrs
  1345. ;
  1346.         putc
  1347.         putc
  1348.         putc
  1349.         putc
  1350.         putcr
  1351. ;
  1352.         getoutadrs
  1353.         cmp    di, offset dblchars
  1354.         jne    badtest
  1355.         mov    di, es
  1356.         cmp    di, seg dblchars
  1357.         jne    badtest
  1358. ;
  1359.         mov    di, seg sl_putcstdout
  1360.         mov    es, di
  1361.         lea    di, sl_putcstdout
  1362.         pushoutadrs
  1363.         putc
  1364.         putc
  1365.         putc
  1366.         putc
  1367.         putcr
  1368. ;
  1369.         popoutadrs
  1370.         putc
  1371.         putc
  1372.         putc
  1373.         putc
  1374.         putcr
  1375.         popoutadrs
  1376.         cmp    di, offset dblchars
  1377.         jne    badtest
  1378.         mov    di, es
  1379.         cmp    di, seg dblchars
  1380.         jne    badtest
  1381. ;
  1382.         putc
  1383.         putc
  1384.         putc
  1385.         putc
  1386.         putcr
  1387.         jmp    short goodtest
  1388. ;
  1389. badtest:    print
  1390.         db    "GetOutAdrs or PopOutAdrs did not return "
  1391.         db    "the proper address",cr,lf,0
  1392. ;
  1393. GoodTest:
  1394. ;
  1395. ;
  1396. ;****************************************************************************
  1397. ;
  1398. ; Test the remaining print routines here
  1399. ;
  1400.         print
  1401.         db    "This is a test of the print routine",cr,lf,0
  1402. ;
  1403.         print
  1404.         db    0
  1405. ;
  1406.         print
  1407.         db    "So is this!",cr,lf,0
  1408. ;
  1409.         lesi    TestString0
  1410.         puts
  1411. ;
  1412.         print
  1413.         db    "Hex value 0xfa output by PutH: ",0
  1414.         mov    al, 0fah
  1415.         puth
  1416. ;
  1417.         print
  1418.         db    cr,lf,"Hex value 0xfa12 output by PutW: ",0
  1419.         mov    ax, 0fa12h
  1420.         putw
  1421. ;
  1422.         print
  1423.         db    cr,lf,"Decimal value 0xffff output by puti: ",0
  1424.         mov    ax, 0ffffh
  1425.         puti
  1426.         print    
  1427.         db    cr,lf,"Decimal value 1 output by puti: ",0
  1428.         mov    ax, 1
  1429.         puti
  1430. ;
  1431.         print
  1432.         db    cr,lf,"Unsigned value 0ffffh output by putu: ",0
  1433.         mov    ax, 0ffffh
  1434.         putu
  1435.         print
  1436.         db    cr,lf,"Unsigned value 1 output by putu: ",0
  1437.         mov    ax, 1
  1438.         putu
  1439. ;
  1440.         print
  1441.         db    cr,lf,"Long value 0ffff1234 output by putL: ",0
  1442.         mov    ax, 1234h
  1443.         mov    dx, 0ffffh
  1444.         putl
  1445.         print    
  1446.         db    cr,lf,"Long value 01234ffff output by putL: ",0
  1447.         mov    dx, 1234h
  1448.         mov    ax, 0ffffh
  1449.         putl
  1450. ;
  1451.         print
  1452.         db    cr,lf,"Unsigned long value 1234ffff output by "
  1453.         db    "putUL: ",0
  1454.         putul
  1455.         print
  1456.         db    cr,lf,"Unsigned long value 0ffff1234 output by "
  1457.         db    "putUL: ",0
  1458.         mov    dx, 0ffffh
  1459.         mov    ax, 1234h
  1460.         putUL
  1461.         putcr
  1462. ;
  1463.         mov    cx, 10
  1464. islp1:        print
  1465.         db    "Outputting -2567 using a field width of ",0
  1466.         mov    ax, cx
  1467.         puti
  1468.         print
  1469.         db    " **",0
  1470.         mov    ax, -2567
  1471.         putisize
  1472.         print
  1473.         db    "** w/PutISize",cr,lf,0
  1474.         loop    islp1
  1475. ;
  1476.         mov    cx, 10
  1477. islp2:        print
  1478.         db    "Outputting -2567 using a field width of ",0
  1479.         mov    ax, cx
  1480.         puti
  1481.         print
  1482.         db    " **",0
  1483.         mov    ax, -2567
  1484.         putusize
  1485.         print
  1486.         db    "** w/PutUSize",cr,lf,0
  1487.         loop    islp2
  1488. ;
  1489.         mov    cx, 10
  1490. islp3:        print
  1491.         db    "Outputting -2567 using a field width of ",0
  1492.         mov    ax, cx
  1493.         puti
  1494.         print
  1495.         db    " **",0
  1496.         mov    ax, -2567
  1497.         mov    dx, 0ffffh
  1498.         putlsize
  1499.         print
  1500.         db    "** w/PutLSize",cr,lf,0
  1501.         loop    islp3
  1502.         print
  1503.         db    "Outputting 0ff001234h using PutLSize: ",0
  1504.         mov    dx, 0ff00h
  1505.         mov    ax, 1234h
  1506.         mov    cx, 10
  1507.         PutLSize
  1508.         putcr
  1509. ;
  1510.         mov    cx, 10
  1511. islp4:        print
  1512.         db    "Outputting -2567 using a field width of ",0
  1513.         mov    ax, cx
  1514.         puti
  1515.         print
  1516.         db    " **",0
  1517.         mov    ax, -2567
  1518.         mov    dx, 0ffffh
  1519.         putulsize
  1520.         print
  1521.         db    "** w/PutULSize",cr,lf,0
  1522.         loop    islp4
  1523.         print
  1524.         db    "Outputting 0ff001234h using PutULSize: ",0
  1525.         mov    dx, 0ff00h
  1526.         mov    ax, 1234h
  1527.         mov    cx, 10
  1528.         PutULSize
  1529.         putcr
  1530. ;
  1531. ;****************************************************************************
  1532. ;
  1533. ; Testing the PRINTF routine:
  1534. ;
  1535.         printf
  1536.         db    "This is a test of the printf routine w/o any "
  1537.         db    "operands.\n"
  1538.         db    "It tests the esc characters \\n, \\r, \\b, \\t, "
  1539.         db    "\0x0d, and \\\\.\n"
  1540.         db    "Test of \\r:\n"
  1541.         db    "Old line.\rNew line.\n"
  1542.         db    "Test of \t\ttab.\n"
  1543.         db    "Test of backspace\b\b\b\b\bs p a c e\n"
  1544.         db    "Test of return using \\0x0d:\n"
  1545.         db    "Old line.\0x0dNew line.\n\n",0
  1546. ;
  1547.         printf
  1548.         db    cr,lf
  1549.         db    "Test of integer output formats (using I):\n"
  1550.         db    "\%d\t\t-\t*%d*\n"
  1551.         db    "\%10d\t\t-\t*%10d*\n"
  1552.         db    "\%-10d\t\t-\t*%-10d*\n"
  1553.         db    "\%\\*10d\t\t-\t*%\*10d*\n"
  1554.         db    "\%\-\\*10d\t\t-\t*%-\*10d*\n"
  1555.         db    "\%^d\t\t-\t*%^d*\n"
  1556.         db    "\%10^d\t\t-\t*%10^d*\n"
  1557.         db    "\%-10^d\t\t-\t*%-10^d*\n"
  1558.         db    "\%\\*10^d\t\t-\t*%\*10^d*\n"
  1559.         db    "\%\-\\*10^d\t-\t*%-\*10^d*\n"
  1560.         db    0
  1561.         dd    i,i,i,i,i,pi,pi,pi,pi,pi
  1562. ;
  1563.         printf
  1564.         db    cr,lf
  1565.         db    "Test of unsigned integer output formats (using U):\n"
  1566.         db    "\%u\t\t-\t*%u*\n"
  1567.         db    "\%10u\t\t-\t*%10u*\n"
  1568.         db    "\%-10u\t\t-\t*%-10u*\n"
  1569.         db    "\%\\*10u\t\t-\t*%\*10u*\n"
  1570.         db    "\%\-\\*10u\t\t-\t*%-\*10u*\n"
  1571.         db    "\%^u\t\t-\t*%^u*\n"
  1572.         db    "\%10^u\t\t-\t*%10^u*\n"
  1573.         db    "\%-10^u\t\t-\t*%-10^u*\n"
  1574.         db    "\%\\*10^u\t\t-\t*%\*10^u*\n"
  1575.         db    "\%\-\\*10^u\t-\t*%-\*10^u*\n"
  1576.         db    0
  1577.         dd    u,u,u,u,u,pu,pu,pu,pu,pu
  1578. ;
  1579.         printf
  1580.         db    cr,lf
  1581.         db    "Test of unsigned long output formats (using UL):\n"
  1582.         db    "\%ul\t\t-\t*%lu*\n"
  1583.         db    "\%15lu\t\t-\t*%15lu*\n"
  1584.         db    "\%-15lu\t\t-\t*%-15lu*\n"
  1585.         db    "\%\\*15lu\t\t-\t*%\*15lu*\n"
  1586.         db    "\%\-\\*15lu\t-\t*%-\*15lu*\n"
  1587.         db    "\%^lu\t\t-\t*%^lu*\n"
  1588.         db    "\%15^lu\t\t-\t*%15^lu*\n"
  1589.         db    "\%-15^lu\t\t-\t*%-15^lu*\n"
  1590.         db    "\%\\*15^lu\t-\t*%\*15^lu*\n"
  1591.         db    "\%\-\\*15^lu\t-\t*%-\*15^lu*\n"
  1592.         db    0
  1593.         dd    ul,ul,ul,ul,ul,pul,pul,pul,pul,pul
  1594. ;
  1595.         printf
  1596.         db    cr,lf
  1597.         db    "Test of long output formats (using L):\n"
  1598.         db    "\%ld\t\t-\t*%ld*\n"
  1599.         db    "\%15ld\t\t-\t*%15ld*\n"
  1600.         db    "\%-15ld\t\t-\t*%-15ld*\n"
  1601.         db    "\%\\*15ld\t\t-\t*%\*15ld*\n"
  1602.         db    "\%\-\\*15ld\t-\t*%-\*1ld*\n"
  1603.         db    "\%^ld\t\t-\t*%^ld*\n"
  1604.         db    "\%15^ld\t\t-\t*%15^ld*\n"
  1605.         db    "\%-15^ld\t\t-\t*%-15^ld*\n"
  1606.         db    "\%\\*15^ld\t-\t*%\*15^ld*\n"
  1607.         db    "\%\-\\*15^ld\t-\t*%-\*15^ld*\n"
  1608.         db    0
  1609.         dd    l,l,l,l,l,pl,pl,pl,pl,pl
  1610. ;
  1611.         printf
  1612.         db    cr,lf
  1613.         db    "Test of hexadecimal output (byte) using I:\n"
  1614.         db    "\%h\t\t-\t*%h*\n"
  1615.         db    "\%5h\t\t-\t*%5h*\n"
  1616.         db    "\%-5h\t\t-\t*%-5h*\n"
  1617.         db    "\%\\*5h\t\t-\t*%\*5h*\n"
  1618.         db    "\%\-\\*5h\t\t-\t*%-\*5h*\n"
  1619.         db    "\%^h\t\t-\t*%^h*\n"
  1620.         db    "\%5^h\t\t-\t*%5^h*\n"
  1621.         db    "\%-5^h\t\t-\t*%-5^h*\n"
  1622.         db    "\%\\*5^h\t\t-\t*%\*5^h*\n"
  1623.         db    "\%\-\\*5^h\t\t-\t*%-\*5^h*\n"
  1624.         db    0
  1625.         dd    i,i,i,i,i,pi,pi,pi,pi,pi
  1626. ;
  1627.         printf
  1628.         db    cr,lf
  1629.         db    "Test of hexadecimal output (word) using I:\n"
  1630.         db    "\%x\t\t-\t*%x*\n"
  1631.         db    "\%5x\t\t-\t*%5x*\n"
  1632.         db    "\%-5x\t\t-\t*%-5x*\n"
  1633.         db    "\%\\*5x\t\t-\t*%\*5x*\n"
  1634.         db    "\%\-\\*5x\t\t-\t*%-\*5x*\n"
  1635.         db    "\%^x\t\t-\t*%^x*\n"
  1636.         db    "\%5^x\t\t-\t*%5^x*\n"
  1637.         db    "\%-5^x\t\t-\t*%-5^x*\n"
  1638.         db    "\%\\*5^x\t\t-\t*%\*5^x*\n"
  1639.         db    "\%\-\\*5^x\t\t-\t*%-\*5^x*\n"
  1640.         db    0
  1641.         dd    i,i,i,i,i,pi,pi,pi,pi,pi
  1642. ;
  1643.         printf
  1644.         db    cr,lf
  1645.         db    "Test of hexadecimal output (long) using UL:\n"
  1646.         db    "\%lx\t\t-\t*%lx*\n"
  1647.         db    "\%15lx\t\t-\t*%15lx*\n"
  1648.         db    "\%-15lx\t\t-\t*%-15lx*\n"
  1649.         db    "\%\\*15lx\t\t-\t*%\*15lx*\n"
  1650.         db    "\%\-\\*15lx\t-\t*%-\*15lx*\n"
  1651.         db    "\%^lx\t\t-\t*%^lx*\n"
  1652.         db    "\%15^lx\t\t-\t*%15^lx*\n"
  1653.         db    "\%-15^lx\t\t-\t*%-15^lx*\n"
  1654.         db    "\%\\*15^lx\t-\t*%\*15^lx*\n"
  1655.         db    "\%\-\\*15^lx\t-\t*%-\*15^lx*\n"
  1656.         db    0
  1657.         dd    ul,ul,ul,ul,ul,pul,pul,pul,pul,pul
  1658. ;
  1659.         printf
  1660.         db    cr,lf
  1661.         db    "Test of character output using S:\n"
  1662.         db    "\%c\t\t-\t*%c*\n"
  1663.         db    "\%5c\t\t-\t*%5c*\n"
  1664.         db    "\%-5c\t\t-\t*%-5c*\n"
  1665.         db    "\%\\*5c\t\t-\t*%\*5c*\n"
  1666.         db    "\%\-\\*5c\t\t-\t*%-\*5c*\n"
  1667.         db    "\%^c\t\t-\t*%^c*\n"
  1668.         db    "\%5^c\t\t-\t*%5^c*\n"
  1669.         db    "\%-5^c\t\t-\t*%-5^c*\n"
  1670.         db    "\%\\*5^c\t\t-\t*%\*5^c*\n"
  1671.         db    "\%\-\\*5^c\t\t-\t*%-\*5^c*\n"
  1672.         db    0
  1673.         dd    s,s,s,s,s,ps,ps,ps,ps,ps
  1674. ;
  1675.         printf
  1676.         db    cr,lf
  1677.         db    "Test of string output using s:\n"
  1678.         db    "\%s\t\t-\t*%s*\n"
  1679.         db    "\%15s\t\t-\t*%15s*\n"
  1680.         db    "\%-15s\t\t-\t*%-15s*\n"
  1681.         db    "\%\\*15s\t\t-\t*%\*15s*\n"
  1682.         db    "\%\-\\*15s\t\t-\t*%-\*15s*\n"
  1683.         db    "\%^s\t\t-\t*%^s*\n"
  1684.         db    "\%15^s\t\t-\t*%15^s*\n"
  1685.         db    "\%-15^s\t\t-\t*%-15^s*\n"
  1686.         db    "\%\\*15^s\t\t-\t*%\*15^s*\n"
  1687.         db    "\%\-\\*15^s\t-\t*%-\*15^s*\n"
  1688.         db    0
  1689.         dd    s,s,s,s,s,ps,ps,ps,ps,ps
  1690. ;
  1691. ;****************************************************************************
  1692. ;
  1693. ; Test the input routines here.
  1694. ;
  1695.         print
  1696.         db    "Testing GETC- Press any key: ",0
  1697.         getc
  1698.         print
  1699.         db    cr,lf,"You pressed: '",0
  1700.         putc
  1701.         print
  1702.         db    "' : ",0
  1703.         putw
  1704.         print
  1705.         db    cr,lf,"Testing GetcStdIn- Press any key:",0
  1706.         GetcStdIn
  1707.         print
  1708.         db    cr,lf,"You pressed: '",0
  1709.         putc
  1710.         print
  1711.         db    "' : ",0
  1712.         putw
  1713.         print
  1714.         db    cr,lf,"Testing GetcBIOS- Press any key:",0
  1715.         getcBIOS
  1716.         print
  1717.         db    cr,lf,"You pressed: '",0
  1718.         putc
  1719.         print
  1720.         db    "' : ",0
  1721.         putw
  1722. ;
  1723.         print
  1724.         db    cr,lf,"Redirecting input, reading: ",0
  1725.         lesi    ReturnA
  1726.         SetInAdrs
  1727.         getc
  1728.         print
  1729.         db    cr,lf,"Getc returned: '",0
  1730.         putc
  1731.         print
  1732.         db    "' : ",0
  1733.         putw
  1734.         print
  1735.         db    cr,lf,"Pushing address, changing to 'B': ",0
  1736.         lesi    ReturnB
  1737.         PushInAdrs
  1738.         getc
  1739.         print
  1740.         db    cr,lf,"Getc returned: '",0
  1741.         putc
  1742.         print
  1743.         db    "' : ",0
  1744.         putw
  1745.         print
  1746.         db    cr,lf,"Popping address: ",0
  1747.         PopInAdrs
  1748.         cmp    di, offset ReturnB
  1749.         jne    BadPopIn
  1750.         mov    di, es
  1751.         cmp    di, seg ReturnB
  1752.         je    GoodPopIn
  1753. BadPopIn:    print
  1754.         db    cr,lf,"Did not return the proper address",cr,lf,0
  1755. GoodPopIn:    print
  1756.         db    cr,lf,"Popping address again, should read from kbd: "
  1757.         db    0
  1758.         PopInAdrs
  1759.         getc
  1760.         print
  1761.         db    cr,lf,"Getc returned: '",0
  1762.         putc
  1763.         print
  1764.         db    "' : ",0
  1765.         putw
  1766.         putcr
  1767. ;
  1768. ;****************************************************************************
  1769. ;
  1770. ; Test GETS here:
  1771. ;
  1772.         print
  1773.         db    "Testing GETS, enter a line of text: ",0
  1774.         gets
  1775.         jnc    goodgets
  1776.         print
  1777.         db    "Bad gets call",cr,lf,0
  1778. ;
  1779. goodgets:    print
  1780.         db    "You entered: ",0
  1781.         puts
  1782.         putcr
  1783. ;
  1784. ;
  1785. ;***************************************************************************
  1786. ;
  1787. ;
  1788. ;
  1789. Quit:        mov     ah, 4ch
  1790.         int     21h
  1791. ;
  1792. ;
  1793. Main        endp
  1794. ;
  1795. ;
  1796. dblchars    proc    far
  1797.         putcstdout
  1798.         putcstdout
  1799.         ret
  1800. dblchars    endp
  1801. ;
  1802. ;
  1803. ReturnA        proc    far
  1804.         mov    ax, "A"
  1805.         ret
  1806. ReturnA        endp
  1807. ;
  1808. ReturnB        proc    far
  1809.         mov    ax, "B"
  1810.         ret
  1811. ReturnB        endp
  1812. ;
  1813. ;
  1814. ; Printset- Prints the characters in the set passed in es:di
  1815. ;
  1816. PrintSet    proc
  1817.         push    es
  1818.         push    ds
  1819.         push    di
  1820.         push    si
  1821.         push    dx
  1822.         push    ax
  1823. ;
  1824.         mov    dx, es        ;dx:si := es:di
  1825.         mov    si, di
  1826. ;
  1827.         createsets
  1828.         copyset
  1829. PrLoop:        rmvitem
  1830.         cmp    al, 0
  1831.         jz    PrDone
  1832.         putc
  1833.         jmp    PrLoop
  1834. ;
  1835. PrDone:        free
  1836.         pop    ax
  1837.         pop    dx
  1838.         pop    si
  1839.         pop    di
  1840.         pop    ds
  1841.         pop    es
  1842.         ret
  1843. PrintSet    endp
  1844. ;
  1845. ;
  1846. cseg            ends
  1847. ;
  1848. ;
  1849. ; Allocate a reasonable amount of space for the stack (2k).
  1850. ;
  1851. sseg        segment    para stack 'stack'
  1852. stk        db    256 dup ("stack   ")
  1853. sseg        ends
  1854. ;
  1855. ;
  1856. ;
  1857. ; zzzzzzseg must be the last segment that gets loaded into memory!
  1858. ;
  1859. zzzzzzseg    segment    para public 'zzzzzz'
  1860. LastBytes    db    16 dup (?)
  1861. heap        db    1024 dup (?)
  1862. zzzzzzseg    ends
  1863.         end    Main
  1864.