Category : Miscellaneous Language Source Code
Archive   : NEC-V20.ZIP
Filename : BENCHE.ASM
NAME BENCHE
;--------------------------------------------------------------------------------
; :
; V-Series Benchmark Tests :
; :
; EDN Benchmark E - Character String Search :
; :
; NOTE - This version is used for both 8086 and V-Series family timings :
; since no new V-Series instructions apply to this benchmark. :
; :
;--------------------------------------------------------------------------------
$INCLUDE(\SIII\VSERIES.MAC)
CODE SEGMENT WORD PUBLIC
PUBLIC MAIN
EXTRN EPILOGUE : NEAR, PROLOGUE : NEAR, PUTS : NEAR
ORG 0100H
ASSUME CS:CODE, DS:CODE, ES:CODE, SS:CODE
MAIN PROC NEAR
;
; Begin by determining if the processor is a V20/V30 or a 8086/8088.
; In this case, a V20/V30 with set the least significant bit of the CW
; register, while an 8086/8088 will execute a POP CS and a SBC with an
; immediate operand. Since CW is cleared to begin with, if the contents
; of CW are not zero the processor must be a V20/V30.
;
MOV V20_V30, -1 ; Assume a V20/V30 microprocessor
PUSH CS ; Push the PS on stack
XOR CX, CX ; Clear the CW register
SET1 CX, 0 ; Execute the determining instruction
OR CX, CX ; Test if CW has changed value
JNZ VSERIES ; Continue with the V-Series demonstration
MOV V20_V30, 0 ; Set the V-Series flag
JMP UPD8086 ; And continue
VSERIES:
POP AX ; Restore the stack
; No pop was performed by V-Series processor
UPD8086:
MOV DX, OFFSET BENCH_E_STR ; Display the benchmark message
CALL PUTS
CALL PROLOGUE ; Initialize the demo
MOV CX, 20000 ; Do 20000 iterations
NEXT:
PUSH CX
MOV DI, OFFSET TABLE_START ; Setup the table offset
MOV CX, OFFSET TABLE_END ; Get the end of the table
SUB CX, OFFSET TABLE_START ; Subtract the start of the table
MOV SI, OFFSET STRING_START
MOV BX, OFFSET STRING_END ; Get the end of the search string
SUB BX, OFFSET STRING_START ; Subtract the starting offset - BX now
; contains the search string length
CALL BENCH_E ; Run the benchmark
POP CX
LOOP NEXT
CALL EPILOGUE ; Clean up the demo
INT 20H ; Return to DOS
MAIN ENDP
PUBLIC V20_V30
V20_V30 DB ?
BENCH_E_STR DB 13, 'EDN Benchmark E - String Search Benchmark (20,000 Iterations)', 13, '$'
$EJECT
;--------------------------------------------------------------------------------
; :
; EDN Benchmark for the 8086 - Character String Search :
; :
; :
; Inputs :
; :
; ES:DI - Pointer to the target string :
; DS:SI - Pointer to the search string :
; CX - Target string length in bytes :
; BX - Search string length in bytes :
; :
; Outputs :
; :
; DI - Contains the index to the first occurance of the search :
; string in the target string of -1 if no such string exists. :
; :
; Registers Modified :
; :
; CX, DI :
; :
; All other registers are intact :
; :
;--------------------------------------------------------------------------------
BENCH_E PROC NEAR
PUSH AX ; Save the working register set
PUSH DX
PUSH CX ; Save a copy of the target string length
CLD ; Search forward
MOV AL, [SI] ; Load the first character
SUB CX, BX ; Compute the length difference between the
; target string and the source string
INC CX ; Adjust to be max search length
;
; Find the first matching character
;
TRYNXT:
REPNE SCASB ; Scan the string while not equal
JE MATCH1 ; Jump if a match is located
NOTFND:
MOV DI, -1 ; Set the Not Found Flag
JMP DONE ; Exit
;
; Found the firat character of a string that is a potential match. Continue
; scanning the rest of the string for a match.
;
MATCH1:
MOV DX, CX ; Save the possible search count
PUSH DI ; Save the current position in the table
MOV CX, BX ; Get the search string length
PUSH SI ; Save the string pointer
DEC DI ; Retry the first in case the string length is 1
REPE CMPSB ; Compare the strings
;
; Drop through if the string does not match when the search length has
; been exhausted.
;
POP SI ; Restore the source string pointer
POP DI ; Restore the table pointer
MOV CX, DX ; Restore the possible search count
JE FOUND ; String match found
JCXZ NOTFND ; End of table - no match found
JMP TRYNXT ; Start searching from the next character in the table
FOUND:
POP DI ; Get the target table length
SUB DI, DX ; Compute the pointer to the string match in the table
SUB DI, BX ; Adjust for the search string size
;
; Restore the registers
;
DONE:
POP DX ; Restore the working registers
POP AX
RET ; Return to caller
BENCH_E ENDP
;
; The data table is 120 characters inlength. A partial match
; is found in position 60 while the actual match is in position 90.
;
TABLE_START DB '000000000000000000000000000000'
S1 DB '000000000000000000000000000000'
S2 DB 'HERE00000000000000000000000000'
S3 DB 'HERE IS A MATCH000000000000000'
TABLE_END DB 0
STRING_START DB 'HERE IS A MATCH'
STRING_END DB 0
CODE 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/