Chapter 3 typos (and 1 Chapter 2 one)
This commit is contained in:
parent
e54d0fa5d2
commit
753657938b
2 changed files with 81 additions and 81 deletions
|
|
@ -200,7 +200,7 @@ enough.
|
||||||
The single most critical aspect of the hardware, and the one about which
|
The single most critical aspect of the hardware, and the one about which
|
||||||
it is hardest to learn, is the CPU. The x86 family CPUs have a complex,
|
it is hardest to learn, is the CPU. The x86 family CPUs have a complex,
|
||||||
irregular instruction set, and, unlike most processors, they are neither
|
irregular instruction set, and, unlike most processors, they are neither
|
||||||
straightforward nor wellregarding true code performance. What's more,
|
straightforward nor well-documented true code performance. What's more,
|
||||||
assembly is so difficult to learn that most articles and books that
|
assembly is so difficult to learn that most articles and books that
|
||||||
present assembly code settle for code that just works, rather than code
|
present assembly code settle for code that just works, rather than code
|
||||||
that pushes the CPU to its limits. In fact, since most articles and
|
that pushes the CPU to its limits. In fact, since most articles and
|
||||||
|
|
|
||||||
|
|
@ -671,7 +671,7 @@ count reaches zero, the timer turns over and starts counting down again
|
||||||
without stopping, and a pulse is generated for a single clock period.
|
without stopping, and a pulse is generated for a single clock period.
|
||||||
While the pulse is not held for nearly as long as in square wave mode,
|
While the pulse is not held for nearly as long as in square wave mode,
|
||||||
it doesn't matter, since the 8259 interrupt controller is configured in
|
it doesn't matter, since the 8259 interrupt controller is configured in
|
||||||
the PC to be edgeand hence cares only about the existence of a pulse
|
the PC to be edge-triggered and hence cares only about the existence of a pulse
|
||||||
from timer 0, not the duration of the pulse. As a result, timer 0
|
from timer 0, not the duration of the pulse. As a result, timer 0
|
||||||
continues to generate timer interrupts in divide-by-N mode, and the
|
continues to generate timer interrupts in divide-by-N mode, and the
|
||||||
system clock continues to maintain good time.
|
system clock continues to maintain good time.
|
||||||
|
|
@ -688,7 +688,7 @@ the Zen timer shown in Listing 3.1 supports.
|
||||||
In fact, the Zen timer shown in Listing 3.1 can only time intervals of
|
In fact, the Zen timer shown in Listing 3.1 can only time intervals of
|
||||||
up to about 54 ms in length, since that is the period of time that can
|
up to about 54 ms in length, since that is the period of time that can
|
||||||
be measured by timer 0 before its count turns over and repeats.
|
be measured by timer 0 before its count turns over and repeats.
|
||||||
fifty-four ms may not seem like a very long time, but even a CPU as slow
|
Fifty-four ms may not seem like a very long time, but even a CPU as slow
|
||||||
as the 8088 can perform more than 1,000 divides in 54 ms, and division
|
as the 8088 can perform more than 1,000 divides in 54 ms, and division
|
||||||
is the single instruction that the 8088 performs most slowly. If a
|
is the single instruction that the 8088 performs most slowly. If a
|
||||||
measured period turns out to be longer than 54 ms (that is, if timer 0
|
measured period turns out to be longer than 54 ms (that is, if timer 0
|
||||||
|
|
@ -730,10 +730,10 @@ restart until the timing interval ends, losing time all the while.
|
||||||
|
|
||||||
The effects on the system time of the Zen timer aren't a matter for
|
The effects on the system time of the Zen timer aren't a matter for
|
||||||
great concern, as they are temporary, lasting only until the next warm
|
great concern, as they are temporary, lasting only until the next warm
|
||||||
or cold boot. System that have batteryclocks, (AT-style machines; that
|
or cold boot. System that have battery-backed clocks, (AT-style machines; that
|
||||||
is, virtually all machines in common use) automatically reset the
|
is, virtually all machines in common use) automatically reset the
|
||||||
correct time whenever the computer is booted, and systems without
|
correct time whenever the computer is booted, and systems without
|
||||||
battery-clocks prompt for the correct date and time when booted.
|
battery-backed clocks prompt for the correct date and time when booted.
|
||||||
Also, repeated use of the Zen timer usually makes the system clock slow
|
Also, repeated use of the Zen timer usually makes the system clock slow
|
||||||
by at most a total of a few seconds, unless code that takes much longer
|
by at most a total of a few seconds, unless code that takes much longer
|
||||||
than 54 ms to run is timed (in which case the Zen timer will notify you
|
than 54 ms to run is timed (in which case the Zen timer will notify you
|
||||||
|
|
@ -789,8 +789,8 @@ from timer counts to microseconds, and prints the resulting time in
|
||||||
microseconds to the standard output.
|
microseconds to the standard output.
|
||||||
|
|
||||||
Note that `ZTimerReport` need not be called immediately after
|
Note that `ZTimerReport` need not be called immediately after
|
||||||
`ZTimerOff`. In fact, after a given call to `ZTimerOff,
|
`ZTimerOff`. In fact, after a given call to `ZTimerOff`,
|
||||||
ZTimerReport` can be called at any time right up until the next call to
|
`ZTimerReport` can be called at any time right up until the next call to
|
||||||
`ZTimerOn`.
|
`ZTimerOn`.
|
||||||
|
|
||||||
You may want to use the Zen timer to measure several portions of a
|
You may want to use the Zen timer to measure several portions of a
|
||||||
|
|
@ -880,7 +880,7 @@ performance will be similar even on different IBM models; in fact, quite
|
||||||
the opposite is true. For example, every PS/2 computer, even the
|
the opposite is true. For example, every PS/2 computer, even the
|
||||||
relatively slow Model 30, executes code much faster than does a PC or
|
relatively slow Model 30, executes code much faster than does a PC or
|
||||||
XT. As another example, I set out to do the timings for my earlier book
|
XT. As another example, I set out to do the timings for my earlier book
|
||||||
*Zen of Assembly Language* on an XTcomputer, only to find that the
|
*Zen of Assembly Language* on an XT-compatible computer, only to find that the
|
||||||
computer wasn't quite IBM-compatible regarding code performance. The
|
computer wasn't quite IBM-compatible regarding code performance. The
|
||||||
differences were minor, mind you, but my experience illustrates the risk
|
differences were minor, mind you, but my experience illustrates the risk
|
||||||
of assuming that a specific make of computer will perform in a certain
|
of assuming that a specific make of computer will perform in a certain
|
||||||
|
|
@ -1111,8 +1111,8 @@ pztime <filename>
|
||||||
In fact, that's exactly how I timed each of the listings in this book.
|
In fact, that's exactly how I timed each of the listings in this book.
|
||||||
Code fragments you write yourself can be timed in just the same way. If
|
Code fragments you write yourself can be timed in just the same way. If
|
||||||
you wish to time code directly in place in your programs, rather than in
|
you wish to time code directly in place in your programs, rather than in
|
||||||
the test-bed program of Listing 3.2, simply insert calls to `ZTimerOn,
|
the test-bed program of Listing 3.2, simply insert calls to `ZTimerOn`,
|
||||||
ZTimerOff`, and `ZTimerReport` in the appropriate places and link
|
`ZTimerOff`, and `ZTimerReport` in the appropriate places and link
|
||||||
PZTIMER to your program.
|
PZTIMER to your program.
|
||||||
|
|
||||||
### The Long-Period Zen Timer
|
### The Long-Period Zen Timer
|
||||||
|
|
@ -1303,7 +1303,7 @@ computers.
|
||||||
; All registers and all flags are preserved by all routines.
|
; All registers and all flags are preserved by all routines.
|
||||||
;
|
;
|
||||||
|
|
||||||
Code segment word public ‘CODE'
|
Code segment word public 'CODE'
|
||||||
assume cs:Code, ds:nothing
|
assume cs:Code, ds:nothing
|
||||||
public ZTimerOn, ZTimerOff, ZTimerReport
|
public ZTimerOn, ZTimerOff, ZTimerReport
|
||||||
|
|
||||||
|
|
@ -1384,10 +1384,10 @@ ReferenceCount dw ? ;number of counts required to
|
||||||
; String printed to report results.
|
; String printed to report results.
|
||||||
;
|
;
|
||||||
OutputStr label byte
|
OutputStr label byte
|
||||||
db 0dh, 0ah, ‘Timed count: ‘
|
db 0dh, 0ah, 'Timed count: '
|
||||||
TimedCountStr db 10 dup (?)
|
TimedCountStr db 10 dup (?)
|
||||||
db ' microseconds', 0dh, 0ah
|
db ' microseconds', 0dh, 0ah
|
||||||
db ‘$'
|
db '$'
|
||||||
;
|
;
|
||||||
; Temporary storage for timed count as it's divided down by powers
|
; Temporary storage for timed count as it's divided down by powers
|
||||||
; of ten when converting from doubleword binary to ASCII.
|
; of ten when converting from doubleword binary to ASCII.
|
||||||
|
|
@ -1417,7 +1417,7 @@ PowersOfTenEnd labelword
|
||||||
;
|
;
|
||||||
TurnOverStr label byte
|
TurnOverStr label byte
|
||||||
db 0dh, 0ah
|
db 0dh, 0ah
|
||||||
db ‘****************************************************'
|
db '****************************************************'
|
||||||
db 0dh, 0ah
|
db 0dh, 0ah
|
||||||
db '* Either midnight passed or an hour or more passed *'
|
db '* Either midnight passed or an hour or more passed *'
|
||||||
db 0dh, 0ah
|
db 0dh, 0ah
|
||||||
|
|
@ -1429,11 +1429,11 @@ TurnOverStrlabelbyte
|
||||||
db 0dh, 0ah
|
db 0dh, 0ah
|
||||||
db '* run to be timed by the long-period Zen timer. *'
|
db '* run to be timed by the long-period Zen timer. *'
|
||||||
db 0dh, 0ah
|
db 0dh, 0ah
|
||||||
db ‘* Suggestions: use the DOS TIME command, the DOS *'
|
db '* Suggestions: use the DOS TIME command, the DOS *'
|
||||||
db 0dh, 0ah
|
db 0dh, 0ah
|
||||||
db ‘* time function, or a watch. *'
|
db '* time function, or a watch. *'
|
||||||
db 0dh, 0ah
|
db 0dh, 0ah
|
||||||
db ‘****************************************************'
|
db '****************************************************'
|
||||||
db 0dh, 0ah
|
db 0dh, 0ah
|
||||||
db '$'
|
db '$'
|
||||||
|
|
||||||
|
|
@ -1896,7 +1896,7 @@ substantially.
|
||||||
|
|
||||||
Finally, please note that the *precision* Zen timer works perfectly well
|
Finally, please note that the *precision* Zen timer works perfectly well
|
||||||
on both PS/2 and non-PS/2 computers. The PS/2 and 8253 considerations
|
on both PS/2 and non-PS/2 computers. The PS/2 and 8253 considerations
|
||||||
we've just discussed apply *only* to the longZen timer.
|
we've just discussed apply *only* to the long-period Zen timer.
|
||||||
|
|
||||||
### Example Use of the Long-Period Zen Timer
|
### Example Use of the Long-Period Zen Timer
|
||||||
|
|
||||||
|
|
@ -2126,7 +2126,7 @@ be dealt with here: small code model and large; I'll tackle the simpler
|
||||||
one, the small code model, first.
|
one, the small code model, first.
|
||||||
|
|
||||||
Altering the Zen timer for linking to a small code model C program
|
Altering the Zen timer for linking to a small code model C program
|
||||||
involves the following steps: `C` hange `ZTimerOn` to
|
involves the following steps: Change `ZTimerOn` to
|
||||||
`_ZTimerOn`, change `ZTimerOff` to `_ZTimerOff`, change
|
`_ZTimerOn`, change `ZTimerOff` to `_ZTimerOff`, change
|
||||||
`ZTimerReport` to `_ZTimerReport`, and change `Code` to
|
`ZTimerReport` to `_ZTimerReport`, and change `Code` to
|
||||||
`_TEXT` . Figure 3.2 shows the line numbers and new states of all
|
`_TEXT` . Figure 3.2 shows the line numbers and new states of all
|
||||||
|
|
@ -2190,13 +2190,13 @@ call near ptr ReferenceZTimerOn
|
||||||
(and likewise for `ReferenceZTimerOff`), which works because
|
(and likewise for `ReferenceZTimerOff`), which works because
|
||||||
`ReferenceZTimerOn` is in the same segment as the calling code. This
|
`ReferenceZTimerOn` is in the same segment as the calling code. This
|
||||||
is normally a great optimization, being both smaller and faster than a
|
is normally a great optimization, being both smaller and faster than a
|
||||||
far call. However, it's not so great for the Zen
|
far call.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
timer, because our purpose in calling the reference timing code is to
|
However, it's not so great for the Zen timer, because our purpose in calling the reference timing code is to
|
||||||
determine exactly how much time is taken by overhead code—including the
|
determine exactly how much time is taken by overhead code—including the
|
||||||
far calls to `ZTimerOn` and `ZTimerOf`f! By converting the far calls
|
far calls to `ZTimerOn` and `ZTimerOf`! By converting the far calls
|
||||||
to push/near call pairs within the Zen timer module, TASM makes it
|
to push/near call pairs within the Zen timer module, TASM makes it
|
||||||
impossible to emulate exactly the overhead of the Zen timer, and makes
|
impossible to emulate exactly the overhead of the Zen timer, and makes
|
||||||
timings slightly (about 16 cycles on a 386) less accurate.
|
timings slightly (about 16 cycles on a 386) less accurate.
|
||||||
|
|
@ -2255,7 +2255,7 @@ processor cache at the start of the code being timed, because the timing
|
||||||
code is not necessarily fetched and does not necessarily access memory
|
code is not necessarily fetched and does not necessarily access memory
|
||||||
in exactly the same time sequence as the code immediately preceding the
|
in exactly the same time sequence as the code immediately preceding the
|
||||||
code under measurement normally does. This prefetch effect can introduce
|
code under measurement normally does. This prefetch effect can introduce
|
||||||
as much as 3 to 4 µ of inaccuracy. Similarly, the state of the prefetch
|
as much as 3 to 4 µs of inaccuracy. Similarly, the state of the prefetch
|
||||||
queue at the end of the code being timed affects how long the code that
|
queue at the end of the code being timed affects how long the code that
|
||||||
stops the timer takes to execute. Consequently, the Zen timer tends to
|
stops the timer takes to execute. Consequently, the Zen timer tends to
|
||||||
be more accurate for longer code sequences, since the relative magnitude
|
be more accurate for longer code sequences, since the relative magnitude
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue