Replace invalid characters with HTML entities
— with — ’ with ’ + with + × with x ç with ç “ with “ ” with ” ‘ with ‘ • with • – with - µ with µ † with † Fix C++ θ with θ Yen symbol instead of times Fix broken apos Bullet again E-circumflex
This commit is contained in:
parent
9e52de9586
commit
500e7f5654
353 changed files with 5091 additions and 5091 deletions
32
07-03.html
32
07-03.html
|
|
@ -49,21 +49,21 @@
|
|||
.data
|
||||
; Sample string to search through.
|
||||
SampleString labelbyte
|
||||
db ‘This is a sample string of a long enough length ’
|
||||
db ‘so that raw searching speed can outweigh any ’
|
||||
db ‘extra set-up time that may be required.’,0
|
||||
db ‘This is a sample string of a long enough length ’
|
||||
db ‘so that raw searching speed can outweigh any ’
|
||||
db ‘extra set-up time that may be required.’,0
|
||||
SAMPLE_STRING_LENGTH equ $-SampleString
|
||||
|
||||
; User prompt.
|
||||
Prompt db ‘Enter character to search for:$’
|
||||
Prompt db ‘Enter character to search for:$’
|
||||
|
||||
; Result status messages.
|
||||
ByteFoundMsg db 0dh,0ah
|
||||
db ‘Specified byte found.’,0dh,0ah,‘$’
|
||||
db ‘Specified byte found.’,0dh,0ah,‘$’
|
||||
ZeroByteFoundMsg db 0dh, 0ah
|
||||
db ‘Zero byte encountered.’,0dh,0ah,‘$’
|
||||
db ‘Zero byte encountered.’,0dh,0ah,‘$’
|
||||
NoByteFoundMsg db 0dh,0ah
|
||||
db ‘Buffer exhausted with no match.’, 0dh, 0ah, ‘$’
|
||||
db ‘Buffer exhausted with no match.’, 0dh, 0ah, ‘$’
|
||||
|
||||
.code
|
||||
Startprocnear
|
||||
|
|
@ -80,12 +80,12 @@ Startprocnear
|
|||
call SearchMaxLength ;search the buffer
|
||||
mov dx,offset ByteFoundMsg ;assume we found the byte
|
||||
jc PrintStatus ;we did find the byte
|
||||
;we didn’t find the byte, figure out
|
||||
;we didn’t find the byte, figure out
|
||||
;whether we found a zero byte or
|
||||
;ran out of buffer
|
||||
mov dx,offset NoByteFoundMsg
|
||||
;assume we didn’t find a zero byte
|
||||
jcxz PrintStatus ;we didn’t find a zero byte
|
||||
;assume we didn’t find a zero byte
|
||||
jcxz PrintStatus ;we didn’t find a zero byte
|
||||
mov dx,offset ZeroByteFoundMsg ;we found a zero byte
|
||||
PrintStatus:
|
||||
mov ah,9 ;DOS print string function
|
||||
|
|
@ -114,25 +114,25 @@ SearchMaxLengthprocnear
|
|||
SearchMaxLengthLoop:
|
||||
lodsb ;get the next byte
|
||||
cmp al,ah ;is this the byte we want?
|
||||
jz ByteFound ;yes, we’re done with success
|
||||
jz ByteFound ;yes, we’re done with success
|
||||
and al,al ;is this the terminating 0 byte?
|
||||
jz ByteNotFound ;yes, we’re done with failure
|
||||
loop SearchMaxLengthLoop ;it’s neither, so check the next
|
||||
jz ByteNotFound ;yes, we’re done with failure
|
||||
loop SearchMaxLengthLoop ;it’s neither, so check the next
|
||||
;byte, if any
|
||||
ByteNotFound:
|
||||
clc ;return “not found” status
|
||||
clc ;return “not found” status
|
||||
ret
|
||||
ByteFound:
|
||||
dec si ;point back to the location at which
|
||||
;we found the searched-for byte
|
||||
stc ;return “found” status
|
||||
stc ;return “found” status
|
||||
ret
|
||||
SearchMaxLengthendp
|
||||
end Start
|
||||
</PRE>
|
||||
<!-- END CODE //-->
|
||||
<H3><A NAME="Heading7"></A><FONT COLOR="#000077">Unrolling Loops</FONT></H3>
|
||||
<P>Listing 7.2 takes a different tack, unrolling the loop so that four bytes are checked for each <B>LOOP</B> performed. The same instructions are used inside the loop in each listing, but Listing 7.2 is arranged so that three-quarters of the <B>LOOP</B>s are eliminated. Listings 7.1 and 7.2 perform exactly the same task, and they use the same instructions in the loop—the searching algorithm hasn’t changed in any way—but we have sequenced the instructions differently in Listing 7.2, and that makes all the difference.</P><P><BR></P>
|
||||
<P>Listing 7.2 takes a different tack, unrolling the loop so that four bytes are checked for each <B>LOOP</B> performed. The same instructions are used inside the loop in each listing, but Listing 7.2 is arranged so that three-quarters of the <B>LOOP</B>s are eliminated. Listings 7.1 and 7.2 perform exactly the same task, and they use the same instructions in the loop—the searching algorithm hasn’t changed in any way—but we have sequenced the instructions differently in Listing 7.2, and that makes all the difference.</P><P><BR></P>
|
||||
<CENTER>
|
||||
<TABLE BORDER>
|
||||
<TR>
|
||||
|
|
|
|||
Loading…
Reference in a new issue