-
Notifications
You must be signed in to change notification settings - Fork 10
/
chapter-instr-glance.tex
73 lines (55 loc) · 6.52 KB
/
chapter-instr-glance.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
\chapter{Instructions at a Glance}
% ███████████████████████████████████████████████████████████████████████████████████████████████████
% █░░░░░░░░░░░░░░█░░░░░░█████████░░░░░░░░░░░░░░█░░░░░░██████████░░░░░░█░░░░░░░░░░░░░░█░░░░░░░░░░░░░░█
% █░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀░░█████████░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀░░░░░░░░░░██░░▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█
% █░░▄▀░░░░░░░░░░█░░▄▀░░█████████░░▄▀░░░░░░▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░██░░▄▀░░█░░▄▀░░░░░░░░░░█░░▄▀░░░░░░░░░░█
% █░░▄▀░░█████████░░▄▀░░█████████░░▄▀░░██░░▄▀░░█░░▄▀░░░░░░▄▀░░██░░▄▀░░█░░▄▀░░█████████░░▄▀░░█████████
% █░░▄▀░░█████████░░▄▀░░█████████░░▄▀░░░░░░▄▀░░█░░▄▀░░██░░▄▀░░██░░▄▀░░█░░▄▀░░█████████░░▄▀░░░░░░░░░░█
% █░░▄▀░░██░░░░░░█░░▄▀░░█████████░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀░░██░░▄▀░░██░░▄▀░░█░░▄▀░░█████████░░▄▀▄▀▄▀▄▀▄▀░░█
% █░░▄▀░░██░░▄▀░░█░░▄▀░░█████████░░▄▀░░░░░░▄▀░░█░░▄▀░░██░░▄▀░░██░░▄▀░░█░░▄▀░░█████████░░▄▀░░░░░░░░░░█
% █░░▄▀░░██░░▄▀░░█░░▄▀░░█████████░░▄▀░░██░░▄▀░░█░░▄▀░░██░░▄▀░░░░░░▄▀░░█░░▄▀░░█████████░░▄▀░░█████████
% █░░▄▀░░░░░░▄▀░░█░░▄▀░░░░░░░░░░█░░▄▀░░██░░▄▀░░█░░▄▀░░██░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀░░░░░░░░░░█░░▄▀░░░░░░░░░░█
% █░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀░░██░░▄▀░░█░░▄▀░░██░░░░░░░░░░▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█
% █░░░░░░░░░░░░░░█░░░░░░░░░░░░░░█░░░░░░██░░░░░░█░░░░░░██████████░░░░░░█░░░░░░░░░░░░░░█░░░░░░░░░░░░░░█
% ███████████████████████████████████████████████████████████████████████████████████████████████████
\ChapterTOC[]
\pagebreak
\thispagestyle{plain} % use toc style without headers for this explanation page, it better matches chapter start page
This chapter presents all instructions at a glance for quick info and to easily compare them when choosing the most optimal combination for the task at hand. Instructions are grouped into logical sections based on the area they operate on.
\ifdefined\isPDF \else The chapter ends with alphabetical list of all instructions to make them easier to find when searching by mnemonic. \fi
\subsubsection{Instruction Execution}
\begin{tabular}{ll}
B & Number of bytes instruction uses in RAM\\
Mc\notet & Number of machine cycles instruction takes to complete\\
Ts\notet & Number of clock periods instruction requires to complete\\
\end{tabular}
\subsubsection{Flags \textnormal{(copied from section \XRef{z80_flags} as convenience)}}
\begin{tabularx}{\linewidth}{lX}
SF &
\textbf{Sign} Set if 2-complement value is negative.\\
ZF\notet &
\textbf{Zero} Set if the result is zero. \\
HY\notet &
\textbf{Half-Carry} The half-carry of an addition/subtraction (from bit 3 to 4)\See{*}. \\
PV\notet &
\textbf{Parity/Overflow} This flag can either be the parity of the result ({\tt \FPP}), or 2-complement signed overflow ({\tt \FPV}). \\
NF\notet &
\textbf{Add/Subtract} Indicates the last operation was an addition ({\tt 0}) or a subtraction ({\tt 1})\See{*}. \\
CF\notet &
\textbf{Carry} Set if there was a carry from the most significant bit. \\
\end{tabularx}
\See{*} \small{Primarily used for BCD operations.}
\subsubsection{Effects}
\begin{tabular}{cl}
{\tt 0}/{\tt 1} & Flag is set to {\tt 0} or {\tt 1} \\
{\tt \FS} & Flag is modified according to operation \\
{\tt \FN} & Flag is not affected \\
{\tt \FU} & Effect on flag is unpredictable \\
{\tt VF} & P/V flag is used as overflow \\
{\tt PF} & P/V flag is used as parity \\
{\tt \FX} & Special case, see description under the table or in chapter \XRef{instruction_details}
\end{tabular}
\subsubsection{Notes}
{\tt YF} and {\tt XF} flags are not represented; they're irrelevant from the programmer point of view.
I used 4 sources for comparing effects: Z80 undocumented\footnote{\url{http://www.myquest.nl/z80undocumented/}}, Programming the Z80 third edition\footnote{\url{http://www.z80.info/zaks.html}}, Zilog Z80 manual\footnote{\url{https://www.zilog.com/docs/z80/um0080.pdf}} and Next Dev Wiki\footnote{\url{https://wiki.specnext.dev/Extended_Z80_instruction_set}}. Where different and I couldn't verify, I opted for variant that matches most sources with slightly greater precedence for Next Dev Wiki side.
\pagebreak