| 1 |
\chapter{F8 Processor} |
| 2 |
\label{processor:f8} |
| 3 |
\index{Processor!F8} |
| 4 |
\index{Machine!Channel F} |
| 5 |
|
| 6 |
The F8 processor is used by the \nameref{machine:channelF} machine. |
| 7 |
|
| 8 |
\section{Endianness} |
| 9 |
|
| 10 |
The \mono{F8} is a big-endian machine. Byte ordering in words is high, then low. |
| 11 |
|
| 12 |
\subsection{Processor selection} |
| 13 |
|
| 14 |
With DASM, the target CPU is selected with the PROCESSOR |
| 15 |
directive inside the source file that should be assembled. |
| 16 |
The F8 CPU is selected like this: |
| 17 |
|
| 18 |
\begin{usage} |
| 19 |
processor f8 |
| 20 |
processor F8 ; case insensitive |
| 21 |
\end{usage} |
| 22 |
|
| 23 |
\subsection{Expressions with parentheses} |
| 24 |
|
| 25 |
|
| 26 |
Some of DASM's backends, for instance the one for the 6502, |
| 27 |
don't allow parentheses in expressions that are part of a |
| 28 |
mnemonic's operand, because parentheses are used in the |
| 29 |
6502's assembly language to denote indirect addressing. |
| 30 |
Instead, you have to use brackets. |
| 31 |
|
| 32 |
This is not the case with the F8 backend. Both parentheses |
| 33 |
and brackets can be used everywhere, so the following lines |
| 34 |
are parsed and assembled correctly: |
| 35 |
|
| 36 |
\begin{code} |
| 37 |
as (2+2)*2 ; Assembles to $c8 |
| 38 |
as [2+2]*2 ; Assembles to $c8 |
| 39 |
\end{code} |
| 40 |
|
| 41 |
\subsection{Data definition directives} |
| 42 |
|
| 43 |
|
| 44 |
Since \mono{DS} is an F8 instruction (decrement scratchpad register), |
| 45 |
the \mono{DS} directive isn't available anymore if \dasm assembles |
| 46 |
F8 code. Instead, use the \mono{RES} directive, which works just like |
| 47 |
the \mono{DS} directive: |
| 48 |
|
| 49 |
\begin{code} |
| 50 |
ds.b 4,$33 ; Would assemble to $33 $33 $33 $33, |
| 51 |
; but isn't available in F8 mode |
| 52 |
res.b 4,$33 ; Assembles to $33 $33 $33 $33 |
| 53 |
\end{code} |
| 54 |
|
| 55 |
Of course \mono{RES.W} and \mono{RES.L} do exist as well. |
| 56 |
|
| 57 |
|
| 58 |
For source code compatibility with \mono{f8tool} (another F8 assembler), some |
| 59 |
additional data definition directives are available : \mono{DB}, \mono{DW} and \mono{DD}. |
| 60 |
These work just like \mono{DC.B}, \mono{DC.W} and \mono{DC.L}: |
| 61 |
|
| 62 |
\begin{code} |
| 63 |
dc.b $f8 ; Assembles to $f8 |
| 64 |
db $f8 ; Assembles to $f8 |
| 65 |
\end{code} |
| 66 |
|
| 67 |
\subsection{Special register names} |
| 68 |
|
| 69 |
For some of the special registers, multiple names are accepted: |
| 70 |
|
| 71 |
\begin{table}[H] |
| 72 |
\begin{tabularx}{\linewidth}{cl} |
| 73 |
\toprule |
| 74 |
\textbf{Register}&\textbf{Accepted Names}\\ |
| 75 |
\hline |
| 76 |
|
| 77 |
\mono{DC0}&\mono{DC}, \mono{DC0}\\ |
| 78 |
\mono{PC0}&\mono{P0}, \mono{PC0}\\ |
| 79 |
\mono{PC1}&\mono{P}, \mono{PC1}\\ |
| 80 |
\mono{J}&\mono{J}, Any expression that evaluates to \mono{9}\\ |
| 81 |
&(This may seem strange, but \mono{J} is really\\ |
| 82 |
&just an alias for scratchpad register \mono{9})\\ |
| 83 |
\hline |
| 84 |
\end{tabularx} |
| 85 |
\end{table} |
| 86 |
|
| 87 |
The names \mono{DC}, \mono{P0}, \mono{P} and \mono{J} are standard syntax, the other forms |
| 88 |
have been introduced for compatibility with other assemblers. |
| 89 |
|
| 90 |
Thus, the following lines assemble all correctly: |
| 91 |
|
| 92 |
\begin{code} |
| 93 |
lr h,dc ; Assembles to $11 |
| 94 |
lr h,dc0 ; Assembles to $11 |
| 95 |
lr p0,q ; Assembles to $0d |
| 96 |
lr pc0,q ; Assembles to $0d |
| 97 |
lr p,q ; Assembles to $09 |
| 98 |
lr pc1,q ; Assembles to $09 |
| 99 |
lr w,j ; Assembles to $1d |
| 100 |
lr w,3*3 ; Assembles to $1d |
| 101 |
\end{code} |
| 102 |
|
| 103 |
\subsection{Scratchpad register access} |
| 104 |
|
| 105 |
There are several ways to access scratchpad registers: |
| 106 |
|
| 107 |
\begin{table}[H] |
| 108 |
\begin{tabularx}{\linewidth}{ll} |
| 109 |
\toprule |
| 110 |
\textbf{Access Mode}&\textbf{Accepted Syntax}\\ |
| 111 |
\hline |
| 112 |
\\ |
| 113 |
Direct access to registers \mono{0..11}&Any expression that evaluates to \mono{0..11}\\ |
| 114 |
Access via \mono{ISAR}&\mono{S}, \mono{(IS)}, any expression that evaluates to \mono{12}\\ |
| 115 |
Access via \mono{ISAR}, \mono{ISAR} incremented&\mono{I}, \mono{(IS)+}, any expression that evaluates to \mono{13}\\ |
| 116 |
Access via \mono{ISAR}, \mono{ISAR} decremented&\mono{D}, \mono{(IS)-}, any expression that evaluates to \mono{14}\\ |
| 117 |
\hline |
| 118 |
\end{tabularx} |
| 119 |
\end{table} |
| 120 |
|
| 121 |
The \mono{(IS)}, \mono{(IS)+} and \mono{(IS)-} forms are not standard syntax and have |
| 122 |
been mainly introduced for compatibility with \mono{f8tool}. |
| 123 |
|
| 124 |
|
| 125 |
For some of the directly accessible scratchpad registers aliases exist: |
| 126 |
|
| 127 |
\begin{table}[H] |
| 128 |
\begin{tabularx}{\linewidth}{cc} |
| 129 |
\toprule |
| 130 |
\textbf{Register}&\textbf{Alias Name}\\ |
| 131 |
\hline |
| 132 |
\mono{9}&\mono{J}\\ |
| 133 |
\mono{10}&\mono{HU}\\ |
| 134 |
\mono{11}&\mono{HL}\\ |
| 135 |
\hline |
| 136 |
\end{tabularx} |
| 137 |
\end{table} |
| 138 |
|
| 139 |
Originally, \mono{J} was only used with the \mono{LR} instruction when accessing the |
| 140 |
flags, but since \mono{J} is just an alias for register \mono{9}, \mono{J} can also be used |
| 141 |
in normal scratchpad register operations. |
| 142 |
|
| 143 |
The following lines assemble all correctly |
| 144 |
|
| 145 |
\begin{code} |
| 146 |
xs 2+2 ; Assembles to $e4 |
| 147 |
xs s ; Assembles to $ec |
| 148 |
xs (is) ; Assembles to $ec |
| 149 |
xs 12 ; Assembles to $ec |
| 150 |
xs i ; Assembles to $ed |
| 151 |
xs (is)+ ; Assembles to $ed |
| 152 |
xs 13 ; Assembles to $ed |
| 153 |
xs d ; Assembles to $ee |
| 154 |
xs (is)- ; Assembles to $ee |
| 155 |
xs 14 ; Assembles to $ee |
| 156 |
xs 9 ; Assembles to $e9 |
| 157 |
xs j ; Assembles to $e9 |
| 158 |
xs hu ; Assembles to $ea |
| 159 |
xs hl ; Assembles to $eb |
| 160 |
\end{code} |
| 161 |
|
| 162 |
|
| 163 |
\subsection{No instruction optimizations are done} |
| 164 |
|
| 165 |
|
| 166 |
The assembler doesn't optimize instructions where a smaller |
| 167 |
instruction could be used. It won't optimize between |
| 168 |
\mono{OUT/OUTS}, \mono{IN/INS} and \mono{LI/LIS}. |
| 169 |
|
| 170 |
For instance, the following line assembles to \mono{\$20 \$00}, even |
| 171 |
though the \mono{LIS} instruction could be used, which would need |
| 172 |
only one byte. |
| 173 |
|
| 174 |
\begin{code} |
| 175 |
li 0 ; Assembles to $20 $00 |
| 176 |
\end{code} |