Category : Assembly Language Source Code
Archive   : RHSTDLIB.ZIP
Filename : TEST.ASM
;
; T E S T S U I T E F O R
;
;
; R A N D Y H Y D E ' S S T A N D A R D
;
; L I B R A R Y F O R A S S E M B L Y
;
; L A N G U A G E P R O G R A M M E R S
;
;****************************************************************************
;
;
; Global variables go here:
;
dseg segment para public 'data'
i dw -4321
pi dd i
u dw 2345
pu dd u
l dd -1234567890
pl dd l
ul dd 987654321
pul dd ul
;
ps dd s
s db "Printf string",0
TestString0 db "This string gets printed by puts!",cr,lf,0
TestString1 db "This string gets used by the STRxxx Routines",cr,lf,0
TestString2 db "gets",0
TestString3 db "Hello there",0
TestString4 db "THIS STRING GETS USED BY THE STRXXX ROUTINES",cr,lf,0
TestString5 db "all lower case",cr,lf,0
TestString6 db "Clear out this string",0
StringSet1 db "Tabcdefghijklmnopqrst ",0
StringSet2 db "uvwxyz!",0
buffer db 256 dup (?)
buffer2 db 256 dup (?)
sfstr1 db "1 -1 1 65000 100000 -100000 1 4000000000 0abc x",0
sfstr2 db "1, 2",0
hex1 db "12ab",0
int1 db "-12345",0
int2 db "65000",0
lint1 db "-2000000000",0
lint2 db "4000000000",0
i1 dw ?
i2 dw ?
u1 dw ?
u2 dw ?
l1 dd ?
l2 dd ?
ul1 dd ?
ul2 dd ?
h1 dw ?
c1 db ?
c2 db '!'
MemAvail dw ?
;
; Allocate some character sets down here
;
set charset, cs2, cs3, cs4
;
dseg ends
;
;
;
;
cseg segment para public 'code'
assume cs:cseg, ds:dseg
;
include stdlib.a
;
lesi macro adrs
mov di, seg adrs
mov es, di
lea di, adrs
endm
;
ldxi macro adrs
mov dx, seg adrs
lea si, adrs
endm
;
; Variables that wind up being used by the standard library routines.
; The MemInit routine uses "PSP" and "zzzzzzseg" labels. They must be
; present if you intend to use getenv, MemInit, malloc, and free.
;
;
public PSP
PSP dw ?
;
cr equ 13
lf equ 10
;
;
; Main is the main program. Program execution always begins here.
;
Main proc
mov cs:PSP, es ;Save pgm seg prefix
mov ax, seg dseg ;Set up the segment registers
mov ds, ax
mov es, ax
mov dx, 0 ;Allocate all available RAM.
MemInit
mov MemAvail, cx
printf
db "There are %x paragraphs of memory available."
db cr,lf,lf,0
dd MemAvail
;
;
;
;
;***************************************************************************
;
; Test the character set routines down here:
;
db "Testing RangeSet:",cr,lf,0
mov al, 'A'
mov ah, 'F'
lesi CharSet
rangeset
db "Chars in set: ",0
call PrintSet
;
db cr,lf,lf,"Testing addstr, addstrl:",cr,lf,0
lesi cs2
ldxi StringSet2
addstr
addstrl
db "aAbBcCdDeEfF",0
db "Chars in set: ",0
call PrintSet
;
db cr,lf,lf,"Testing rmvstr, rmvstrl:",cr,lf,0
lesi cs2
ldxi StringSet2
rmvstr
rmvstrl
db "ABCDEF",0
db "Chars in set: ",0
call PrintSet
;
db cr,lf,lf,"Testing addchar/rmvchar:",cr,lf,0
lesi cs2
mov al, 'A'
addchar
mov al, 'a'
rmvchar
db "Chars in set: ",0
call PrintSet
;
db cr,lf,lf,"Testing emptyset:",cr,lf,0
emptyset
db "Chars in set: ",0
call PrintSet
;
db cr,lf,lf,"Testing member:",cr,lf,0
addstrl
db "ABCDEF",0
mov al, 'A'
member
jne NotInSet1
db "A was not in the set",0
jmp short NIS1
;
NotInSet1: print
db "A is in the set",0
NIS1: putcr
mov al, "G"
member
jne NotInSet2
db "G is not in the set",0
jmp short NIS2
;
NotInSet2: print
db "G is in the set",0
NIS2: putcr
;
db cr,lf,lf,"Testing copyset:",cr,lf,0
mov dx, es
mov si, di
lesi cs3
copyset
db "Value in cs3: ",0
call Printset
;
db cr,lf,lf,"Testing unionset:",cr,lf,0
addstrl
db "ABCDEFuvwxyz",0
ldxi cs2
setunion
db "Chars in set: ",0
call Printset
;
db cr,lf,lf,"Testing set difference",cr,lf,0
ldxi cs2
setdifference
db "Chars in set: ",0
call PrintSet
;
;
;
;***************************************************************************
;
; Test the STRxxx routines here.
;
;
;*Strspan
;
db cr,lf,lf,"Testing strspan:",cr,lf,0
;
lesi TestString1
ldxi StringSet1
strspan
mov i1, cx
printf
db "TestString1 contains a character not found in "
db "StringSet1 at position %d\n\n",0
dd i1
;
;
;*Strspanl
;
db "Testing strspanl:",cr,lf,0
;
lesi TestString1
strspanl
db "Tabcdefghijklmnopqrst ",0
mov i1, cx
printf
db "TestString1 contains a character not found in "
db "the set at position %d\n\n",0
dd i1
;
;
;*Strcspan
;
db "Testing strcspan:",cr,lf,0
;
lesi TestString1
ldxi StringSet2
strcspan
mov i1, cx
printf
db "TestString1 contains a character found in "
db "StringSet2 at position %d\n\n",0
dd i1
;
;
;*Strcspanl
;
db "Testing strcspanl:",cr,lf,0
;
lesi TestString1
strcspanl
db "uvwxyz!",0
mov i1, cx
printf
db "TestString1 contains a character not found in "
db "the set at position %d\n\n",0
dd i1
;
;
;*Strset, Strset2
;
db "Testing Strset",cr,lf,0
;
lesi TestString6
mov al, '*'
strset
puts
;
;
db cr,lf,lf,"Testing StrSet2:",cr,lf,0
mov cx, 32
mov al, '#'
strset2
puts
free
putcr
putcr
;
;
;*Strupr, Strupr2
;
printf
db "Testing Strupr:\n"
db "Before: %s",0
dd TestString5
lesi TestString5
strupr
printf
db "After: %s",0
dd TestString5
;
;
;*Strlwr, Strlwr2
;
printf
db cr,lf,"Testing Strlwr:\n"
db "Before: %s",0
dd TestString5
lesi TestString5
strlwr
printf
db "After: %s",0
dd TestString5
;
;
;
;*Strcmp, Strcmpl
;
db "Testing Strcmp",cr,lf,0
;
lesi TestString1
ldxi TestString1
strcmp
jne Sne1
db "TestString1 == TestString1",cr,lf,0
jmp short s2
;
Sne1: print
db "TestString1 <> TestString1",cr,lf,0
;
s2: ldxi TestString0
strcmp
jb IsBelow
ja IsAbove
printf
db "'%s' is equal to '%s'\n",0
dd TestString1, TestString0
jmp short s3
;
IsBelow: printf
db "%s is less than \n%s\n",0
dd TestString1, TestString0
jmp short s3
;
IsAbove: printf
db "%s is greater than \n%s\n",0
dd TestString1, TestString0
;
S3:
;
db cr,lf,"Testing Strcmpl",cr,lf,0
;
lesi TestString2
strcmpl
db "gets",0
jne Sne1a
db "TestString2 == 'gets'",cr,lf,0
jmp short s2a
;
Sne1a: print
db "TestString2 <> 'gets'",cr,lf,0
;
s2a: lesi TestString2
strcmpl
db "itsa",0
jb IsBelowa
ja IsAbovea
printf
db "'%s' is equal to 'itsa'\n",0
dd TestString2
jmp short s3a
;
IsBelowa: printf
db "'%s' is less than 'itsa'\n",0
dd TestString2
jmp short s3a
;
IsAbovea: printf
db "'%s' is greater than 'itsa'\n",0
dd TestString2
;
S3a:
;
;
;*Stricmp, Stricmpl
;
db cr,lf,"Testing Stricmp",cr,lf,0
;
lesi TestString1
ldxi TestString4
stricmp
jne Sne1c
db "TestString1 == TestString4",cr,lf,0
jmp short s2c
;
Sne1c: print
db "TestString1 <> TestString4",cr,lf,0
;
s2c: lesi TestString1
ldxi TestString4
stricmp
jb IsBelowc
ja IsAbovec
printf
db "'%s' is equal to '%s'\n",0
dd TestString1, TestString4
jmp short s3c
;
IsBelowc: printf
db "'%s' is less than '%s'\n",0
dd TestString1, TestString4
jmp short s3c
;
IsAbovec: printf
db "'%s' is greater than '%s'\n",0
dd TestString1, TestString4
;
S3c:
;
;
db "Testing Stricmpl",cr,lf,0
;
lesi TestString2
stricmpl
db "GETS",0
jne Sne1d
db "TestString2 == 'gets'",cr,lf,0
jmp short s2d
;
Sne1d: print
db "TestString2 <> 'gets'",cr,lf,0
;
s2d: lesi TestString2
strcmpl
db "itsa",0
jb IsBelowd
ja IsAboved
printf
db "'%s' is equal to 'itsa'\n",0
dd TestString2
jmp short s3d
;
IsBelowd: printf
db "'%s' is less than 'itsa'\n",0
dd TestString2
jmp short s3d
;
IsAboved: printf
db "'%s' is greater than 'itsa'\n",0
dd TestString2
;
S3d:
;
;
;*Strcpy
;
lesi TestString1
ldxi Buffer
strcpy
puts
;
;*Strcpyl
;
db "Testing Strcpyl:",cr,lf,0
;
ldxi Buffer
strcpyl
db "This is an strcpyl string",cr,lf,0
puts
ldxi Buffer2
strcpy
puts
;
;*Strdup
;
lesi TestString1
strdup
puts
free
;
;*Strdupl
;
db "Testing Strdupl:",cr,lf,0
;
strdupl
db "This string is for strdupl",cr,lf,0
puts
free
;
;*Strlen
;
lesi s
strlen
mov i1, cx
printf
db "Length of string: '%s' is %d\n",0
dd s, i1
;
;*Strcat
;
db "Testing strcat:",cr,lf,0
;
lesi Buffer
strcpyl
db "Test String 1 --",0
ldxi TestString1
strcat
puts
;
;*Strcatl
;
db "Testing strcatl:",cr,lf,0
;
lesi Buffer
strcpyl
db "Strcatl test --",0
strcatl
db "More stuff for Strcatl",cr,lf,0
puts
;
;*Strcat2
;
db "Testing strcat2:",cr,lf,0
;
lesi TestString1
ldxi TestString0
strcat2
puts
free
;
db "Testing strcat2l:",cr,lf,0
;
lesi TestString1
strcat2l
db "Appended string",cr,lf,0
puts
free
;
;*Strchar
;
lesi TestString1
mov al, 'a'
StrChr
pushf
mov i1, cx
printf
db "Testing strchr:",cr,lf
db "Searching for 'a' in '%s'\n"
db "Found it at position %d\n",0
dd TestString1, i1
popf
jnc FndIt1
db "Could not find character in string.",cr,lf,0
;
FndIt1: lesi TestString1
mov al, 'T'
StrChr
pushf
mov i1, cx
printf
db "Testing strchr:",cr,lf
db "Searching for 'T' in '%s'\n"
db "Found it at position %d\n",0
dd TestString1, i1
popf
jnc FndIt2
db "Could not find character in string.",cr,lf,0
FndIt2:
;
;
;*Strstr
;
db "Testing strstr:",cr,lf,0
;
lesi TestString1
ldxi TestString2
strstr
jc NotFnd2
mov i1, cx
printf
db "Found substring at position %i\n",0
dd i1
jmp short FndIt3
;
NotFnd2: print
db "Didn't find substring #1.",cr,lf,0
;
FndIt3: ldxi TestString3
strstr
jc NotFnd3
db "Error, found a string which isn't present!",cr,lf,0
;
NotFnd3:
;
;
;*Strstrl
;
db "Testing strstrl:",cr,lf,0
;
lesi TestString1
strstrl
db "gets",0
jc NotFnd2a
mov i1, cx
printf
db "Found substring at position %i\n",0
dd i1
jmp short FndIt3a
;
NotFnd2a: print
db "Didn't find substring #1.",cr,lf,0
;
FndIt3a: strstrl
db "Hello There",0
jc NotFnd3a
db "Error, found a string which isn't present!",cr,lf,0
;
NotFnd3a:
;
;
;
;
putcr
putcr
;
;***************************************************************************
;
; Test IsAlNum, IsDigit, IsAlpha, IsLower, IsUpper, and IsxDigit here:
;
db "Testing IsAlNum, IsDigit, IsAlpha, IsLower, "
db "IsUpper, and IsXDigit",cr,lf,0
;
mov cx, 26
mov al, 'Z'
mov ah, 'z'
TstAlphaLp: IsAlNum
jne yALNumFail
IsAlpha
jne ALFail
IsUpper
jne UprFail
cmp al, 'F'
ja NotHex
IsXDigit
jne XFail
;
NotHex: xchg al, ah
IsAlNum
yALNumFail: jne AlNumFail
IsAlpha
jne ALFail
IsLower
jne LwrFail
cmp al, 'f'
ja NotHex2
IsXDigit
jne XFail
;
NotHex2: xchg al, ah
dec al
dec ah
loop TstAlphaLp
;
mov cx, 10
mov al, '9'
TstDigLp: IsDigit
jne DigitFail
IsAlNum
jne AlNumFail
IsXDigit
jne XFail
dec al
loop TstDigLp
jmp short TestBad
;
ALNumFail: jmp short xALNumFail
ALFail: jmp short xALFail
UprFail: jmp xUprFail
LwrFail: jmp xLwrFail
XFail: jmp xXFail
DigitFail: jmp xDigitFail
;
TestBad: mov al, '1'
IsAlpha
je ALFail
IsLower
je LwrFail
IsUpper
je UprFail
mov al, '!'
IsDigit
je DigitFail
IsAlNum
je AlNumFail
IsXDigit
je XFail
jmp TestSPrintf
;
xALNumFail: print
db "IsALNum has failed",cr,lf,0
jmp TestSPrintf
;
xALFail: print
db "IsAlpha has failed",cr,lf,0
jmp short TestSPrintf
;
xUprFail: print
db "IsUpper has failed",cr,lf,0
jmp short TestSPrintf
;
xLwrFail: print
db "IsLower has failed",cr,lf,0
jmp short TestSPrintf
;
xXFail: print
db "IsXDigit has failed",cr,lf,0
jmp short TestSPrintf
;
xDigitFail: print
db "IsDigit has failed",cr,lf,0
;
;***************************************************************************
;
; Testing sprintf and sbprintf here.
;
TestSPrintf: sprintf
db "I= %i, I='%10i', I=%^i",cr,lf
db "U= %u",cr,lf,0
dd i,i,pi,u
puts
free
;
lesi Buffer
sbprintf
db "I= %i, I='%10i', I=%^i",cr,lf
db "U= %u",cr,lf,0
dd i,i,pi,u
puts
;
;***************************************************************************
;
; Testing various ITOxx routines here.
;
mov ax, -1234
itoa
db "ITOA: -1234 is ",0
puts
putcr
free ;Free allocated storage.
;
;-----
;
mov ax, 43210
utoa
db "UTOA: 43210 is ",0
puts
putcr
free ;Free allocated storage.
;
;-----
;
mov ax, 0ABCDh
htoa
db "HTOA: 0cdh is ",0
puts
putcr
free ;Free allocated storage.
;
;-----
;
mov ax, 0ABCDh
wtoa
db "WTOA: 0abcdh is ",0
puts
putcr
free ;Free allocated storage.
;
;-----
;
mov ax, -1234
mov dx, 0ffffh
ltoa
db "LTOA: -1234 is ",0
puts
putcr
free
;
;-----
;
mov ax, 1234
mov dx, 0
ultoa
db "ULTOA: 1234 is ",0
puts
putcr
free
;
;
;***************************************************************************
;
; Testing memory management routines here:
;
mov cx, 256
malloc
IsPtr
jnc ValidPtr
db "This is not a valid ptr (1)",cr,lf,0
jmp short x1
;
ValidPtr: print
db "Malloc returned a valid ptr",cr,lf,0
;
x1: inc di
IsPtr
jc InvalidPtr
db "Incrementing a pointer didn't make it invalid",cr,lf,0
jmp short x2
;
InvalidPtr: print
db "Incrementing a pointer makes it invalid",cr,lf,0
;
x2: IsInHeap
jc BadIsIn
db "Although incrementing it leaves it in the heap",cr,lf,0
jmp short x3
;
BadIsIn: print
db "Incrementing the pointer moved it out of the heap"
db cr,lf,0
;
x3: dec di
free
jnc GoodFree
db "Free returned an error",cr,lf,0
jmp short x4
;
GoodFree: print
db "FREE did its job.",cr,lf,0
;
x4: mov cx, 512
malloc
mov cx, 256
realloc
jnc GoodRealloc
db "Realloc screwed up!",cr,lf,0
jmp x5
;
GoodRealloc: DupPtr
free
jnc GF1
db "Free choked after DupPtr",cr,lf,0
jmp short x5
;
GF1: free
jnc GF2
db "Free choked after second call.",cr,lf,0
jmp short x5
;
GF2: free
jc x5
db "Free DIDN'T return an error when it was "
db "supposed to.",cr,lf,0
;
x5:
;
;
;****************************************************************************
;
; Testing the ISIZE and LSIZE routines here:
;
mov ax, -12345
isize
db "Size of -12345 (isize) is ",0
puti
mov ax, 1234
usize
db cr,lf,"Size of 1234 (usize) is ",0
puti
;
mov dx, 0ffffh
mov ax, -12345
lsize
db cr,lf,"Size of -12345 (lsize) is ",0
puti
mov ax, 1234
xor dx, dx
ulsize
db cr,lf,"Size of 1234 (ulsize) is ",0
puti
putcr
;
;****************************************************************************
;
; Test the "ATOxx" routines here.
;
db "Testing ATOH: ",0
lesi hex1
atoh
putw
mov al, ' '
putc
;
atoh2
putw
putcr
;
db "Testing ATOI: ",0
lesi int1
atoi
puti
mov al, ' '
putc
atoi2
puti
putcr
;
db "Testing ATOU: ",0
lesi int2
atou
putu
mov al, ' '
putc
atou2
putu
putcr
;
db "Testing ATOL: ",0
lesi lint1
atol
putl
mov al, ' '
putc
atol2
putl
putcr
;
db "Testing ATOUL: ",0
lesi lint2
atoul
putul
mov al, ' '
putc
atoul2
putul
putcr
;
;
;****************************************************************************
;
; Test SCANF here:
;
printf
db "Enter some text: ",0
scanf
db "%s",0
dd buffer
db "You entered: ",0
lesi buffer
puts
putcr
;
; Test SSCANF here:
;
printf
db "Before, c1=%c, c2=%c\n",0
dd c1,c2
;
lesi sfstr1
sscanf
db "%i %d %u %u %ld %li %lu %lu %x %c",0
dd i1,i2,u1,u2,l1,l2,ul1,ul2,h1,c1
;
printf
db "Values input by sscanf:\n"
db "i1=%d, i2=%d\n"
db "u1=%u, u2=%u\n"
db "l1=%ld, l2=%ld\n"
db "ul1=%lu, ul2=%lu\n"
db "h1=%x\n"
db "c1=%c, c2=%c\n"
db 0
dd i1,i2,u1,u2,l1,l2,ul1,ul2,h1,c1,c2
;
;
db "Testing scanf character skipping:",cr,lf,0
lesi sfstr2
sscanf
db "%i, %i",0
dd i1,i2
printf
db "i1=%i, i2=%i\n",0
dd i1, i2
;
;
;****************************************************************************
;
;
;
; Testing the PUTC routines here.
;
; The following code should print:
;
; aaa
; aaa
; aaa
; aaaaaaaa
;
; aaaa
; aaaaaaaa
;
; aaaa
;
;
mov al, 'a'
putc
putc
putc
;
putcr
;
putcstdout
putcstdout
putcstdout
putcr
;
putcbios
putcbios
putcbios
putcr
;
mov di, cs
mov es, di
lea di, dblchars
setoutadrs
;
putc
putc
putc
putc
putcr
;
getoutadrs
cmp di, offset dblchars
jne badtest
mov di, es
cmp di, seg dblchars
jne badtest
;
mov di, seg sl_putcstdout
mov es, di
lea di, sl_putcstdout
pushoutadrs
putc
putc
putc
putc
putcr
;
popoutadrs
putc
putc
putc
putc
putcr
popoutadrs
cmp di, offset dblchars
jne badtest
mov di, es
cmp di, seg dblchars
jne badtest
;
putc
putc
putc
putc
putcr
jmp short goodtest
;
badtest: print
db "GetOutAdrs or PopOutAdrs did not return "
db "the proper address",cr,lf,0
;
GoodTest:
;
;
;****************************************************************************
;
; Test the remaining print routines here
;
db "This is a test of the print routine",cr,lf,0
;
db 0
;
db "So is this!",cr,lf,0
;
lesi TestString0
puts
;
db "Hex value 0xfa output by PutH: ",0
mov al, 0fah
puth
;
db cr,lf,"Hex value 0xfa12 output by PutW: ",0
mov ax, 0fa12h
putw
;
db cr,lf,"Decimal value 0xffff output by puti: ",0
mov ax, 0ffffh
puti
db cr,lf,"Decimal value 1 output by puti: ",0
mov ax, 1
puti
;
db cr,lf,"Unsigned value 0ffffh output by putu: ",0
mov ax, 0ffffh
putu
db cr,lf,"Unsigned value 1 output by putu: ",0
mov ax, 1
putu
;
db cr,lf,"Long value 0ffff1234 output by putL: ",0
mov ax, 1234h
mov dx, 0ffffh
putl
db cr,lf,"Long value 01234ffff output by putL: ",0
mov dx, 1234h
mov ax, 0ffffh
putl
;
db cr,lf,"Unsigned long value 1234ffff output by "
db "putUL: ",0
putul
db cr,lf,"Unsigned long value 0ffff1234 output by "
db "putUL: ",0
mov dx, 0ffffh
mov ax, 1234h
putUL
putcr
;
mov cx, 10
islp1: print
db "Outputting -2567 using a field width of ",0
mov ax, cx
puti
db " **",0
mov ax, -2567
putisize
db "** w/PutISize",cr,lf,0
loop islp1
;
mov cx, 10
islp2: print
db "Outputting -2567 using a field width of ",0
mov ax, cx
puti
db " **",0
mov ax, -2567
putusize
db "** w/PutUSize",cr,lf,0
loop islp2
;
mov cx, 10
islp3: print
db "Outputting -2567 using a field width of ",0
mov ax, cx
puti
db " **",0
mov ax, -2567
mov dx, 0ffffh
putlsize
db "** w/PutLSize",cr,lf,0
loop islp3
db "Outputting 0ff001234h using PutLSize: ",0
mov dx, 0ff00h
mov ax, 1234h
mov cx, 10
PutLSize
putcr
;
mov cx, 10
islp4: print
db "Outputting -2567 using a field width of ",0
mov ax, cx
puti
db " **",0
mov ax, -2567
mov dx, 0ffffh
putulsize
db "** w/PutULSize",cr,lf,0
loop islp4
db "Outputting 0ff001234h using PutULSize: ",0
mov dx, 0ff00h
mov ax, 1234h
mov cx, 10
PutULSize
putcr
;
;****************************************************************************
;
; Testing the PRINTF routine:
;
printf
db "This is a test of the printf routine w/o any "
db "operands.\n"
db "It tests the esc characters \\n, \\r, \\b, \\t, "
db "\0x0d, and \\\\.\n"
db "Test of \\r:\n"
db "Old line.\rNew line.\n"
db "Test of \t\ttab.\n"
db "Test of backspace\b\b\b\b\bs p a c e\n"
db "Test of return using \\0x0d:\n"
db "Old line.\0x0dNew line.\n\n",0
;
printf
db cr,lf
db "Test of integer output formats (using I):\n"
db "\%d\t\t-\t*%d*\n"
db "\%10d\t\t-\t*%10d*\n"
db "\%-10d\t\t-\t*%-10d*\n"
db "\%\\*10d\t\t-\t*%\*10d*\n"
db "\%\-\\*10d\t\t-\t*%-\*10d*\n"
db "\%^d\t\t-\t*%^d*\n"
db "\%10^d\t\t-\t*%10^d*\n"
db "\%-10^d\t\t-\t*%-10^d*\n"
db "\%\\*10^d\t\t-\t*%\*10^d*\n"
db "\%\-\\*10^d\t-\t*%-\*10^d*\n"
db 0
dd i,i,i,i,i,pi,pi,pi,pi,pi
;
printf
db cr,lf
db "Test of unsigned integer output formats (using U):\n"
db "\%u\t\t-\t*%u*\n"
db "\%10u\t\t-\t*%10u*\n"
db "\%-10u\t\t-\t*%-10u*\n"
db "\%\\*10u\t\t-\t*%\*10u*\n"
db "\%\-\\*10u\t\t-\t*%-\*10u*\n"
db "\%^u\t\t-\t*%^u*\n"
db "\%10^u\t\t-\t*%10^u*\n"
db "\%-10^u\t\t-\t*%-10^u*\n"
db "\%\\*10^u\t\t-\t*%\*10^u*\n"
db "\%\-\\*10^u\t-\t*%-\*10^u*\n"
db 0
dd u,u,u,u,u,pu,pu,pu,pu,pu
;
printf
db cr,lf
db "Test of unsigned long output formats (using UL):\n"
db "\%ul\t\t-\t*%lu*\n"
db "\%15lu\t\t-\t*%15lu*\n"
db "\%-15lu\t\t-\t*%-15lu*\n"
db "\%\\*15lu\t\t-\t*%\*15lu*\n"
db "\%\-\\*15lu\t-\t*%-\*15lu*\n"
db "\%^lu\t\t-\t*%^lu*\n"
db "\%15^lu\t\t-\t*%15^lu*\n"
db "\%-15^lu\t\t-\t*%-15^lu*\n"
db "\%\\*15^lu\t-\t*%\*15^lu*\n"
db "\%\-\\*15^lu\t-\t*%-\*15^lu*\n"
db 0
dd ul,ul,ul,ul,ul,pul,pul,pul,pul,pul
;
printf
db cr,lf
db "Test of long output formats (using L):\n"
db "\%ld\t\t-\t*%ld*\n"
db "\%15ld\t\t-\t*%15ld*\n"
db "\%-15ld\t\t-\t*%-15ld*\n"
db "\%\\*15ld\t\t-\t*%\*15ld*\n"
db "\%\-\\*15ld\t-\t*%-\*1ld*\n"
db "\%^ld\t\t-\t*%^ld*\n"
db "\%15^ld\t\t-\t*%15^ld*\n"
db "\%-15^ld\t\t-\t*%-15^ld*\n"
db "\%\\*15^ld\t-\t*%\*15^ld*\n"
db "\%\-\\*15^ld\t-\t*%-\*15^ld*\n"
db 0
dd l,l,l,l,l,pl,pl,pl,pl,pl
;
printf
db cr,lf
db "Test of hexadecimal output (byte) using I:\n"
db "\%h\t\t-\t*%h*\n"
db "\%5h\t\t-\t*%5h*\n"
db "\%-5h\t\t-\t*%-5h*\n"
db "\%\\*5h\t\t-\t*%\*5h*\n"
db "\%\-\\*5h\t\t-\t*%-\*5h*\n"
db "\%^h\t\t-\t*%^h*\n"
db "\%5^h\t\t-\t*%5^h*\n"
db "\%-5^h\t\t-\t*%-5^h*\n"
db "\%\\*5^h\t\t-\t*%\*5^h*\n"
db "\%\-\\*5^h\t\t-\t*%-\*5^h*\n"
db 0
dd i,i,i,i,i,pi,pi,pi,pi,pi
;
printf
db cr,lf
db "Test of hexadecimal output (word) using I:\n"
db "\%x\t\t-\t*%x*\n"
db "\%5x\t\t-\t*%5x*\n"
db "\%-5x\t\t-\t*%-5x*\n"
db "\%\\*5x\t\t-\t*%\*5x*\n"
db "\%\-\\*5x\t\t-\t*%-\*5x*\n"
db "\%^x\t\t-\t*%^x*\n"
db "\%5^x\t\t-\t*%5^x*\n"
db "\%-5^x\t\t-\t*%-5^x*\n"
db "\%\\*5^x\t\t-\t*%\*5^x*\n"
db "\%\-\\*5^x\t\t-\t*%-\*5^x*\n"
db 0
dd i,i,i,i,i,pi,pi,pi,pi,pi
;
printf
db cr,lf
db "Test of hexadecimal output (long) using UL:\n"
db "\%lx\t\t-\t*%lx*\n"
db "\%15lx\t\t-\t*%15lx*\n"
db "\%-15lx\t\t-\t*%-15lx*\n"
db "\%\\*15lx\t\t-\t*%\*15lx*\n"
db "\%\-\\*15lx\t-\t*%-\*15lx*\n"
db "\%^lx\t\t-\t*%^lx*\n"
db "\%15^lx\t\t-\t*%15^lx*\n"
db "\%-15^lx\t\t-\t*%-15^lx*\n"
db "\%\\*15^lx\t-\t*%\*15^lx*\n"
db "\%\-\\*15^lx\t-\t*%-\*15^lx*\n"
db 0
dd ul,ul,ul,ul,ul,pul,pul,pul,pul,pul
;
printf
db cr,lf
db "Test of character output using S:\n"
db "\%c\t\t-\t*%c*\n"
db "\%5c\t\t-\t*%5c*\n"
db "\%-5c\t\t-\t*%-5c*\n"
db "\%\\*5c\t\t-\t*%\*5c*\n"
db "\%\-\\*5c\t\t-\t*%-\*5c*\n"
db "\%^c\t\t-\t*%^c*\n"
db "\%5^c\t\t-\t*%5^c*\n"
db "\%-5^c\t\t-\t*%-5^c*\n"
db "\%\\*5^c\t\t-\t*%\*5^c*\n"
db "\%\-\\*5^c\t\t-\t*%-\*5^c*\n"
db 0
dd s,s,s,s,s,ps,ps,ps,ps,ps
;
printf
db cr,lf
db "Test of string output using s:\n"
db "\%s\t\t-\t*%s*\n"
db "\%15s\t\t-\t*%15s*\n"
db "\%-15s\t\t-\t*%-15s*\n"
db "\%\\*15s\t\t-\t*%\*15s*\n"
db "\%\-\\*15s\t\t-\t*%-\*15s*\n"
db "\%^s\t\t-\t*%^s*\n"
db "\%15^s\t\t-\t*%15^s*\n"
db "\%-15^s\t\t-\t*%-15^s*\n"
db "\%\\*15^s\t\t-\t*%\*15^s*\n"
db "\%\-\\*15^s\t-\t*%-\*15^s*\n"
db 0
dd s,s,s,s,s,ps,ps,ps,ps,ps
;
;****************************************************************************
;
; Test the input routines here.
;
db "Testing GETC- Press any key: ",0
getc
db cr,lf,"You pressed: '",0
putc
db "' : ",0
putw
db cr,lf,"Testing GetcStdIn- Press any key:",0
GetcStdIn
db cr,lf,"You pressed: '",0
putc
db "' : ",0
putw
db cr,lf,"Testing GetcBIOS- Press any key:",0
getcBIOS
db cr,lf,"You pressed: '",0
putc
db "' : ",0
putw
;
db cr,lf,"Redirecting input, reading: ",0
lesi ReturnA
SetInAdrs
getc
db cr,lf,"Getc returned: '",0
putc
db "' : ",0
putw
db cr,lf,"Pushing address, changing to 'B': ",0
lesi ReturnB
PushInAdrs
getc
db cr,lf,"Getc returned: '",0
putc
db "' : ",0
putw
db cr,lf,"Popping address: ",0
PopInAdrs
cmp di, offset ReturnB
jne BadPopIn
mov di, es
cmp di, seg ReturnB
je GoodPopIn
BadPopIn: print
db cr,lf,"Did not return the proper address",cr,lf,0
GoodPopIn: print
db cr,lf,"Popping address again, should read from kbd: "
db 0
PopInAdrs
getc
db cr,lf,"Getc returned: '",0
putc
db "' : ",0
putw
putcr
;
;****************************************************************************
;
; Test GETS here:
;
db "Testing GETS, enter a line of text: ",0
gets
jnc goodgets
db "Bad gets call",cr,lf,0
;
goodgets: print
db "You entered: ",0
puts
putcr
;
;
;***************************************************************************
;
;
;
Quit: mov ah, 4ch
int 21h
;
;
Main endp
;
;
dblchars proc far
putcstdout
putcstdout
ret
dblchars endp
;
;
ReturnA proc far
mov ax, "A"
ret
ReturnA endp
;
ReturnB proc far
mov ax, "B"
ret
ReturnB endp
;
;
; Printset- Prints the characters in the set passed in es:di
;
PrintSet proc
push es
push ds
push di
push si
push dx
push ax
;
mov dx, es ;dx:si := es:di
mov si, di
;
createsets
copyset
PrLoop: rmvitem
cmp al, 0
jz PrDone
putc
jmp PrLoop
;
PrDone: free
pop ax
pop dx
pop si
pop di
pop ds
pop es
ret
PrintSet endp
;
;
cseg ends
;
;
; Allocate a reasonable amount of space for the stack (2k).
;
sseg segment para stack 'stack'
stk db 256 dup ("stack ")
sseg ends
;
;
;
; zzzzzzseg must be the last segment that gets loaded into memory!
;
zzzzzzseg segment para public 'zzzzzz'
LastBytes db 16 dup (?)
zzzzzzseg ends
end Main
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/