isa: conditionbits fixed (?), starting with opcode
authorMartin Perner <martin@perner.cc>
Mon, 25 Oct 2010 13:00:28 +0000 (15:00 +0200)
committerMartin Perner <martin@perner.cc>
Mon, 25 Oct 2010 13:00:28 +0000 (15:00 +0200)
2_isa/Makefile [new file with mode: 0644]
2_isa/arith.ptex [new file with mode: 0644]
2_isa/common.sty [new file with mode: 0644]
2_isa/conds.tex [new file with mode: 0644]
2_isa/data.ptex [new file with mode: 0644]
2_isa/gentex.pl [new file with mode: 0755]
2_isa/isa.tex [new file with mode: 0644]
2_isa/misc.ptex [new file with mode: 0644]

diff --git a/2_isa/Makefile b/2_isa/Makefile
new file mode 100644 (file)
index 0000000..9a9fcc6
--- /dev/null
@@ -0,0 +1,27 @@
+SHELL := bash
+
+FILES  = isa.tex conds.tex
+FILES += Makefile
+TARGET = isa.pdf
+
+ISA_FILES = arith.ptex data.ptex misc.ptex
+
+ISA_BUILD = $(ISA_FILES:.ptex=.tex)
+
+PDFGEN = pdflatex --jobname=$(basename $@) $<
+
+all: $(TARGET)
+
+$(TARGET): $(FILES) $(ISA_BUILD)
+       $(PDFGEN)
+       $(PDFGEN)
+       $(PDFGEN)
+
+%.tex: %.ptex
+       ./gentex.pl $^
+
+.PHONY: clean html
+
+clean:
+       rm -fr *.aux *.log *.dvi *.pdf *.toc *.outc $(ISA_BUILD)
+
diff --git a/2_isa/arith.ptex b/2_isa/arith.ptex
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/2_isa/common.sty b/2_isa/common.sty
new file mode 100644 (file)
index 0000000..c626b91
--- /dev/null
@@ -0,0 +1,39 @@
+\usepackage{graphicx}
+\usepackage{amsmath}
+\usepackage{hyperref}
+\usepackage{url}
+\usepackage[latin1]{inputenc}
+\usepackage{listings}
+\usepackage{ngerman}
+
+
+% put footnotes below floats
+% this is a good idea if the table for the cmp looks bad on top of page
+\usepackage{fnpos}
+\makeFNbelow
+
+
+\lstset{%
+basicstyle=\footnotesize,
+frame=single,
+breaklines=true,
+tabsize=4
+}
+
+\newcommand{\insertemail}[1]{\href{mailto:#1}{#1}}
+
+\newcommand{\longcomment}[1]{}
+
+\newcommand{\addauthor}[3]{
+       #1 {\small (#2)}\\{\small\insertemail{#3}}
+}
+
+\newcommand{\allauthors}{
+       \author{
+               \addauthor{Markus Hofst\"atter}{0725034}{markus.manrow@gmx.at}\and
+               \addauthor{Martin Perner}{0725782}{e0725782@student.tuwien.ac.at}\and
+               \addauthor{Stefan Rebernig}{0726283}{stefan.rebernig@gmail.com}\and
+               \addauthor{Manfred Schwarz}{0725898}{e0725898@student.tuwien.ac.at}\and
+               \addauthor{Bernhard Urban}{0725771}{lewurm@gmail.com}
+       }
+}
diff --git a/2_isa/conds.tex b/2_isa/conds.tex
new file mode 100644 (file)
index 0000000..3f82736
--- /dev/null
@@ -0,0 +1,34 @@
+\section{Conditions}
+
+\begin{table}[ht]
+       \centering
+       \begin{tabular}{|c|c|c|}\hline
+               Bitcode & Condition             & Bits to test \\ \hline
+               0000    & equal / zero          & ZF = 0\\ \hline
+               0001    & not equal / not zero  & ZF = 1\\ \hline
+               0010    & not overflow          & OF = 0\\ \hline
+               0011    & overflow              & OF = 1\\ \hline
+               0100    & not carry             & CF = 0\\ \hline
+               0101    & carry                 & CF = 1\\ \hline
+               0110    & not signed / not neg. & SF = 0\\ \hline
+               0111    & signed / neg.         & SF = 1\\ \hline
+               1000    & below (?)             & \\ \hline
+               1001    & above (?)             & \\ \hline
+               1010    & greater than or equal & SF == OF\\ \hline
+               1011    & less than             & SF != OF \\ \hline
+               1100    & greater than          & (ZF == 0 $\wedge$ SF == OF) \\ \hline
+               1101    & less than or equal    & (ZF == 1 $\vee$ SF != OF) \\ \hline
+               1110    & never                 & \\ \hline
+               1111    & always                & \\ \hline
+       \end{tabular}
+       \caption{codierung von conditions}
+\end{table}
+
+\begin{table}
+       \centering
+       \begin{tabular}{|l|c|c|c|c|} \hline
+               Bit  & 3  & 2  & 1  & 0  \\ \hline
+               Flag & SF & CF & OF & ZF \\ \hline
+       \end{tabular}
+       \caption{billig PSW bitorder}
+\end{table}
diff --git a/2_isa/data.ptex b/2_isa/data.ptex
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/2_isa/gentex.pl b/2_isa/gentex.pl
new file mode 100755 (executable)
index 0000000..a36281a
--- /dev/null
@@ -0,0 +1,149 @@
+#!/usr/bin/perl
+
+sub ins {
+       my $bits = $_[0];
+       my $bline;
+       #bit value line
+       my $vline;
+       my $nline;
+       #print bit value line
+       my $pvline;
+       my @bitlist;
+       my $tabular;
+
+
+       $count = 0;
+       @fields = split(/\|/, $_[3]);
+       foreach my $field (@fields) {
+               #remove heading and trailing spaces
+               $field =~ s/^\s+//;
+               $field =~ s/\s+$//;
+
+               $count += $field;
+               #$tabular .= $field." \\\\";
+       }
+
+       if($count != $bits) {
+               return "Num of Fields not equal to Bits!";
+       }
+       $count = 0;
+       @fieldnames = split(/\|/, $_[4]);
+
+       if(scalar(@fields) != scalar(@fieldnames)) {
+               return "Num of Fields != Num of Names";
+       }
+
+       $pvline = 0;
+       foreach my $fieldn (@fieldnames) {
+               #remove heading and trailing spaces
+               $fieldn =~ s/^\s+//;
+               $fieldn =~ s/\s+$//;
+
+               if($fieldn =~ m/^[^\(.]*\(\s*([0-1]+)\s*\).*$/) {
+                       if(length($1) == $fields[$count]) {
+                               push(@bitlist,$1);
+                               $fieldn =~  s/\s?\(\s*[0-1]+\s*\)//;
+                               $pvline = 1;
+                       }
+                       else {
+                               $x = '';
+                               for($i = 1; $i <= $fields[$count]; $i++) {
+                                       $x .= 'X';
+                               }
+                       push(@bitlist,$x);
+                       }
+               }
+               else {
+                       $x = '';
+                       for($i = 1; $i <= $fields[$count]; $i++) {
+                               $x .= 'X';
+                       }
+                       push(@bitlist,$x);
+               }
+               #$tabular .= $fieldn.": ". $bits." \\\\";
+               $count++;
+       }
+       $bitlist = join("",@bitlist);
+
+       #$tabular .= "\\textbf{names:} @fieldnames \n";
+       #$tabular .= "\\textbf{bitlist:} $bitlist \n";
+
+       $count = $bits-1;
+
+       $tabular = "\\begin{center} \n \\resizebox{\\textwidth}{!}{\n";
+       $tabular .= "\\begin{tabular}{|l|";
+       for($i = $bits-1; $i >= 0; $i--) {
+               #build table
+               $tabular .= "c|";
+
+               #build bitcount
+               $bline .= $i;
+               if($i != 0) {
+                       $bline .= " & ";
+               }
+               else {
+                       $bline .= "\\\\ \\hline \n";
+               }
+
+               #build bitvalue
+               $vline .= substr($bitlist,($bits-1)-$i,1);
+               if($i != 0) {
+                       $vline .= " & ";
+               }
+               else {
+                       $vline .= "\\\\ \\hline \n";
+               }
+
+               #build nameline
+               #because of multicolumn we need to limit execution
+               if($i == $count) {
+                       $nline .= "\\multicolumn{@fields[0]}{>{\\columncolor{names}}c|}{@fieldnames[0]}";
+
+                       #update count
+                       $count -= @fields[0];
+
+                       if($count <= 0) {
+                               $nline .= "\\\\ \\hline \n";
+                       }
+                       else {
+                               $nline .= " & ";
+                       }
+
+                       shift(@fieldnames);
+                       shift(@fields);
+               }
+       }
+       $tabular .= "} \\hline \n";
+       $tabular .= "\\multicolumn{".($bits+1)."}{|>{\\columncolor{title}}c|}{\\textbf{".$_[1]."} (".$_[2].")} \\\\ \\hline \n";
+       $tabular .= "\\rowcolor{bit} \\cellcolor{title} &". $bline;
+       if($pvline == 1) {
+               $tabular .= "\\rowcolor{bitval} \\cellcolor{title}Values &". $vline;
+       }
+       $tabular .= "\\cellcolor{title}Field &". $nline;
+       $tabular .= "\\end{tabular}\n}\n \\end{center}\n";
+
+
+       return $tabular;
+}
+
+if($#ARGV != 0) {
+       die "Usage: gentex.pl <file.ptex>";
+}
+
+open(DATA, "<".$ARGV[0]) || die "Couldn't open file $ARGV[0] for read!";
+
+$output = $ARGV[0];
+
+$output =~ s/\.[^.]*$//;
+$output .= ".tex";
+
+open(OUTPUT, ">".$output) || die "Couldn't open file $output for output!";
+
+while(<DATA>)
+{
+       $res = eval "$_";
+       print OUTPUT $res;
+}
+
+close(DATA);
+close(OUTPUT);
diff --git a/2_isa/isa.tex b/2_isa/isa.tex
new file mode 100644 (file)
index 0000000..73e462b
--- /dev/null
@@ -0,0 +1,27 @@
+\documentclass[a4paper,12pt]{scrartcl}
+\usepackage{common}
+\begin{document}
+\allauthors
+
+\title{Instruction Set}
+\titlehead{Vienna University of Technology \hfill WS~2010}
+\subject{Computer Architecture Labor\"ubung}
+\date{\today}
+\publishers{Gruppe 1}
+
+\maketitle
+\newpage
+\tableofcontents
+\newpage
+
+\include{conds}
+\section{instr}
+\subsection{arith}
+\include{arith}
+\subsection{data}
+\include{data}
+\subsection{misc}
+\include{misc}
+
+
+\end{document}
diff --git a/2_isa/misc.ptex b/2_isa/misc.ptex
new file mode 100644 (file)
index 0000000..e69de29