\input cwebmac
% This file is part of the Stanford GraphBase (c) Stanford University 1993
% This material goes at the beginning of all Stanford GraphBase CWEB files

\def\topofcontents{
  \leftline{\sc\today\ at \hours}\bigskip\bigskip
  \centerline{\titlefont\title}}

\font\ninett=cmtt9
\def\botofcontents{\vskip 0pt plus 1filll
    \ninerm\baselineskip10pt
    \noindent\copyright\ 1993 Stanford University
    \bigskip\noindent
    This file may be freely copied and distributed, provided that
    no changes whatsoever are made. All users are asked to help keep
    the Stanford GraphBase files consistent and ``uncorrupted,''
    identical everywhere in the world. Changes are permissible only
    if the modified file is given a new name, different from the names of
    existing files in the Stanford GraphBase, and only if the modified file is
    clearly identified as not being part of that GraphBase.
    (The {\ninett CWEB} system has a ``change file'' facility by
    which users can easily make minor alterations without modifying
    the master source files in any way. Everybody is supposed to use
    change files instead of changing the files.)
    The author has tried his best to produce correct and useful programs,
    in order to help promote computer science research,
    but no warranty of any kind should be assumed.
    \smallskip\noindent
    Preliminary work on the Stanford GraphBase project
    was supported in part by National Science
    Foundation grant CCR-86-10181.}

\def\prerequisite#1{\def\startsection{\noindent
    Important: Before reading {\sc\title},
    please read or at least skim the program for {\sc#1}.\bigskip
    \let\startsection=\stsec\stsec}}
\def\prerequisites#1#2{\def\startsection{\noindent
    Important: Before reading {\sc\title}, please read
    or at least skim the programs for {\sc#1} and {\sc#2}.\bigskip
    \let\startsection=\stsec\stsec}}



\def\title{TEST\_\,RISC\_\,ELTE}

\prerequisite{GB\_\,GATES\_\,ELTE}

\N{1}{1}Introduction. This demonstration program uses graphs
constructed by the \PB{\\{risc\_elte}} procedure in the
{\sc GB\_\,GATES\_\,ELTE} module to produce
an interactive program called \.{test\_risc\_elte}, which multiplies and
divides
small numbers the slow way---by simulating the behavior of
a logical circuit, one gate at a time.

The program assumes that \UNIX/ conventions are being used. Some code in
sections listed under `\UNIX/ dependencies' in the index might need to change
if this program is ported to other operating systems.

\def\<#1>{$\langle${\rm#1}$\rangle$}
To run the program under \UNIX/, say `\.{test\_risc\_elte} \<trace>',
where \<trace>
is nonempty if and only if you want the machine computations to
be printed out.

The program will prompt you for two numbers, and it will use the
simulated RISC ELTE machine to compute their product, quotient and
some other things.  Then it will ask for two more numbers, and so on.

\fi

\M{2}Here is the general layout of this program, as seen by the \CEE/ compiler:

\Y\B\8\#\&{include} \.{"gb\_graph.h"}\C{ the standard GraphBase data structures
}\6
\8\#\&{include} \.{"gb\_gates\_elte.h"}\C{ routines for gate graphs }\6
\ATH\7
\X3:Global variables\X\7
${}\\{main}(\\{argc},\39\\{argv}){}$\1\1\6
\&{int} \\{argc};\C{ the number of command-line arguments }\6
\&{char} ${}{*}\\{argv}[\,]{}$;\C{ an array of strings containing those
arguments }\2\2\6
${}\{{}$\1\6
${}\\{trace}\K(\\{argc}>\T{1}\?\T{8}:\T{0}){}$;\C{ we'll show registers 0--7 if
tracing }\6
\&{if} ${}((\|g\K\\{risc\_elte}(\T{8\$L}))\E\NULL){}$\5
${}\{{}$\1\6
${}\\{printf}(\.{"Sorry,\ I\ couldn't\ g}\)\.{enerate\ the\ graph\ (t}\)%
\.{rouble\ code\ \%ld)!\\n"},\39\\{panic\_code});{}$\6
\&{return} ${}({-}\T{1});{}$\6
\4${}\}{}$\2\6
\\{printf}(\.{"Welcome\ to\ the\ worl}\)\.{d\ of\ microRISC\ ELTE.}\)\.{\\n"});%
\6
\&{while} (\T{1})\5
${}\{{}$\1\6
\X4:Prompt for two numbers; \PB{\&{break}} if unsuccessful\X;\6
\X9:Test some instructions of the RISC ELTE machine\X;\6
\X7:Use the RISC ELTE machine to compute the product, \PB{\|p}\X;\6
${}\\{printf}(\.{"The\ product\ of\ \%ld\ }\)\.{and\ \%ld\ is\ \%ld\%s.\\n"},%
\39\|m,\39\|n,\39\|p,\39\|o\?\.{"\ (overflow\ occurred}\)\.{)"}:\.{""});{}$\6
\X8:Use the RISC ELTE machine to compute the quotient and remainder, \PB{\|q}
and~\PB{\|r}\X;\6
${}\\{printf}(\.{"The\ quotient\ is\ \%ld}\)\.{,\ and\ the\ remainder\ }\)\.{is%
\ \%ld.\\n"},\39\|q,\39\|r);{}$\6
\4${}\}{}$\2\6
\&{return} \T{0};\C{ normal exit }\6
\4${}\}{}$\2\par
\fi

\M{3}\B\X3:Global variables\X${}\E{}$\6
\&{Graph} ${}{*}\|g{}$;\C{ graph that defines a simple RISC machine }\6
\&{long} \|o${},{}$ \|p${},{}$ \|q${},{}$ \|r;\C{ overflow, product, quotient,
remainder }\6
\&{long} \\{trace};\C{ number of registers to trace }\6
\&{long} \|m${},{}$ \|n;\C{ numbers to be multiplied and divided }\6
\&{char} \\{buffer}[\T{100}];\C{ input buffer }\par
\A6.
\U2.\fi

\M{4}\B\D$\\{prompt}(\|s)$ \6
${}\{{}$\5
\1\\{printf}(\|s);\5
\\{fflush}(\\{stdout});\C{ make sure the user sees the prompt }\6
\&{if} ${}(\\{fgets}(\\{buffer},\39\T{99},\39\\{stdin})\E\NULL){}$\1\5
\&{break};\5
\2${}\}{}$\2\par
\Y\B\4\X4:Prompt for two numbers; \PB{\&{break}} if unsuccessful\X${}\E{}$\6
\\{prompt}(\.{"\\nGimme\ a\ number:\ "});\6
\4\\{step0}:\6
\&{if} ${}(\\{sscanf}(\\{buffer},\39\.{"\%ld"},\39{\AND}\|m)\I\T{1}){}$\1\5
\&{break};\2\6
\4\\{step1}:\6
\&{if} ${}(\|m\Z\T{0}){}$\5
${}\{{}$\1\6
\\{prompt}(\.{"Excuse\ me,\ I\ meant\ }\)\.{a\ positive\ number:\ "});\6
\&{if} ${}(\\{sscanf}(\\{buffer},\39\.{"\%ld"},\39{\AND}\|m)\I\T{1}){}$\1\5
\&{break};\2\6
\&{if} ${}(\|m\Z\T{0}){}$\1\5
\&{break};\2\6
\4${}\}{}$\2\6
\&{while} ${}(\|m>\T{\^7fff}){}$\5
${}\{{}$\1\6
\\{prompt}(\.{"That\ number's\ too\ b}\)\.{ig;\ please\ try\ again}\)\.{:\ "});%
\6
\&{if} ${}(\\{sscanf}(\\{buffer},\39\.{"\%ld"},\39{\AND}\|m)\I\T{1}){}$\1\5
\&{goto} \\{step0};\C{ \PB{\\{step0}} will \PB{\&{break}} out }\2\6
\&{if} ${}(\|m\Z\T{0}){}$\1\5
\&{goto} \\{step1};\2\6
\4${}\}{}$\2\6
\X5:Now do the same thing for \PB{\|n} instead of \PB{\|m}\X;\par
\U2.\fi

\M{5}\B\X5:Now do the same thing for \PB{\|n} instead of \PB{\|m}\X${}\E{}$\6
\\{prompt}(\.{"OK,\ now\ gimme\ anoth}\)\.{er:\ "});\6
\&{if} ${}(\\{sscanf}(\\{buffer},\39\.{"\%ld"},\39{\AND}\|n)\I\T{1}){}$\1\5
\&{break};\2\6
\4\\{step2}:\6
\&{if} ${}(\|n\Z\T{0}){}$\5
${}\{{}$\1\6
\\{prompt}(\.{"Excuse\ me,\ I\ meant\ }\)\.{a\ positive\ number:\ "});\6
\&{if} ${}(\\{sscanf}(\\{buffer},\39\.{"\%ld"},\39{\AND}\|n)\I\T{1}){}$\1\5
\&{break};\2\6
\&{if} ${}(\|n\Z\T{0}){}$\1\5
\&{break};\2\6
\4${}\}{}$\2\6
\&{while} ${}(\|n>\T{\^7fff}){}$\5
${}\{{}$\1\6
\\{prompt}(\.{"That\ number's\ too\ b}\)\.{ig;\ please\ try\ again}\)\.{:\ "});%
\6
\&{if} ${}(\\{sscanf}(\\{buffer},\39\.{"\%ld"},\39{\AND}\|n)\I\T{1}){}$\1\5
\&{goto} \\{step0};\C{ \PB{\\{step0}} will \PB{\&{break}} out }\2\6
\&{if} ${}(\|n\Z\T{0}){}$\1\5
\&{goto} \\{step2};\2\6
\4${}\}{}$\2\par
\U4.\fi

\N{1}{6}A RISC program. Here is the little program we will run on the
little computer. It consists mainly of a subroutine called \PB{\\{tri}},
which computes the value of the ternary operation $x\lfloor
y/z\rfloor$, assuming that $y\ge0$ and $z>0$; the inputs $x,y,z$
appear in registers $1,2,3$, respectively, and the exit address is
assumed to be in register~7.  As special cases we can compute the
product $xy$ (letting $z=1$) or the quotient $\lfloor y/z\rfloor$
(letting $x=1$). When the subroutine returns, it leaves the result in
register~4; it also leaves the value $(y\bmod z)-z$ in register~2.
Overflow will be set if and only if the true result was not between
$-2^{15}$ and $2^{15}-1$, inclusive.

It would not be difficult to modify the code to make it work with unsigned
16-bit numbers, or to make it deliver results with 32 or 48 or perhaps
even 64 bits of precision.

\Y\B\4\D$\\{div}$ \5
\T{112}\C{ location `\PB{\\{div}}' in the program below }\par
\B\4\D$\\{mult}$ \5
\T{115}\C{ location `\PB{\\{mult}}' in the program below }\par
\B\4\D$\\{test}$ \5
\T{16}\C{ location `\PB{\\{test}}' in the program below }\par
\B\4\D$\\{memry\_size}$ \5
\T{144}\C{ the number of instructions in the program below }\par
\Y\B\4\X3:Global variables\X${}\mathrel+\E{}$\6
\&{unsigned} \&{long} \\{memry}[\\{memry\_size}]${}\K\{{}$\C{ a ``ram memory''
used by \PB{\\{run\_risc}} }\6
${}\T{\^0f87},{}$\C{ \PB{\T{0}:} cold start, jump to 7 }\6
\T{\^0f70}${},{}$\C{ \quad\&{jumpto} interrupt handler }\6
\T{\^0058}${},{}$\C{ \quad at 88 }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^1ff0}${},{}$\C{ \PB{\\{start}:} $\\{r1}=m$ (contents of next word) }\6
\T{\^1111}${},{}$\C{ (we will put the value of \PB{\|m} here, in \PB{\\{memry}[%
\T{1}]}) }\6
\T{\^2a30}${},{}$\C{ \quad$\\{r2}=n$ (contents of next word) }\6
\T{\^3333}${},{}$\C{ (we will put the value of \PB{\|n} here, in \PB{\\{memry}[%
\T{3}]}) }\6
\T{\^7f70}${},{}$\C{ \quad\&{jumpto} (contents of next word),
      $\\{r7}={}$return address }\6
\T{\^5555}${},{}$\C{ (we will put an address here, in \PB{\\{memry}[\T{5}]}) }\6
\T{\^0f8f}${},{}$\C{ halt without changing any status bits }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^2d50}${},{}$\C{ \PB{\T{16}:} push \PB{\|n} to stack pointer 0 }\6
\T{\^2d70}${},{}$\C{ \quad write \PB{\|n} to given address }\6
\T{\^000e}${},{}$\C{ \quad 14 }\6
\T{\^1d46}${},{}$\C{ \quad write \PB{\|m} to address 6 }\6
\T{\^2d51}${},{}$\C{ \quad push \PB{\|n} to stack pointer \PB{\|m} }\6
\T{\^1d62}${},{}$\C{ \quad write \PB{\|m} to address \PB{\|n} }\6
\T{\^1d72}${},{}$\C{ \quad write \PB{\|m} indirect address at \PB{\|n} }\6
\T{\^3e71}${},{}$\C{ \quad pop \PB{\|n} from stack pointed by \PB{\|m} into
register 3 }\6
\T{\^3c61}${},{}$\C{ \PB{\T{24}:} \PB{\\{mxor}} of \PB{\|n} with \PB{\|m} }\6
\T{\^4e46}${},{}$\C{ \quad load from address 6 to register 4 }\6
\T{\^4e61}${},{}$\C{ \quad sideway add register 1 to 4 }\6
\T{\^4e70}${},{}$\C{ \quad pop from next address into register  4 }\6
\T{\^1111}${},{}$\C{ \quad data }\6
\T{\^4ad0}${},{}$\C{ \quad NOPE }\6
\T{\^5e5f}${},{}$\C{ \quad TRAP 15, return address into register 5 }\6
\T{\^0fa7}${},{}$\C{ \quad\PB{\&{return}} (literally, $\\{r0}=\\{r7}$) }\6
\T{\^0000}${},{}$\C{ \PB{\T{32}:} empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ \PB{\T{40}:} empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ \PB{\T{48}:} empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ \PB{\T{56}:} empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0f70}${},{}$\C{ \quad jump without link }\6
\T{\^0050}${},{}$\C{ \quad to 80 }\6
\T{\^624e}${},{}$\C{ \PB{\T{64}:} as well as this curious constant setting by
shift }\6
\T{\^3c51}${},{}$\C{ \quad \PB{\\{mor}} of \PB{\|n} with \PB{\|m} }\6
\T{\^4ad0}${},{}$\C{ \quad NOPE }\6
\T{\^0f70}${},{}$\C{ \quad jump back }\6
\T{\^0052}${},{}$\C{ \quad to 82 }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ \PB{\T{72}:} empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0244}${},{}$\C{ \PB{\T{80}:} fast jump done, but this may affect flags }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^6aa0}${},{}$\C{ \quad get present address into register 6 }\6
\T{\^6a94}${},{}$\C{ \quad and add 4 to write into memory at address 0 }\6
\T{\^6d40}${},{}$\C{ \quad to prepare simulation of interrupt after }\6
\T{\^0f81}${},{}$\C{ \quad this instruction, which jump to address 1 }\6
\T{\^0e55}${},{}$\C{ \quad resume by link in register 5 }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^1d43}${},{}$\C{ \PB{\T{88}:} int handler: save register 1 at address 3 }\6
\T{\^1f80}${},{}$\C{ \quad clear register 1 }\6
\T{\^1c88}${},{}$\C{ \quad save S flag into register 1 }\6
\T{\^1a94}${},{}$\C{ \quad save N flag into register 1 }\6
\T{\^1cd2}${},{}$\C{ \quad save K flag into register 1 }\6
\T{\^1ad1}${},{}$\C{ \quad save V flag into register 1 }\6
\T{\^2d44}${},{}$\C{ \quad save register 2 at address 4; etc. }\6
\T{\^2e44}${},{}$\C{ \quad load register 2 from address 4 }\6
\T{\^1061}${},{}$\C{ \PB{\T{96}:} shift register 1 to left by 1 }\6
\T{\^1061}${},{}$\C{ \quad shift register 1 to left by 1 }\6
\T{\^1621}${},{}$\C{ \quad shift register 1 to right by 4 to set K and V  }\6
\T{\^1830}${},{}$\C{ \quad make and of register 1 by }\6
\T{\^8001}${},{}$\C{ \quad this mask to set S and N }\6
\T{\^0f8f}${},{}$\C{ \quad halt without changing any status bits }\6
\T{\^0e50}${},{}$\C{ \quad resume 0 }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ \PB{\T{104}:} empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^3a21}${},{}$\C{ \PB{\\{div}:} $\\{r3}=\\{r1}$ }\6
\T{\^1a01}${},{}$\C{ \quad$\\{r1}=1$ }\6
\T{\^0a13}${},{}$\C{ \quad\PB{\&{goto} \\{tri}} (literally, \PB{$\MRL{\hbox{%
\\{r0}}+{\K}}$ \T{4}}) }\6
\T{\^3a01}${},{}$\C{ \PB{\\{mult}:} $\\{r3}=1$ }\6
\T{\^0a11}${},{}$\C{ \quad\PB{\&{goto} \\{tri}} (literally, \PB{$\MRL{\hbox{%
\\{r0}}+{\K}}$ \T{1}}) }\6
\T{\^4000}${},{}$\C{ \PB{\\{tri}:} $\\{r4}=0$ }\6
\T{\^5000}${},{}$\C{ \quad$\\{r5}=0$ }\6
\T{\^6000}${},{}$\C{ \quad$\\{r6}=0$ }\6
\T{\^2a63}${},{}$\C{ \quad\PB{$\MRL{\hbox{\\{r2}}-{\K\hbox{\\{r3}}}}$} }\6
\T{\^0f95}${},{}$\C{ \quad\PB{\&{goto} \\{l2}} }\6
\T{\^3063}${},{}$\C{ \PB{\\{l1}:} \PB{$\MRL{{\hbox{\\{r3}}\LL}{\K}}$ \T{1}} }\6
\T{\^1061}${},{}$\C{ \quad\PB{$\MRL{{\hbox{\\{r1}}\LL}{\K}}$ \T{1}} }\6
\T{\^6ac1}${},{}$\C{ \quad\PB{\&{if}} (overflow) $\\{r6}=1$ }\6
\T{\^5fd1}${},{}$\C{ \quad\PB{$\hbox{\\{r5}}\PP$} }\6
\T{\^2a63}${},{}$\C{ \PB{\\{l2}:} \PB{$\MRL{\hbox{\\{r2}}-{\K\hbox{\\{r3}}}}$}
}\6
\T{\^039b}${},{}$\C{ \quad\PB{\&{if}} ($\ge0$) \PB{\&{goto} \\{l1}} }\6
\T{\^0843}${},{}$\C{ \quad\PB{\&{goto} \\{l4}} }\6
\T{\^3463}${},{}$\C{ \PB{\\{l3}:} \PB{$\MRL{{\hbox{\\{r3}}\GG}{\K}}$ \T{1}} }\6
\T{\^1561}${},{}$\C{ \quad\PB{$\MRL{{\hbox{\\{r1}}\GG}{\K}}$ \T{1}} }\6
\T{\^2863}${},{}$\C{ \PB{\\{l4}:} \PB{$\MRL{\hbox{\\{r2}}+{\K\hbox{\\{r3}}}}$}
}\6
\T{\^0c94}${},{}$\C{ \quad\PB{\&{if}} ($<0$) \PB{\&{goto} \\{l5}} }\6
\T{\^4861}${},{}$\C{ \quad\PB{$\MRL{\hbox{\\{r4}}+{\K\hbox{\\{r1}}}}$} }\6
\T{\^6ac1}${},{}$\C{ \quad\PB{\&{if}} (overflow) $\\{r6}=1$ }\6
\T{\^2a63}${},{}$\C{ \quad\PB{$\MRL{\hbox{\\{r2}}-{\K\hbox{\\{r3}}}}$} }\6
\T{\^5a41}${},{}$\C{ \PB{\\{l5}:} \PB{$\hbox{\\{r5}}\MM$} }\6
\T{\^0398}${},{}$\C{ \quad\PB{\&{if}} ($\ge0$) \PB{\&{goto} \\{l3}} }\6
\T{\^6666}${},{}$\C{ \quad\PB{\&{if}} (\\{r6}) force overflow (literally \PB{$%
\MRL{{\hbox{\\{r6}}\GG}{\K}}$ \T{4}}) }\6
\T{\^0fa7}${},{}$\C{ \quad\PB{\&{return}}                  (literally, $\\{r0}=%
\\{r7}$, preserving overflow) }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${},{}$\C{ empty }\6
\T{\^0000}${}\}{}$;\C{ empty }\par
\fi

\M{7}\B\X7:Use the RISC ELTE machine to compute the product, \PB{\|p}\X${}\E{}$%
\6
$\\{memry}[\T{0}]\K\T{\^f87};{}$\6
${}\\{memry}[\T{8}]\K\|m;{}$\6
${}\\{memry}[\T{10}]\K\|n;{}$\6
${}\\{memry}[\T{12}]\K\\{mult};{}$\6
${}\\{run\_risc\_elte}(\|g,\39\\{memry},\39\\{memry\_size},\39\\{trace});{}$\6
${}\|p\K{}$(\&{long}) \\{risc\_state}[\T{4}];\6
${}\|o\K{}$(\&{long}) \\{risc\_state}[\T{16}]${}\AND\T{1}{}$;\C{ the overflow
bit }\par
\U2.\fi

\M{8}\B\X8:Use the RISC ELTE machine to compute the quotient and remainder, %
\PB{\|q} and~\PB{\|r}\X${}\E{}$\6
$\\{memry}[\T{12}]\K\\{div};{}$\6
${}\\{run\_risc\_elte}(\|g,\39\\{memry},\39\\{memry\_size},\39\\{trace});{}$\6
${}\|q\K{}$(\&{long}) \\{risc\_state}[\T{4}];\6
${}\|r\K((\&{long})(\\{risc\_state}[\T{2}]+\|n))\AND\T{\^7fff}{}$;\par
\U2.\fi

\M{9}\B\X9:Test some instructions of the RISC ELTE machine\X${}\E{}$\6
$\\{memry}[\T{0}]\K\T{\^f87};{}$\6
${}\\{memry}[\T{8}]\K\|m;{}$\6
${}\\{memry}[\T{10}]\K\|n;{}$\6
${}\\{memry}[\T{12}]\K\\{test};{}$\6
${}\\{run\_risc\_elte}(\|g,\39\\{memry},\39\\{memry\_size},\39\\{trace}){}$;\par
\U2.\fi

\N{1}{10}Index. Finally, here's a list that shows where the identifiers of this
program are defined and used.
\fi

\inx
\fin
\con
