SHELL := bash
-FILES = isa.tex conds.tex
+FILES = isa.tex conds.tex flags.tex callingconv.tex
FILES += Makefile
TARGET = isa.pdf
ins ('32', 'add', 'Add',
-'4 | 5 | 4 | 4 | 4 | 10 | 1',
-'Conditions | OpCode | Register Destination|Register A (Source1)| Register B (Source2) | - | C',
+'4 | 5 | 4 | 4 | 4 | 9 | 1 | 1',
+'Conditions | OpCode | Register Destination|Register A (Source1)| Register B (Source2) | - | C | SU',
'Adds Register A and Register B and save result in Register Destination \\\\
-When bit C is set, the content of the carry flag is also added.',
+When bit C is set, the content of the carry flag is also added. When the SU bit is set, the PSW gets updated (default is set)',
'is set to the MSB of the result | is set if addition has a carry out | is set if a overflow occured | is set if the result is zero ',
'add r0, r2, r4 ; add low bytes
addc r1, r3, r5 ; add high bytes');
-ins ('32', 'addi', 'Add im', '4 | 5 | 4 | 4 | 12 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Immediate | H/L | S | C');
+ins ('32', 'addi', 'Add im', '4 | 5 | 4 | 4 | 12 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Immediate | H/L | S | C',
+'H/L oder C kommen raus, daf\\"ur SU rein');
-ins ('32', 'addx', 'Add im 16bit', '4 | 5 | 4 | 16 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination| Immediate | H/L | S | C');
+# ins ('32', 'addx', 'Add im 16bit', '4 | 5 | 4 | 16 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination| Immediate | H/L | S | C');
-ins ('32', 'sub', 'Sub', '4 | 5 | 4 | 4 | 4 | 10 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Register B (Source2) | - | C');
+ins ('32', 'sub', 'Sub', '4 | 5 | 4 | 4 | 4 | 9 | 1 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Register B (Source2) | - | C | SU');
ins ('32', 'subi', 'Sub im', '4 | 5 | 4 | 4 | 12 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Immediate | H/L | S | C');
-ins ('32', 'subx', 'Sub im 16bit', '4 | 5 | 4 | 16 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination| Immediate | H/L | S | C');
+# ins ('32', 'subx', 'Sub im 16bit', '4 | 5 | 4 | 16 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination| Immediate | H/L | S | C');
--- /dev/null
+\section{calling convention}
+
+\begin{table}
+ \centering
+ \begin{tabular}{|c|c|c|} \hline
+ Register & saved by & usage \\ \hline
+ r0 & caller & return \\ \hline
+ r1 & caller & first parameter \\ \hline
+ r2 & caller & second parameter \\ \hline
+ r3 & caller & third parameter \\ \hline
+ r4 & caller & fourth parameter \\ \hline
+ r5 & caller & fifth parameter \\ \hline
+ r6 & caller & \\ \hline
+ r7 & caller & \\ \hline
+ r8 & caller & \\ \hline
+ r9 & caller & \\ \hline
+ r10 & callee & \\ \hline
+ r11 & callee & \\ \hline
+ r12 & callee & \\ \hline
+ r13 & callee & \\ \hline
+ r14 & callee & \\ \hline
+ r15 & callee & \\ \hline
+ \end{tabular}
+ \caption{Register save \ldots}
+% \label{tab:<+label+>}
+\end{table}
\usepackage{listings}
\usepackage{ngerman}
+\usepackage{longtable}
+
%used for coloring of instr.
\usepackage{colortbl}
-ins ('32', 'movpf', 'Move from PSW', '4 | 5 | 4 | 19', 'Conditions | OpCode | Register Destination| - ');
+ins ('32', 'movpf', 'Move from PSW/Stack', '4 | 5 | 4 | 1 | 18', 'Conditions | OpCode | Register Destination| stack | - ');
-ins ('32', 'movpt', 'Move to PSW', '4 | 5 | 4 | 19', 'Conditions | OpCode | Register Source| - ');
+ins ('32', 'movpt', 'Move to PSW', '4 | 5 | 4 | 1 | 18', 'Conditions | OpCode | Register Source | stack | - ');
ins ('32', 'ldw', 'Load word; needs to be aligned to 32bit', '4 | 5 | 4 | 4 | 15', 'Conditions | OpCode | Register Destination|Register Address| displacment? ');
ins ('32', 'ldh', 'Load half word; needs to be aligned to 16bit', '4 | 5 | 4 | 4 | 15', 'Conditions | OpCode | Register Destination|Register Address| displacment? ');
ins ('32', 'ldi', 'Load immediate', '4 | 5 | 4 | 16 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination| Immediate | - | h/l | S ');
-ins ('32', 'stw', 'store word; needs to be aligned to 32bit', '4 | 5 | 4 | 4 | 15', 'Conditions | OpCode | Register Destination|Register Address| - ');
-ins ('32', 'sth', 'store half word; needs to be aligned to 16bit', '4 | 5 | 4 | 4 | 15', 'Conditions | OpCode | Register Destination|Register Address| - ');
-ins ('32', 'stb', 'store byte, 8bit', '4 | 5 | 4 | 4 | 15', 'Conditions | OpCode | Register Destination|Register Address| - ');
+ins ('32', 'stw', 'store word; needs to be aligned to 32bit', '4 | 5 | 4 | 4 | 15', 'Conditions | OpCode | Register Destination|Register Address| displacment ');
+ins ('32', 'sth', 'store half word; needs to be aligned to 16bit', '4 | 5 | 4 | 4 | 15', 'Conditions | OpCode | Register Destination|Register Address| displacment ');
+ins ('32', 'stb', 'store byte, 8bit', '4 | 5 | 4 | 4 | 15', 'Conditions | OpCode | Register Destination|Register Address| displacment ');
ins ('32', 'ldx', 'Load from programspace', '4 | 5 | 4 | 4 | 15', 'Conditions | OpCode | Register Destination|Register Address| displacment ');
ins ('32', 'stx', 'Store to programspace', '4 | 5 | 4 | 4 | 15', 'Conditions | OpCode | Register Destination|Register Address| displacement ');
-ins ('32', 'pop', 'pop from stack', '4 | 5 | 4 | 19', 'Conditions | OpCode | Register Destination | - ');
+ins ('32', 'stackop', 'pop/push/disc/fetch from/to stack', '4 | 5 | 4 | 2 | 17', 'Conditions | OpCode | Register Destination (not for disc) | Type | - ');
-ins ('32', 'push', 'push to stack', '4 | 5 | 4 | 19', 'Conditions | OpCode | Register Source | - ');
+#ins ('32', 'pop', 'pop from stack', '4 | 5 | 4 | 19', 'Conditions | OpCode | Register Destination | - ');
-ins ('32', 'disc', 'discard top-element from stack', '4 | 5 | 23', 'Conditions | OpCode | - ');
+#ins ('32', 'push', 'push to stack', '4 | 5 | 4 | 19', 'Conditions | OpCode | Register Source | - ');
-ins ('32', 'fetch', 'get top-element from stack', '4 | 5 | 4 | 19', 'Conditions | OpCode | Register Destination | - ');
+#ins ('32', 'disc', 'discard top-element from stack', '4 | 5 | 23', 'Conditions | OpCode | - ');
+
+#ins ('32', 'fetch', 'get top-element from stack', '4 | 5 | 4 | 19', 'Conditions | OpCode | Register Destination | - ');
see note in conditions. there is a difference between x86/amd64/avr and arm.
we will very likely go with arm (or?)
+
+\subsection{big/little endian}
--- /dev/null
+\begin{table}
+ \centering
+ \begin{longtable}{|c|c|c|} \hline
+ flag & function & default value \\ \hline
+ C & carry & 0 (not set) \\ \hline
+ SU & Status register update & 1 (set) \\ \hline
+ H/L & use high or low 16-bits & L (not set) \\ \hline
+ F & fill unused 16-bits with value of F & 0 (not set)\footnotemark[1]\\ \hline
+ \end{longtable}
+ \footnotetext[1]{this means that andxf must be used if the not specified 16-bit should be preserve}
+ \caption{ISA flag overview}
+%\label{tab:<+label+>}
+\end{table}
if a condition is not met, the instruction is executed but no changes (on data or flags) occure.
\clearpage
\section{instr}
+\input{flags}
\subsection{arith}
modifies all flags
-ins ('32', 'and', 'And', '4 | 5 | 4 | 4 | 4 | 11', 'Conditions | OpCode | Register Destination|Register A (Source1)| Register B (Source2) | -');
+ins ('32', 'and', 'And', '4 | 5 | 4 | 4 | 4 | 10 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Register B (Source2) | - | SU');
-ins ('32', 'andi', 'And im', '4 | 5 | 4 | 4 | 12 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Immediate | H/L | F | -');
+# ins ('32', 'andi', 'And im', '4 | 5 | 4 | 4 | 12 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Immediate | H/L | F | -');
-ins ('32', 'andx', 'And im 16bit', '4 | 5 | 4 | 16 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination| Immediate | H/L | F | -');
+ins ('32', 'andx', 'And im 16bit', '4 | 5 | 4 | 16 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination| Immediate | H/L | F | SU');
-ins ('32', 'or', 'Or', '4 | 5 | 4 | 4 | 4 | 11', 'Conditions | OpCode | Register Destination|Register A (Source1)| Register B (Source2) | -');
+ins ('32', 'or', 'Or', '4 | 5 | 4 | 4 | 4 | 10 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Register B (Source2) | SU');
-ins ('32', 'ori', 'Or im', '4 | 5 | 4 | 4 | 12 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Immediate | H/L | F | -');
+# ins ('32', 'ori', 'Or im', '4 | 5 | 4 | 4 | 12 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Immediate | H/L | F | -');
-ins ('32', 'orx', 'Or im 16bit', '4 | 5 | 4 | 16 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination| Immediate | H/L | F | -');
+ins ('32', 'orx', 'Or im 16bit', '4 | 5 | 4 | 16 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination| Immediate | H/L | F | SU');
-ins ('32', 'xor', 'Or', '4 | 5 | 4 | 4 | 4 | 11', 'Conditions | OpCode | Register Destination|Register A (Source1)| Register B (Source2) | -');
+ins ('32', 'xor', 'Or', '4 | 5 | 4 | 4 | 4 | 10 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Register B (Source2) | SU');
-ins ('32', 'xori', 'Xor im', '4 | 5 | 4 | 4 | 12 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Immediate | H/L | F | -');
+# ins ('32', 'xori', 'Xor im', '4 | 5 | 4 | 4 | 12 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Immediate | H/L | F | -');
-ins ('32', 'xorx', 'Xor im 16bit', '4 | 5 | 4 | 16 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination| Immediate | H/L | F | -');
+ins ('32', 'xorx', 'Xor im 16bit', '4 | 5 | 4 | 16 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination| Immediate | H/L | F | SU');
-ins ('32', 'lls', 'left shift', '4 | 5 | 4 | 4 | 5 | 9 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Immediate | - | C');
+ins ('32', 'lls', 'left shift', '4 | 5 | 4 | 4 | 5 | 8 | 1 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Immediate | - | C | SU');
-ins ('32', 'lrs', 'right shift', '4 | 5 | 4 | 4 | 5 | 8 | 1 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Immediate | - | ARITH | C');
+ins ('32', 'lrs', 'right shift', '4 | 5 | 4 | 4 | 5 | 7 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Immediate | - | ARITH | C | SU');
-ins ('32', 'branch', 'Branch; save pc+4 in stack, jump to pc+imm', '4 | 5 | 16 | 5 | 1 | 1', 'Conditions | OpCode | Immediate | - | +/- | S');
+ins ('32', 'branch', 'Branch; jump to pc+imm', '4 | 5 | 16 | 3 | 2 | 1 | 1', 'Conditions | OpCode | Immediate | - | Branch/Call/Ret(i) | +/- | S');
-ins ('32', 'jump', 'Jump; jump to pc+imm', '4 | 5 | 16 | 5 | 1 | 1', 'Conditions | OpCode | Immediate | - | +/- | S');
+#ins ('32', 'call', 'Call; save pc+4 in stack, jump to pc+imm', '4 | 5 | 16 | 5 | 1 | 1', 'Conditions | OpCode | Immediate | - | +/- | S');
-ins ('32', 'jumpreg', 'Jump; jump to value of reg', '4 | 5 | 4 | 17 | 1 | 1', 'Conditions | OpCode | Register Source| - | +/- | S');
+#ins ('32', 'branchreg', 'Branch; branch to value of reg', '4 | 5 | 4 | 17 | 1 | 1', 'Conditions | OpCode | Register Source| - | +/- | S');
-ins ('32', 'ret', 'ret', '4 | 5 | 23 ', 'Conditions | OpCode | -');
+#ins ('32', 'ret(i)', 'return (from interrupt)', '4 | 5 | 1 | 22 ', 'Conditions | OpCode | I |-');
-ins ('32', 'reti', 'reti', '4 | 5 | 23 ', 'Conditions | OpCode | -');
+#ins ('32', 'ret', 'ret', '4 | 5 | 23 ', 'Conditions | OpCode | -');
+
+#ins ('32', 'reti', 'reti', '4 | 5 | 23 ', 'Conditions | OpCode | -');
ins ('32', 'cmp', 'compare (rS1 - rS2)', '4 | 5 | 4 | 4 | 15', 'Conditions | OpCode | Register A (Source1) | Register B (Source2) | -');