\documentclass{article}
\input{6828-preamble}

\begin{document}
\psetnum{6}
\date{2004/09/27}

\begin{pset}
  \begin{problem}
    The modified kernel boots successfully:
\begin{verbatim}
sim> boot rk0
@unix.new
modified 6.828 kernel
mem = 1035

login: 
\end{verbatim}
  \end{problem}

  \begin{problem}
    The exit status is 72.
  \end{problem}

  \begin{problem}
    The register status is:
\begin{verbatim}
Breakpoint, PC=003604  (JSR R5,3552)
R0=003662 R1=172320 R2=001170 R3=000000 R4=000200 R5=141774
KSP=141756 USP=000000 PSW=030000 (CM=0,PM=3,IPL=0,tnzvc)
\end{verbatim}
    The stack is below.
  \end{problem}

  \begin{problem}
\begin{verbatim}
   141736: 000000
   141740: 000000
   141742: 000000
   141744: 000000
   141746: 000000
   141750: 000000
   141752: 000000
   141754: 000000
-> 141756: 003700   return PC of f
   141760: 000001   arg #1 to f (a)
   141762: 000002   arg #2 to f (b)
   141764: 003566   return PC to cret
   141766: 001170   saved r2 from before main
   141770: 000000   saved r3 from before main
   141772: 000200   saved r4 from before main
   141774: 135370   saved r5 from before main
   141776: 003470   return PC of main
\end{verbatim}
  \end{problem}

  \begin{problem}
\begin{verbatim}
main:
jsr r5,csv                    run csv to save register values
tst -(sp)                     allocate space on stack
mov 2,(sp)                    push 2 on stack in allocated space
mov 1,-(sp)                   push 1 on stack
jsr pc,*$_f                   call f 
tst (sp)+                     deallocate stack space
mov r0,x(r5)                  put r0 (return value) in x (on stack)
mov x(r5),r0                  put x (on stack) into r0
br _main+36                   instruction doesn't appear in kernel (?)
jmp cret                      jump to cret to restore registers

f:
jsr r5,csv                    execute csv
tst -(sp)                     allocate stack space
clr x(r5)                     x = 0 (on stack)
mov a(r5),r0                  r0 = a (from stack)
ash 0+3,r0                    r0 *= 8
add r0,x(r5)                  x += r0
mov b(r5),r0                  r0 = b (from stack)
ash $7+1,r0                   r0 *= 32
add r0,x(r5)                  x += r0
mov x(r5),r0                  r0 = x
%br _f+50                     instruction doesn't appear in kernel (?) 
jmp cret                      jump to cret to restore registers

\end{verbatim}
  \end{problem}
  \end{pset}
\end{document}
