home *** CD-ROM | disk | FTP | other *** search
- ;Test program for SIMIL_A.ASM string comparison function.
- ;Relatively complete explanation there, or read the original article
- ;in Dr. Dobbs Journal.
- ;
- ;My stuff released to public domain, original authors retain
- ;any copyright, etc. (though none was indicated).
- ;
- ;David Kirschbaum
- ;Toad Hall
- ;kirsch@braggvax.ARPA
-
- CR EQU 0DH
- LF EQU 0AH
-
- CSeg SEGMENT PUBLIC PARA 'CODE'
-
- ;WARNING: This test program ONLY works if SS is in fact CSeg!
- ;That kinda blows away .EXE formats, etc. in the present configuration.
- ;But this is only a demo, after all ... my fees are $45 an hour
- ;if you want anything else...
-
- ASSUME CS:CSeg, DS:CSeg, ES:CSeg, SS:CSeg
-
- org 100H
-
- TestSim proc near
- jmp Start
-
- include simil_a.asm
-
- str1 db '[20char test string]',0
- str2 db '[20char test string]',0
- STRLEN = $ - str2 ;string length
-
- db 9,'Similarity: $'
- percentmsg db '%',CR,LF,'$'
-
- Start:
- mov bx,offset str2 ;point to where we'll change string 2
- mov cx,STRLEN ;do this for all string 2 chars
-
- mov si,offset str1 ;first test string (never changes)
- mov di,offset str2 ;second test string (ditto)
-
- Str_Lup:
- mov dx,si ;display both strings, 'Similarity'
- mov ah,9 ;display msg
- int 21H
-
- call _Simil ;call our procedure
-
- call WordWrite ;display value in AX
-
- mov byte ptr [bx],'.' ;overwrite a string 2 char
- inc bx ;bump to next blank for next time
-
- mov dx,offset percentmsg ;'%', terminating CR/LF
- mov ah,9
- int 21H
-
- loop Str_Lup ;do this for all string 2 chars
-
- mov ax,4C00H ;terminate
- int 21H
-
- TestSim endp
-
- Display_Int proc near
- ;from DISKSCAN.ASM, changed a little for this application.
-
- divisors dw 10000, 1000, 100, 10, 1 ; For decimal conversion
-
- ;AX contains word to display
- WordWrite:
- Push BX ;save our char pointer TH
- Push CX ;and our loop counter TH
- Push SI ;and our string pointer TH
-
- Mov SI, Offset divisors ; SI points to divisors
- Mov CX, 4 ; CL counter; CH zero blanker
-
- WordWriteLoop:
- Mov BX, [SI] ; Get divisor
- Add SI, 2 ; Increment SI for next one
- Sub DX, DX ; Prepare for division
- Div BX ; Divide DX:AX by BX
- Push DX ; Save remainder
- Or CH, AL ; See if zero
- Jz LeadZero ; If so, do not display it
- Add AL, '0' ; Convert number to ASCII
- ;TH Mov DL, AL ; Print out character
- ;TH Mov AH, 2 ; by calling DOS
- ;TH Int 21h
- int 29H ;undocumented quick screen output TH
- ;reputedly works with all DOS's
- ;(fer shur with my PC-DOS 3.1
- LeadZero:
- Pop AX ; Get back remainder
- Dec CL ; Decrement counter
- Jg WordWriteLoop ; If CL still > 0, do it again
- Mov CH, 1 ; No more zero blanking
- Jz WordWriteLoop ; Convert last digit to ASCII
-
- Pop SI ; Get back pushed registers
- Pop CX
- Pop BX
- Ret
- Display_Int endp
-
- CSeg ends
- end TestSim