\documentclass[11pt]{exam}
\usepackage{amsmath}
\usepackage{amssymb}

\usepackage{datetime}
\usepackage{enumerate}
\usepackage{xltxtra}
\usepackage{listings}
\usepackage{listings-mips}

\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{makecell}
\usepackage{multicol}
\usepackage{multirow}

\usepackage{tabularx}
\usepackage{textcomp}
\usepackage{tikz}
\usetikzlibrary{arrows,automata,decorations.pathmorphing,backgrounds,positioning,fit}
\usepackage{pgf-umlcd}

\usepackage{fontspec}
\setmainfont{Gentium Basic}
\setmonofont{Comic Code}[
  Scale          = 0.80,
  UprightFont    = *-Regular,
  ItalicFont     = *-Italic,
  BoldFont       = *-Bold,
  BoldItalicFont = *-Bold Italic
]

\newcommand{\checkpoint}{{\Large $\checkmark$} }
\definecolor{outputgray}{gray}{0.95}

\lstset{
  basicstyle=\ttfamily,
  language=[mips]assembler,
}
\author{Brian C. Ladd}
\date{Spring 2024}
\title{Adding Some Numbers}

\begin{document}

\maketitle

\section*{Learning Outcomes}
After completing this program, students will be able to
\begin{itemize}
\item Write a MIPS program with a single \lstinline{main} and global data.
\item Use \lstinline{git} to turn in a program.
\item Use MIPS system calls to read and write data and strings.
\end{itemize}

\noindent
\textbf{Note:} For \emph{this} assignment you may make use of the
\lstinline{mult} instruction it MIPS.

\section*{Overview}
Students will write a program that prompts the user for three integer
values, $a$, $b$, and $c$. The program will then use three constants
defined in the program, $x$, $y$, and $z$, to calculate $value = a
\times z + b \times y + c \times x$. The program will store the value
in its own variable and print the results of the calculation.

\section*{Procedure}
\begin{questions}
\question{} Read this entire assignment. Spend a few minutes thinking
  about what you are going to do.

\question{} This program (and all programs in this course) are
  expected to follow the current Departmental Coding Standards (see
  the \lstinline{notes} folder for this class for a copy). In
  particular:
  \begin{itemize}
  \item Every file must identify the programmer, course, and
    assignment in a comment.
  \item Every \emph{function} should have a header comment identifying
    the purpose, parameters (and, in this class, where they are passed
    in), and return value. Document what it \emph{means}.
  \item Every program must include a \lstinline{README} (Coding
    Standards discuss formatting) that discusses how you \emph{tested}
    your program (how do you know it works) and notes as required by
    the assignment.
  \item Your code \textbf{must} assemble without error as submitted. I
    will load it into Mars and press the \textbf{Assemble} button. The
    code should be ready to run.
  \end{itemize}

  This is an upper-division programming course. No program will be
  graded if it fails to meet these requirements.

\question{} You will write a program in MIPS assembler using the MARS
  simulator found at \url{http://www.cs.missouristate.edu/MARS/}. The
  MIPS program itself is just a text file; there is no requirement
  that you type it into the simulator.
\question{} The program will:
\begin{lstlisting}[language={}]
Define global data: a,b,c, value, x,y,z
  (x, y, z have initial values that matter)
main:
  Prompt user for a
  Read integer
  Store integer in a
  Prompt user for b
  Read integer
  Store integer in b
  Prompt user for c
  Read integer
  Store integer in c

  Evaluate a*z+b*y+c*x
  Store result in value

  Print The value is ${value}
\end{lstlisting}

\question{} The vaules of $x, y, z$ come from your three initials (if
  you have fewer than three, pick letters to get to three; if you have
  more than three, pick three of them). The point is to have three
  letters, each of which you turn into a number:
  \begin{enumerate}
  \item 7 if the initial is in the first third of the alphabet
  \item 31 if the initial is in the middle third of the alphabet
  \item 57 if the initial is in the last third of the alphabet
  \end{enumerate}
  Then pick one of them and subtract 100 from it (so it is a negative
  number).%$
  \textbf{Note:} I am not very concerned about which values you use,
  just having different values and one that is negative.

\question{} Consider how you would write this in Java. All variables
  are \lstinline{static} integers (equivalent to global). It is very
  important to do this \textbf{before} trying to write the assembly.

  Write your Java solution and include it in your \lstinline{README}.

\question{} Define the seven variables in the \lstinline{.data}
  section. You can initialize all but $x, y, z$ to 0. Initialize those
  three to the expected constant values.

  You will also have to define strings in the data for \emph{prompts}
  and for the \emph{results}. \lstinline{.asciiz} (ASCII string ending
  in zero) is what you use define a string. Put all strings
  \emph{after} your integers (we will talk about why).

\question{} Write \lstinline{main} in the \lstinline{.text} segment to
  do what your Java program says to do.

\end{questions}
\section*{Submit through Gitea}
\paragraph{Check your working code into \lstinline{git}.} When you have
one working ``feature'' in your program, checking it in to
\lstinline{git} is a \emph{good thing}. Protect yourself from
making things \emph{worse}.

Use a \lstinline{.gitignore} file to exclude any garbage files your
IDE produces from the repository. They will cost you points.

You have an account on the departmental \textbf{Gitea} server. Submit
your work in your shared organization in a repo named
\lstinline{pAddingSomeNumbers}



\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
