SHELL := bash
-FILES = isa.tex conds.tex flags.tex callingconv.tex cmp.tex
+FILES = isa.tex conds.tex flags.tex callingconv.tex cmp.tex desdis.tex
FILES += Makefile
TARGET = isa.pdf
%.tex: %.ptex gentex.pl
./gentex.pl $<
-.PHONY: clean html
+.PHONY: clean
clean:
rm -fr *.aux *.log *.dvi *.pdf *.toc *.outc $(ISA_BUILD)
\begin{table}[ht]
\centering
\begin{tabular}{|c|c|c|} \hline
- register & saved by & usage \\ \hline
+ \textbf{register} & \textbf{saved by} & \textbf{usage} \\ \hline
r0 & caller & return \\ \hline
r1 & caller & first parameter \\ \hline
r2 & caller & second parameter \\ \hline
r1, 0x20-8(r3)} is a valid instruction
\end{itemize}
-\subsubsection{Directives}
+\subsection{Directives}
In order to gain extra comfort, several directives are interpreted by the
assembler, a list is given in table~\ref{tab:asmdirs}.
\begin{table}[ht]
\centering
\begin{tabular}{|l|p{10cm}|} \hline
- Name & Description \\ \hline
+ \textbf{Name} & \textbf{Description} \\ \hline
\texttt{.data} & subsequent data is desired for the data memory\\ \hline
\texttt{.text} & subsequent code is desired for the instruction memory\\ \hline
\verb+.include "file.s"+ & include a further file \\ \hline
- \texttt{.define <name> <value>} & define a constant. Note that a define
- isn't equal to a label\\ \hline
+ \texttt{.org \textit{addr}} & move \textit{forward} to a specific
+ address in data or instruction memory, depending on the current
+ section \\ \hline
+
+ \texttt{.fill \textit{repeat}, \textit{size}, \textit{value}} & place a
+ value of a specific size \texttt{\textit{repeat}}-times, while
+ \texttt{\textit{repeat}} and \texttt{\texttt{size}} are optional.
+
+ When one parameter is given, the value is placed at the current address.
+ Note that a given value will be rounded up to a full byte, e.g.
+ \texttt{0x123} occupy two bytes.
+
+ When two parameters are given, the first equals \texttt{\textit{repeat}}
+ and the second corresponds to \texttt{\textit{value}} \\ \hline
+
+ \texttt{.define \textit{name}, \textit{value}} & define a constant. Note
+ that a define isn't equal to a label\\ \hline
+
\texttt{label: <instr/data>} & label an instruction or data. The label
can be used as an alias for the address of this instruction in the
instruction memory or as a reference in the data memory, depending on
the current section\\ \hline
- %TODO: those are maybe handy: .fill(
- %http://www.myri.com/scs/L3/doc/as_7.html#SEC85)
\end{tabular}
\caption{supported directives by the assembler}
\label{tab:asmdirs}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{url}
+\usepackage{color}
\usepackage[latin1]{inputenc}
\usepackage{listings}
%\usepackage{ngerman}
#1 {\small (#2)}\\{\small\insertemail{#3}}
}
+\newcommand{\todo}[1]{
+ \large\textcolor{red}{TODO: #1}
+}
+
\newcommand{\allauthors}{
\author{
\addauthor{Markus Hofst\"atter}{0725034}{markus.manrow@gmx.at}\and
\begin{table}[ht]
\centering
\begin{tabular}{|c|c|c|c|}\hline
- Bitcode & Condition & Bits to test & suffixes \\ \hline
+ \textbf{Bitcode}&\textbf{Condition}& \textbf{Bits to test} &\textbf{suffixes}\\\hline
0000 & not equal / not zero & ZF = 0 & nq, nz \\ \hline
0001 & equal / zero & ZF = 1 & eq, zs \\ \hline
0010 & not overflow & OF = 0 & no \\ \hline
\begin{table}[hpt]
\centering
\begin{tabular}{|l|c|c|c|c|} \hline
- Bit & 3 & 2 & 1 & 0 \\ \hline
- Flag & SF & CF & OF & ZF \\ \hline
+ \textbf{Bit} & 3 & 2 & 1 & 0 \\ \hline
+ \textbf{Flag}& SF & CF & OF & ZF \\ \hline
\end{tabular}
\caption{Bits in the PSW}
\end{table}
-ins ('32', 'movpf', 'Move from PSW/Stack', '4 | 5 | 4 | 1 | 18', 'Conditions | OpCode | Register Destination| st | - ');
+ins ('32', 'mov\{p,s\}f', 'Move from PSW/Stack', '4 | 5 | 4 | 1 | 18', 'Conditions | OpCode | Register Destination| st | - ');
-ins ('32', 'movpt', 'Move to PSW/Stack', '4 | 5 | 4 | 1 | 18', 'Conditions | OpCode | Register Source | st | - ',
+ins ('32', 'mov\{p,s\}t', 'Move to PSW/Stack', '4 | 5 | 4 | 1 | 18', 'Conditions | OpCode | Register Source | st | - ',
'This instruction will set PSW or Stack to the value stored in the source register. When the move is to PSW the flags will be set like they are set in the source register.');
ins ('32', 'ldw', 'Load word; needs to be aligned to 32bit', '4 | 5 | 4 | 4 | 15', 'Conditions | OpCode | Register Destination|Register Address| displacement ');
ins ('32', 'stackop', 'pop/push/disc/fetch from/to stack', '4 | 5 | 4 | 2 | 17', 'Conditions | OpCode | Register Destination (not for disc) | Type | - ',
'This operation should not be used direct, instead the aliases pop, push, disc and fetch should be used.');
+plaintext ('\\mbox{}\\\\ \\todo{Type == ??}');
#ins ('32', 'pop', 'pop from stack', '4 | 5 | 4 | 19', 'Conditions | OpCode | Register Destination | - ');
\item Saving the return address of a call onto the stack and not into a link register
\item UART and timers are implemented as extension modules, which will allow us to implement additions modules for various functions
\item We defined that carry set is the condition below (unsigned lower)
- \item We use little endian for encoding our data and program space
+ \item We use little endian for encoding our data and program space\todo{hatten wir uns ned auf big endian geeinigt?}
\end{itemize}
In table~\ref{tab:flags} the flags that can suffix instructions are described. If and which flags are available depends on the instruction.
\begin{longtable}{|c|c|c|}\hline
- flag & function & default value \\ \hline
+ \textbf{flag} & \textbf{function} & \textbf{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)\footnote{this means that andxf must be used, if the not specified 16-bit, should be preserve} \\ \hline
- ST & read/write stack instead of PSW & 0 (not set) \\ \hline
S & sign extension & 0 (not set) \\ \hline
+/- & branch taken or not taken & + (taken) \\ \hline
A & if set the shift operation will be arithmetic instead of logic & 0 (logic) \\ \hline
\caption{ISA flag overview}
\label{tab:flags}
\end{longtable}
+\todo{@SU: mit welchem suffix deaktivieren? ``SU'' selbst ist imho verwirrend}
#!/usr/bin/perl
use strict;
+sub plaintext {
+ print $_[0];
+}
+
sub ins {
my $bits = $_[0];
my $bline;
$count = $bits-1;
- $tabular = "\\subsubsection{".$_[1]."}\n";
+ $tabular = "\\subsubsection{\\texttt{".$_[1]."} -- ".$_[2]."}\n";
$tabular .= "\\begin{center} \n \\resizebox{\\textwidth}{!}{\n";
$tabular .= "\\begin{tabular}{|l|";
for($i = $bits-1; $i >= 0; $i--) {
my @aliases = split(/\|/, $_[8]);
$tabular .= "\\begin{table}[!h] \n \\centering \n \\begin{tabular}{|c|c|} \\hline \n";
- $tabular .= "Alias & ".$_[1]." equivalent \\\\ \\hline \n";
+ $tabular .= "\\textbf{Alias }& \\textbf{".$_[1]." equivalent}\\\\ \\hline \n";
foreach my $alias (@aliases) {
my $equv;
my $from;
\begin{document}
\allauthors
-\title{Instruction Set ``Deep Thought''}
+\title{Instruction Set ``Deep Thought''} % haha, deep throat
\titlehead{Vienna University of Technology \hfill WS~2010}
\subject{Computer Architecture Labor\"ubung}
\date{\today}
ins ('32', 'lls', 'left shift', '4 | 5 | 4 | 4 | 5 | 8 | 1 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Immediate | - | C | SU',
'',' | Will change if C is set | | ');
+plaintext ('\\mbox{}\\\\ \\todo{lls und lrs zusammenfassen $\rightarrow$ ein bit entscheidet fuer shift nach links oder rechts}');
+
ins ('32', 'lrs', 'right shift', '4 | 5 | 4 | 4 | 5 | 7 | 1 | 1 | 1', 'Conditions | OpCode | Register Destination|Register A (Source1)| Immediate | - | A | C | SU',
'',' | Will change if C is set | | ');
ins ('32', 'branch', 'Branch; jump to pc+imm', '4 | 5 | 16 | 3 | 2 | 1 | 1', 'Conditions | OpCode | Immediate | - | Type | +/- | S',
'This instruction should be used with it\'s aliases branch, call, ret and reti. No flags will be affected by this instructions.');
+plaintext ('\\mbox{}\\\\ \\todo{Type == ??}');
+
+plaintext ('\\mbox{}\\\\ \\todo{branchreg? :-(}');
+
#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', 'branchreg', 'Branch; branch to value of reg', '4 | 5 | 4 | 17 | 1 | 1', 'Conditions | OpCode | Register Source| - | +/- | S');
.text
; TODO: will the assembler be able to evaluate these expressions?
- UART_BASE=0x1000
- UART_STATUS=(UART_BASE+0x4)
- UART_RECV=(UART_BASE+0x8)
- UART_TRANS=(UART_BASE+0xC)
- UART_BAUD=(UART_BAUD+0x10)
-
- UART_TRANS_EMPTY=0
- UART_RECV_NEW=1
-
- TIMEOUT_START=0x13371337
- DEFAULT_PROG_START=0x200
- STACKSTART=0x500 ; FIXME
+ .define UART_BASE, 0x1000
+ .define UART_STATUS, (UART_BASE+0x4)
+ .define UART_RECV, (UART_BASE+0x8)
+ .define UART_TRANS, (UART_BASE+0xC)
+ .define UART_BAUD, (UART_BAUD+0x10)
+
+ .define UART_TRANS_EMPTY, 0
+ .define UART_RECV_NEW, 1
+
+ .define TIMEOUT_START, 0x13371337
+ .define DEFAULT_PROG_START, 0x200
+ .define STACKSTART, 0x500 ; FIXME
;-----
main:
; setup stackframe
ldih r3, UART_STATUS@hi
ldw r3, 0(r3)
andi r3, r3, 1 << UART_RECV_NEW
- jumpzs+ next; jump if zero
+ branchzs+ next; branch if zero
- branch recv_byte
+ call recv_byte
; we received the enter bootrom sign
cmp r0, 0x48 ; 'H'
- jumpeq- bt_H
+ brancheq- bt_H
next:
subi r3, r3, 1
- jumpnz+ timeout_loop
+ branchnz+ timeout_loop
- ; branch to default entry point
+ ; call to default entry point
ldil r0, DEFAULT_PROG_START@lo
ldih r0, DEFAULT_PROG_START@hi
- jumpreg r0
+ branchreg r0
;-----
send_byte:
ldih r3, UART_STATUS@hi
ldw r3, 0(r3)
andi r3, r3, 1 << UART_TRANS_EMPTY
- jumpzs+ send_byte ; jump if zero
+ branchzs+ send_byte ; branch if zero
ldil r3, UART_TRANS@lo
ldih r3, UART_TRANS@hi
stb r1, 0(r3)
send_word:
; TODO: loop? (less codesize...)
lrs r0, r1, 0
- branch send_byte
+ call send_byte
lrs r0, r1, 8
- branch send_byte
+ call send_byte
lrs r0, r1, 16
- branch send_byte
+ call send_byte
lrs r0, r1, 24
- branch send_byte
+ call send_byte
ret
;-----
ldih r3, UART_STATUS@hi
ldw r3, 0(r3)
andi r3, r3, 1 << UART_RECV_NEW
- jumpzs+ send_byte ; jump if zero
+ branchzs+ send_byte ; branch if zero
ldil r3, UART_RECV@lo
ldih r3, UART_RECV@hi
lwb r0, 0(r3)
;-----
recv_word:
ldisl r0, 0x0
- branch recv_byte
+ call recv_byte
or r0, r0, r1
- branch recv_byte
+ call recv_byte
sll r1, r1, 8
or r0, r0, r1
- branch recv_byte
+ call recv_byte
sll r1, r1, 16
or r0, r0, r1
- branch recv_byte
+ call recv_byte
sll r1, r1, 24
or r0, r0, r1
;-----
bootrom:
- branch recv_byte
+ call recv_byte
cmpi r0, 0x57 ; 'W'
- jumpeq- bt_W
+ brancheq- bt_W
cmpi r0, 0x52 ; 'R'
- jumpeq- bt_R
+ brancheq- bt_R
cmpi r0, 0x51 ; 'Q'
- jumpeq- bt_Q
+ brancheq- bt_Q
cmpi r0, 0x54 ; 'T'
- jumpeq- bt_T
+ brancheq- bt_T
cmpi r0, 0x4a ; 'J'
- jumpeq- bt_J
+ brancheq- bt_J
; cmpi r0, 0x48 ; 'H'
- ; jumpeq bt_H
+ ; brancheq bt_H
; FALL THROUGH ;)
bt_H:
ldisl r1, 0x4f ; 'O'
- branch send_byte
- jump bootrom
+ call send_byte
+ branch bootrom
bt_W:
- branch recv_word ; receive addr
+ call recv_word ; receive addr
mov r6, r0
- branch recv_word ; receive instr
+ call recv_word ; receive instr
stx r0, 0(r6)
ldisl r1, 0x44 ; 'D'
- branch send_byte
- jump bootrom
+ call send_byte
+ branch bootrom
bt_R:
- branch recv_word ; receive addr
+ call recv_word ; receive addr
mov r2, r0
ldisl r1, 0x46 ; 'F'
- branch send_byte
+ call send_byte
ldx r1, 0(r2)
- branch send_word
- jump bootrom
+ call send_word
+ branch bootrom
bt_Q:
- branch recv_word ; receive addr
+ call recv_word ; receive addr
mov r6, r0
- branch recv_word ; receive data
+ call recv_word ; receive data
stw r0, 0(r6)
ldisl r1, 0x41 ; 'A'
- branch send_byte
- jump bootrom
+ call send_byte
+ branch bootrom
bt_T:
- branch recv_word ; receive addr
+ call recv_word ; receive addr
mov r2, r0
ldisl r1, 0x47 ; 'G'
- branch send_byte
+ call send_byte
ldw r1, 0(r2)
- branch send_word
- jump bootrom
+ call send_word
+ branch bootrom
bt_J:
- branch recv_word
- jumpreg r0
+ call recv_word
+ branchreg r0
; 102 instr. please update after modification