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
44
07-04.html
44
07-04.html
|
|
@ -48,21 +48,21 @@
|
|||
.data
|
||||
; Sample string to search through.
|
||||
SampleStringlabelbyte
|
||||
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, ‘$’
|
||||
|
||||
; Table of initial, possibly partial loop entry points for
|
||||
; SearchMaxLength.
|
||||
|
|
@ -87,12 +87,12 @@ Start proc near
|
|||
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
|
||||
|
|
@ -134,42 +134,42 @@ SearchMaxLengthLoop:
|
|||
SearchMaxLengthEntry4:
|
||||
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
|
||||
jz ByteNotFound ;yes, we’re done with failure
|
||||
SearchMaxLengthEntry3:
|
||||
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
|
||||
jz ByteNotFound ;yes, we’re done with failure
|
||||
SearchMaxLengthEntry2:
|
||||
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
|
||||
jz ByteNotFound ;yes, we’re done with failure
|
||||
SearchMaxLengthEntry1:
|
||||
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
|
||||
; four bytes, 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 //-->
|
||||
<P>How much difference? Listing 7.2 runs in 121 µs—40 percent faster than Listing 7.1, even though Listing 7.2 still uses <B>LOOP</B> rather than <B>DEC CX/JNZ.</B> (The loop in Listing 7.2 could be unrolled further, too; it’s just a question of how much more memory you want to trade for ever-decreasing performance benefits.) That’s typical of local optimization; it won’t often yield the order-of-magnitude improvements that algorithmic improvements can produce, but it can get you a critical 50 percent or 100 percent improvement when you’ve exhausted all other avenues.</P>
|
||||
<P>How much difference? Listing 7.2 runs in 121 µs—40 percent faster than Listing 7.1, even though Listing 7.2 still uses <B>LOOP</B> rather than <B>DEC CX/JNZ.</B> (The loop in Listing 7.2 could be unrolled further, too; it’s just a question of how much more memory you want to trade for ever-decreasing performance benefits.) That’s typical of local optimization; it won’t often yield the order-of-magnitude improvements that algorithmic improvements can produce, but it can get you a critical 50 percent or 100 percent improvement when you’ve exhausted all other avenues.</P>
|
||||
<TABLE WIDTH="100%"><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="5%"><IMG SRC="images/i.jpg"><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="95%"><SMALL><I>The point is simply this: You can gain far more by stepping back a bit and thinking of the fastest overall way for the CPU to perform a task than you can by saving a cycle here or there using different instructions. Try to think at the level of sequences of instructions rather than individual instructions, and learn to treat x86 instructions as building blocks with unique characteristics rather than as instructions dedicated to specific tasks.</I></SMALL>
|
||||
</TABLE>
|
||||
<P><BR></P>
|
||||
|
|
|
|||
Loading…
Reference in a new issue