\appendix

\section{Appendix: DAXPY Assembly code}
\label{app:code}

The loop compiled to uniprocessor code looks like this.  (This code
segment is lifted nearly verbatim from \cite{StarT92}.)

\beginid
  load  rXP, dFP[XP]     -- {\em load ptr to \/} X
  load  rYP, dFP[YP]     -- {\em load ptr to \/} Y
  load  rA,  dFP[A]      -- {\em load loop const:\/} a
  load  rYlim, dFP[YLim] -- {\em load loop const:\/} Y {\em ptr limit}
  cmp   rB,rYP,rYLim     -- {\em compare ptr to \/} Y {\em with limit\/}
  jgt   rB, OUT          -- {\em zero-trip loop if greater\/}
\null
LOOP:
  load  rXI, rXP         -- X[i] {\em into\/} rXI  {\bf (L1)}
  load  rYI, rYP         -- Y[i] {\em into\/} rYI  {\bf (L2)}
  add   rXP,rXP,8        -- {\em incr ptr to\/} X
  fmul  rTmp,rA,rXI      -- a*X[i]
  fadd  rTmp,rTmp,rYI    -- a*X[i] + Y[i]
  store rYP, rTmp        -- {\em store into\/} Y[i]  {\bf (S1)}
  add   rYP,rYP,8        -- {\em incr ptr to\/} Y
\null
  cmp   rB,rYP,rYLim     -- {\em compare ptr to \/} Y {\em with limit\/}
  jle   rB, LOOP         -- {\em fall out of loop if greater\/}
\null
OUT:
  {\em ... loop sequel ...\/}
\endid


The loop compiled to *T code looks like this.  (This code segment
is again lifted nearly verbatim from \cite{StarT92}.)

\beginid
;;
;; {\em Synchronization Processor Message Handlers}
;;
L1$_S$:
  store sFP[XI],   rV1   -- {\em store away incoming } X[I]
  join  c1, 2, CONTINUE$_D$ -- {\em attempt continuation of loop}
  next                   -- {\em next message}
\null
L2$_S$:
  store sFP[YI],   rV1   -- {\em store away incoming } Y[I]
  join  c1, 2, CONTINUE$_D$ -- {\em attempt continuation of loop}
  next                   -- {\em next message}
\null
S1$_S$:
  load  rN, sFP[N]       -- {\em total number of stores}
  join  c2, rN, OUT$_D$     -- {\em sequel when all stores complete}
;;
;; {\em Data Processor Threads}
;;
  load  rXP, dFP[XP]     -- {\em load ptr to \/} X
  load  rYP, dFP[YP]     -- {\em load ptr to \/} Y
  load  rYlim, dFP[YLim] -- {\em load loop const:\/} Y {\em ptr limit}
  cmp   rB,rYP,rYLim     -- {\em compare ptr to \/} Y {\em with limit\/}
  jgt   rB, OUT$_D$         -- {\em zero-trip loop if greater\/}
\null
LOOP$_D$:
  rload rXP, L1$_S$         -- {\em initiate load\/} X[i] {\bf (L1)}
  rload rYP, L2$_S$         -- {\em initiate load\/} Y[i] {\bf (L2)}
  next
\null
CONTINUE$_D$:
  load  rA,  dFP[A]      -- {\em load loop const:\/} a
  load  rXP, dFP[XP]     -- {\em load ptr to \/} X
  load  rYP, dFP[YP]     -- {\em load ptr to \/} Y
  load  rYLim, dFP[YLim] -- {\em load loop const:\/} Y {\em ptr limit}
\null
  load  rXI, dFP[XI]     -- {\em load copy of \/} X[I]
  load  rYI, dFP[YI]     -- {\em load copy of \/} Y[I]
\null
  fmul  rTmp,rA,rXI      -- a*X[i]
  fadd  rTmp,rTmp,rYI    -- a*X[i] + Y[i]
  rstore rYP, rTmp,S1$_S$   -- {\em store into\/} Y[i] {\bf (S1)}
  add   rXP,rXP,8        -- {\em increment ptr to\/} X
  add   rYP,rYP,8        -- {\em increment ptr to\/} Y
  store dFP[XP],   rXP   -- {\em store ptr to \/} X
  store dFP[YP],   rYP   -- {\em store ptr to \/} Y
\null
  cmp   rB,rYP,rYLim     -- {\em compare ptr to \/} Y {\em with limit\/}
  jle   rB, LOOP$_D$        -- {\em fall out of loop if greater\/}
  next
\null
OUT$_D$:
  {\em ... loop sequel ...\/}
\endid

