root/doc_inner/doxygen/latex/exec_8c_source.tex

/* [<][>][^][v][top][bottom][index][help] */
\doxysection{exec.\+c}
\label{exec_8c_source}\index{src/exec.c@{src/exec.c}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#include\ "{}exec.h"{}}}
\DoxyCodeLine{00002\ }
\DoxyCodeLine{00010\ \textcolor{keywordtype}{char}\ *pr2str(WORD\ pr);}
\DoxyCodeLine{00011\ }
\DoxyCodeLine{00016\ \textcolor{keywordtype}{void}\ svcin();}
\DoxyCodeLine{00017\ }
\DoxyCodeLine{00022\ \textcolor{keywordtype}{void}\ svcout();}
\DoxyCodeLine{00023\ }
\DoxyCodeLine{00029\ \textcolor{keywordtype}{void}\ setfr(WORD\ adr);}
\DoxyCodeLine{00030\ }
\DoxyCodeLine{00038\ WORD\ get\_r\_r1(WORD\ oprx);}
\DoxyCodeLine{00039\ }
\DoxyCodeLine{00047\ WORD\ get\_x\_r2(WORD\ oprx);}
\DoxyCodeLine{00048\ }
\DoxyCodeLine{00057\ WORD\ get\_adr\_x(WORD\ adr,\ WORD\ oprx);}
\DoxyCodeLine{00058\ }
\DoxyCodeLine{00067\ WORD\ get\_val\_adr\_x(WORD\ adr,\ WORD\ oprx);}
\DoxyCodeLine{00068\ }
\DoxyCodeLine{00072\ \textcolor{keyword}{static}\ CERR\ cerr\_exec[]\ =\ \{}
\DoxyCodeLine{00073\ \ \ \ \ \{\ 201,\ \textcolor{stringliteral}{"{}Program\ Register\ (PR)\ -\/\ memory\ overflow"{}}\ \},}
\DoxyCodeLine{00074\ \ \ \ \ \{\ 202,\ \textcolor{stringliteral}{"{}Stack\ Pointer\ (SP)\ -\/\ stack\ overflow"{}}\ \},}
\DoxyCodeLine{00075\ \ \ \ \ \{\ 203,\ \textcolor{stringliteral}{"{}Stack\ Pointer\ (SP)\ -\/\ stack\ underflow"{}}\ \},}
\DoxyCodeLine{00076\ \ \ \ \ \{\ 204,\ \textcolor{stringliteral}{"{}OP\ in\ word\ \#1\ -\/\ not\ command\ code"{}}\ \},}
\DoxyCodeLine{00077\ \ \ \ \ \{\ 205,\ \textcolor{stringliteral}{"{}r/r1\ in\ word\ \#1\ -\/\ not\ GR"{}}\ \},}
\DoxyCodeLine{00078\ \ \ \ \ \{\ 206,\ \textcolor{stringliteral}{"{}x/r2\ in\ word\ \#1\ -\/\ not\ GR"{}}\ \},}
\DoxyCodeLine{00079\ \ \ \ \ \{\ 207,\ \textcolor{stringliteral}{"{}address\ in\ word\ \#2\ -\/\ out\ of\ memory"{}}\ \},}
\DoxyCodeLine{00080\ \ \ \ \ \{\ 208,\ \textcolor{stringliteral}{"{}SVC\ input\ -\/\ memory\ overflow"{}}\ \},}
\DoxyCodeLine{00081\ \ \ \ \ \{\ 209,\ \textcolor{stringliteral}{"{}SVC\ output\ -\/\ memory\ overflow"{}}\ \},}
\DoxyCodeLine{00082\ \};}
\DoxyCodeLine{00083\ }
\DoxyCodeLine{00087\ EXECMODE\ execmode\ =\ \{\textcolor{keyword}{false},\ \textcolor{keyword}{false},\ \textcolor{keyword}{false},\ 0,\ 0xFFFF,\ \textcolor{keyword}{false},\ \textcolor{keyword}{false}\};}
\DoxyCodeLine{00088\ }
\DoxyCodeLine{00089\ \textcolor{keywordtype}{char}\ *pr2str(WORD\ pr)}
\DoxyCodeLine{00090\ \{}
\DoxyCodeLine{00091\ \ \ \ \ \textcolor{keywordtype}{char}\ *str\ =\ malloc\_chk(CERRSTRSIZE\ +\ 1,\ \textcolor{stringliteral}{"{}pr2str.pr"{}});}
\DoxyCodeLine{00092\ }
\DoxyCodeLine{00093\ \ \ \ \ sprintf(str,\ \textcolor{stringliteral}{"{}PR:\#\%04X"{}},\ pr);}
\DoxyCodeLine{00094\ \ \ \ \ \textcolor{keywordflow}{return}\ str;}
\DoxyCodeLine{00095\ \}}
\DoxyCodeLine{00096\ }
\DoxyCodeLine{00097\ \textcolor{keywordtype}{void}\ svcin()}
\DoxyCodeLine{00098\ \{}
\DoxyCodeLine{00099\ \ \ \ \ \textcolor{keywordtype}{int}\ i;}
\DoxyCodeLine{00100\ \ \ \ \ \textcolor{keywordtype}{char}\ *buf\ =\ malloc\_chk(INSIZE\ +\ 1,\ \textcolor{stringliteral}{"{}svcin.buf"{}});}
\DoxyCodeLine{00101\ }
\DoxyCodeLine{00102\ \ \ \ \ \textcolor{keywordflow}{if}(fgets(buf,\ INSIZE,\ stdin)\ ==\ NULL)\ \{}
\DoxyCodeLine{00103\ \ \ \ \ \ \ \ \ sys-\/>memory[sys-\/>cpu-\/>gr[1]]\ =\ sys-\/>memory[sys-\/>cpu-\/>gr[2]]\ =\ 0x0;}
\DoxyCodeLine{00104\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{00105\ \ \ \ \ \}}
\DoxyCodeLine{00106\ \ \ \ \ \textcolor{keywordflow}{for}(i\ =\ 0;\ i\ <\ INSIZE;\ i++)\ \{}
\DoxyCodeLine{00107\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(!buf[i]\ ||\ buf[i]\ ==\ \textcolor{charliteral}{'\(\backslash\)n'})\ \{}
\DoxyCodeLine{00108\ \ \ \ \ \ \ \ \ \ \ \ \ -\/-\/i;}
\DoxyCodeLine{00109\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00110\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00111\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(sys-\/>cpu-\/>gr[1]\ +\ i\ >\ execptr-\/>end)\ \{}
\DoxyCodeLine{00112\ \ \ \ \ \ \ \ \ \ \ \ \ setcerr(208,\ \textcolor{stringliteral}{"{}"{}});\ \ \ \ \textcolor{comment}{/*\ SVC\ input\ -\/\ memory\ overflow\ */}}
\DoxyCodeLine{00113\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00114\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00115\ \ \ \ \ \ \ \ \ sys-\/>memory[sys-\/>cpu-\/>gr[1]\ +\ i]\ =\ buf[i];}
\DoxyCodeLine{00116\ \ \ \ \ \}}
\DoxyCodeLine{00117\ \ \ \ \ sys-\/>memory[sys-\/>cpu-\/>gr[2]]\ =\ i\ +\ 1;}
\DoxyCodeLine{00118\ \ \ \ \ FREE(buf);}
\DoxyCodeLine{00119\ \}}
\DoxyCodeLine{00120\ }
\DoxyCodeLine{00121\ \textcolor{keywordtype}{void}\ svcout()}
\DoxyCodeLine{00122\ \{}
\DoxyCodeLine{00123\ \ \ \ \ \textcolor{keywordtype}{int}\ i;}
\DoxyCodeLine{00124\ \ \ \ \ WORD\ w;}
\DoxyCodeLine{00125\ }
\DoxyCodeLine{00126\ \ \ \ \ \textcolor{keywordflow}{for}(i\ =\ 0;\ i\ <\ sys-\/>memory[sys-\/>cpu-\/>gr[2]];\ i++)\ \{}
\DoxyCodeLine{00127\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(sys-\/>cpu-\/>gr[1]\ +\ i\ >\ execptr-\/>end)\ \{}
\DoxyCodeLine{00128\ \ \ \ \ \ \ \ \ \ \ \ \ setcerr(209,\ \textcolor{stringliteral}{"{}"{}});\ \ \ \ \textcolor{comment}{/*\ SVC\ output\ -\/\ memory\ overflow\ */}}
\DoxyCodeLine{00129\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{00130\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00131\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ 「JIS\ X\ 0201ラテン文字・片仮名用8ビット符号で規定する文字の符号表」}}
\DoxyCodeLine{00132\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ に記載された文字と、改行(CR)/タブを表示\ */}}
\DoxyCodeLine{00133\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ それ以外の文字は、「.」で表す\ */}}
\DoxyCodeLine{00134\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(((w\ =\ sys-\/>memory[sys-\/>cpu-\/>gr[1]+i])\ >=\ 0x20\ \&\&\ w\ <=\ 0x7E)\ ||\ \ \ \ \textcolor{comment}{/*\ JIS\ X\ 0201ラテン文字\ */}}
\DoxyCodeLine{00135\ \ \ \ \ \ \ \ \ \ \ \ (w\ >=\ 0xA0\ \&\&\ w\ <=\ 0xFE)\ ||\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ JIS\ X\ 0201片仮名用8ビット符号\ */}}
\DoxyCodeLine{00136\ \ \ \ \ \ \ \ \ \ \ \ w\ ==\ 0xA\ ||\ w\ ==\ \textcolor{charliteral}{'\(\backslash\)t'})}
\DoxyCodeLine{00137\ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{00138\ \ \ \ \ \ \ \ \ \ \ \ \ putchar((\textcolor{keywordtype}{char})w);}
\DoxyCodeLine{00139\ \ \ \ \ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00140\ \ \ \ \ \ \ \ \ \ \ \ \ putchar(\textcolor{charliteral}{'.'});}
\DoxyCodeLine{00141\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00142\ \ \ \ \ \}}
\DoxyCodeLine{00143\ \}}
\DoxyCodeLine{00144\ }
\DoxyCodeLine{00145\ \textcolor{keywordtype}{void}\ setfr(WORD\ adr)}
\DoxyCodeLine{00146\ \{}
\DoxyCodeLine{00147\ \ \ \ \ sys-\/>cpu-\/>fr\ =\ 0x0;}
\DoxyCodeLine{00148\ \ \ \ \ \textcolor{comment}{/*\ 第15ビットが1のとき、SFは1\ */}}
\DoxyCodeLine{00149\ \ \ \ \ \textcolor{keywordflow}{if}((adr\ \&\ 0x8000)\ ==\ 0x8000)\ \{}
\DoxyCodeLine{00150\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ SF;}
\DoxyCodeLine{00151\ \ \ \ \ \}}
\DoxyCodeLine{00152\ \ \ \ \ \textcolor{comment}{/*\ 演算結果が0のとき、ZFは1\ */}}
\DoxyCodeLine{00153\ \ \ \ \ \textcolor{keywordflow}{if}(adr\ ==\ 0x0)\ \{}
\DoxyCodeLine{00154\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ ZF;}
\DoxyCodeLine{00155\ \ \ \ \ \}}
\DoxyCodeLine{00156\ \}}
\DoxyCodeLine{00157\ }
\DoxyCodeLine{00158\ WORD\ get\_r\_r1(WORD\ oprx)}
\DoxyCodeLine{00159\ \{}
\DoxyCodeLine{00160\ \ \ \ \ WORD\ r\ =\ 0;}
\DoxyCodeLine{00161\ \ \ \ \ \textcolor{keywordtype}{char}\ *s\ =\ NULL;}
\DoxyCodeLine{00162\ }
\DoxyCodeLine{00163\ \ \ \ \ \textcolor{keywordflow}{if}((r\ =\ ((oprx\ \&\ 0x00F0)\ >>4))\ >\ GRSIZE\ -\/\ 1)\ \{}
\DoxyCodeLine{00164\ \ \ \ \ \ \ \ \ setcerr(205,\ s\ =\ pr2str(sys-\/>cpu-\/>pr));\ \ \ \ \textcolor{comment}{/*\ r/r1\ in\ word\ \#1\ -\/\ not\ GR\ */}}
\DoxyCodeLine{00165\ \ \ \ \ \ \ \ \ FREE(s);}
\DoxyCodeLine{00166\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0x0;}
\DoxyCodeLine{00167\ \ \ \ \ \}}
\DoxyCodeLine{00168\ \ \ \ \ \textcolor{keywordflow}{return}\ r;}
\DoxyCodeLine{00169\ \}}
\DoxyCodeLine{00170\ }
\DoxyCodeLine{00171\ WORD\ get\_x\_r2(WORD\ oprx)}
\DoxyCodeLine{00172\ \{}
\DoxyCodeLine{00173\ \ \ \ \ WORD\ x\ =\ 0;}
\DoxyCodeLine{00174\ \ \ \ \ \textcolor{keywordtype}{char}\ *s\ =\ NULL;}
\DoxyCodeLine{00175\ }
\DoxyCodeLine{00176\ \ \ \ \ \textcolor{keywordflow}{if}((x\ =\ (oprx\ \&\ 0x000F))\ >\ GRSIZE\ -\/\ 1)\ \{}
\DoxyCodeLine{00177\ \ \ \ \ \ \ \ \ setcerr(206,\ s\ =\ pr2str(sys-\/>cpu-\/>pr));\ \ \ \ \textcolor{comment}{/*\ r/r1\ in\ word\ \#1\ -\/\ not\ GR\ */}}
\DoxyCodeLine{00178\ \ \ \ \ \ \ \ \ FREE(s);}
\DoxyCodeLine{00179\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0x0;}
\DoxyCodeLine{00180\ \ \ \ \ \}}
\DoxyCodeLine{00181\ \ \ \ \ \textcolor{keywordflow}{return}\ x;}
\DoxyCodeLine{00182\ \}}
\DoxyCodeLine{00183\ }
\DoxyCodeLine{00184\ WORD\ get\_adr\_x(WORD\ adr,\ WORD\ oprx)}
\DoxyCodeLine{00185\ \{}
\DoxyCodeLine{00186\ \ \ \ \ WORD\ a\ =\ adr;}
\DoxyCodeLine{00187\ \ \ \ \ WORD\ x\ =\ get\_x\_r2(oprx);}
\DoxyCodeLine{00188\ }
\DoxyCodeLine{00189\ \ \ \ \ \textcolor{keywordflow}{if}(x\ >\ 0)\ \{}
\DoxyCodeLine{00190\ \ \ \ \ \ \ \ \ a\ +=\ sys-\/>cpu-\/>gr[x];}
\DoxyCodeLine{00191\ \ \ \ \ \}}
\DoxyCodeLine{00192\ \ \ \ \ \textcolor{keywordflow}{return}\ a;}
\DoxyCodeLine{00193\ \}}
\DoxyCodeLine{00194\ }
\DoxyCodeLine{00195\ WORD\ get\_val\_adr\_x(WORD\ adr,\ WORD\ oprx)}
\DoxyCodeLine{00196\ \{}
\DoxyCodeLine{00197\ \ \ \ \ WORD\ a\ =\ 0;}
\DoxyCodeLine{00198\ \ \ \ \ \textcolor{keywordtype}{char}\ *s\ =\ NULL;}
\DoxyCodeLine{00199\ }
\DoxyCodeLine{00200\ \ \ \ \ \textcolor{keywordflow}{if}((a\ =\ get\_adr\_x(adr,\ oprx))\ >=\ sys-\/>memsize)\ \{}
\DoxyCodeLine{00201\ \ \ \ \ \ \ \ \ setcerr(207,\ s\ =\ pr2str(sys-\/>cpu-\/>pr\ +\ 1));\ \ \ \ \textcolor{comment}{/*\ address\ in\ word\ \#2\ -\/\ out\ of\ memory\ */}}
\DoxyCodeLine{00202\ \ \ \ \ \ \ \ \ FREE(s);}
\DoxyCodeLine{00203\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0x0;}
\DoxyCodeLine{00204\ \ \ \ \ \}}
\DoxyCodeLine{00205\ \ \ \ \ \textcolor{keywordflow}{return}\ sys-\/>memory[a];}
\DoxyCodeLine{00206\ \}}
\DoxyCodeLine{00207\ }
\DoxyCodeLine{00208\ \textcolor{comment}{/*\ exec.hで定義された関数群\ */}}
\DoxyCodeLine{00209\ \textcolor{keywordtype}{void}\ addcerrlist\_exec()}
\DoxyCodeLine{00210\ \{}
\DoxyCodeLine{00211\ \ \ \ \ addcerrlist(ARRAYSIZE(cerr\_exec),\ cerr\_exec);}
\DoxyCodeLine{00212\ \}}
\DoxyCodeLine{00213\ }
\DoxyCodeLine{00214\ \textcolor{keywordtype}{void}\ nop()}
\DoxyCodeLine{00215\ \{}
\DoxyCodeLine{00216\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 1;}
\DoxyCodeLine{00217\ \}}
\DoxyCodeLine{00218\ }
\DoxyCodeLine{00219\ \textcolor{keywordtype}{void}\ ld\_r\_adr\_x()}
\DoxyCodeLine{00220\ \{}
\DoxyCodeLine{00221\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00222\ \ \ \ \ setfr(sys-\/>cpu-\/>gr[get\_r\_r1(w[0])]\ =\ get\_val\_adr\_x(w[1],\ w[0]));}
\DoxyCodeLine{00223\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00224\ \}}
\DoxyCodeLine{00225\ }
\DoxyCodeLine{00226\ \textcolor{keywordtype}{void}\ ld\_r1\_r2()}
\DoxyCodeLine{00227\ \{}
\DoxyCodeLine{00228\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr]\};}
\DoxyCodeLine{00229\ \ \ \ \ setfr(sys-\/>cpu-\/>gr[get\_r\_r1(w[0])]\ =\ sys-\/>cpu-\/>gr[get\_x\_r2(w[0])]);}
\DoxyCodeLine{00230\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 1;}
\DoxyCodeLine{00231\ \}}
\DoxyCodeLine{00232\ }
\DoxyCodeLine{00233\ \textcolor{keywordtype}{void}\ st()}
\DoxyCodeLine{00234\ \{}
\DoxyCodeLine{00235\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00236\ \ \ \ \ sys-\/>memory[get\_adr\_x(w[1],\ w[0])]\ =\ sys-\/>cpu-\/>gr[get\_r\_r1(w[0])];}
\DoxyCodeLine{00237\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00238\ \}}
\DoxyCodeLine{00239\ }
\DoxyCodeLine{00240\ \textcolor{keywordtype}{void}\ lad()}
\DoxyCodeLine{00241\ \{}
\DoxyCodeLine{00242\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00243\ \ \ \ \ sys-\/>cpu-\/>gr[get\_r\_r1(w[0])]\ =\ get\_adr\_x(w[1],\ w[0]);}
\DoxyCodeLine{00244\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00245\ \}}
\DoxyCodeLine{00246\ }
\DoxyCodeLine{00247\ \textcolor{keywordtype}{void}\ adda(WORD\ r,\ WORD\ val)}
\DoxyCodeLine{00248\ \{}
\DoxyCodeLine{00249\ \ \ \ \ \textcolor{keywordtype}{long}\ tmp;}
\DoxyCodeLine{00250\ }
\DoxyCodeLine{00251\ \ \ \ \ sys-\/>cpu-\/>fr\ =\ 0x0;}
\DoxyCodeLine{00252\ \ \ \ \ \textcolor{comment}{/*\ 引数の値を16ビット符号付整数として加算し、オーバーフローをチェック\ */}}
\DoxyCodeLine{00253\ \ \ \ \ assert(\textcolor{keyword}{sizeof}(\textcolor{keywordtype}{short})\ *\ 8\ ==\ 16\ \&\&\ (\textcolor{keywordtype}{short})0xFFFF\ ==\ -\/1);}
\DoxyCodeLine{00254\ \ \ \ \ \textcolor{keywordflow}{if}((tmp\ =\ (\textcolor{keywordtype}{short})(sys-\/>cpu-\/>gr[r])\ +\ (\textcolor{keywordtype}{short})val)\ >\ 32767\ ||\ tmp\ <\ -\/32768)\ \{}
\DoxyCodeLine{00255\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ OF;}
\DoxyCodeLine{00256\ \ \ \ \ \}}
\DoxyCodeLine{00257\ \ \ \ \ \textcolor{comment}{/*\ 加算した結果を、WORD値に戻す\ */}}
\DoxyCodeLine{00258\ \ \ \ \ sys-\/>cpu-\/>gr[r]\ =\ (WORD)(tmp\ \&\ 0xFFFF);}
\DoxyCodeLine{00259\ \ \ \ \ \textcolor{keywordflow}{if}((sys-\/>cpu-\/>gr[r]\ \&\ 0x8000)\ ==\ 0x8000)\ \{}
\DoxyCodeLine{00260\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ SF;}
\DoxyCodeLine{00261\ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}(sys-\/>cpu-\/>gr[r]\ ==\ 0x0)\ \{}
\DoxyCodeLine{00262\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ ZF;}
\DoxyCodeLine{00263\ \ \ \ \ \}}
\DoxyCodeLine{00264\ \}}
\DoxyCodeLine{00265\ }
\DoxyCodeLine{00266\ \textcolor{keywordtype}{void}\ adda\_r\_adr\_x()}
\DoxyCodeLine{00267\ \{}
\DoxyCodeLine{00268\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00269\ \ \ \ \ adda(get\_r\_r1(w[0]),\ get\_val\_adr\_x(w[1],\ w[0]));}
\DoxyCodeLine{00270\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00271\ \}}
\DoxyCodeLine{00272\ }
\DoxyCodeLine{00273\ \textcolor{keywordtype}{void}\ adda\_r1\_r2()}
\DoxyCodeLine{00274\ \{}
\DoxyCodeLine{00275\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr]\};}
\DoxyCodeLine{00276\ \ \ \ \ adda(get\_r\_r1(w[0]),\ sys-\/>cpu-\/>gr[get\_x\_r2(w[0])]);}
\DoxyCodeLine{00277\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 1;}
\DoxyCodeLine{00278\ \}}
\DoxyCodeLine{00279\ }
\DoxyCodeLine{00280\ \textcolor{keywordtype}{void}\ suba\_r\_adr\_x()}
\DoxyCodeLine{00281\ \{}
\DoxyCodeLine{00282\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00283\ \ \ \ \ adda(get\_r\_r1(w[0]),\ \string~(get\_val\_adr\_x(w[1],\ w[0]))\ +\ 1);}
\DoxyCodeLine{00284\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00285\ \}}
\DoxyCodeLine{00286\ }
\DoxyCodeLine{00287\ \textcolor{keywordtype}{void}\ suba\_r1\_r2()}
\DoxyCodeLine{00288\ \{}
\DoxyCodeLine{00289\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr]\};}
\DoxyCodeLine{00290\ \ \ \ \ adda(get\_r\_r1(w[0]),\ \string~(sys-\/>cpu-\/>gr[get\_x\_r2(w[0])])\ +\ 1);}
\DoxyCodeLine{00291\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 1;}
\DoxyCodeLine{00292\ \}}
\DoxyCodeLine{00293\ }
\DoxyCodeLine{00294\ \textcolor{keywordtype}{void}\ addl\_gr(WORD\ r,\ WORD\ val,\ \textcolor{keywordtype}{bool}\ add)}
\DoxyCodeLine{00295\ \{}
\DoxyCodeLine{00296\ \ \ \ \ \textcolor{keywordtype}{unsigned}\ \textcolor{keywordtype}{long}\ o\ =\ 0;}
\DoxyCodeLine{00297\ \ \ \ \ \textcolor{keywordtype}{unsigned}\ \textcolor{keywordtype}{long}\ s\ =\ 0;}
\DoxyCodeLine{00298\ }
\DoxyCodeLine{00299\ \ \ \ \ o\ =\ sys-\/>cpu-\/>gr[r];}
\DoxyCodeLine{00300\ \ \ \ \ sys-\/>cpu-\/>fr\ =\ 0;\ \ \ \ \textcolor{comment}{/*\ flag\ initialize\ */}}
\DoxyCodeLine{00301\ }
\DoxyCodeLine{00302\ \ \ \ \ \textcolor{keywordflow}{if}(add\ ==\ \textcolor{keyword}{true})\ \{}
\DoxyCodeLine{00303\ \ \ \ \ \ \ \ \ s\ =\ o\ +\ val;}
\DoxyCodeLine{00304\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(s\ >\ 0xFFFF)\ \{}
\DoxyCodeLine{00305\ \ \ \ \ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ OF;}
\DoxyCodeLine{00306\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00307\ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00308\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(o\ <\ val)\ \{}
\DoxyCodeLine{00309\ \ \ \ \ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ OF;}
\DoxyCodeLine{00310\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00311\ \ \ \ \ \ \ \ \ s\ =\ o\ +\ (\string~val\ +\ 1);}
\DoxyCodeLine{00312\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(s\ >\ 0xFFFF)\ \{}
\DoxyCodeLine{00313\ \ \ \ \ \ \ \ \ \ \ \ \ s\ \&=\ 0xFFFF;}
\DoxyCodeLine{00314\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00315\ \ \ \ \ \}}
\DoxyCodeLine{00316\ \ \ \ \ sys-\/>cpu-\/>gr[r]\ =\ (WORD)s;}
\DoxyCodeLine{00317\ }
\DoxyCodeLine{00318\ \ \ \ \ \textcolor{keywordflow}{if}((s\ \&\ 0x8000)\ ==\ 0x8000)\ \{}
\DoxyCodeLine{00319\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ SF;}
\DoxyCodeLine{00320\ \ \ \ \ \}}
\DoxyCodeLine{00321\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}(s\ ==\ 0x0)\ \{}
\DoxyCodeLine{00322\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ ZF;}
\DoxyCodeLine{00323\ \ \ \ \ \}}
\DoxyCodeLine{00324\ \}}
\DoxyCodeLine{00325\ }
\DoxyCodeLine{00326\ \textcolor{keywordtype}{void}\ addl\_r\_adr\_x()}
\DoxyCodeLine{00327\ \{}
\DoxyCodeLine{00328\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00329\ \ \ \ \ addl\_gr(get\_r\_r1(w[0]),\ get\_val\_adr\_x(w[1],\ w[0]),\ \textcolor{keyword}{true});}
\DoxyCodeLine{00330\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00331\ \}}
\DoxyCodeLine{00332\ }
\DoxyCodeLine{00333\ \textcolor{keywordtype}{void}\ addl\_r1\_r2()}
\DoxyCodeLine{00334\ \{}
\DoxyCodeLine{00335\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr]\};}
\DoxyCodeLine{00336\ \ \ \ \ addl\_gr(get\_r\_r1(w[0]),\ sys-\/>cpu-\/>gr[get\_x\_r2(w[0])],\ \textcolor{keyword}{true});}
\DoxyCodeLine{00337\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 1;}
\DoxyCodeLine{00338\ \}}
\DoxyCodeLine{00339\ }
\DoxyCodeLine{00340\ \textcolor{keywordtype}{void}\ subl\_r\_adr\_x()}
\DoxyCodeLine{00341\ \{}
\DoxyCodeLine{00342\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00343\ \ \ \ \ addl\_gr(get\_r\_r1(w[0]),\ get\_val\_adr\_x(w[1],\ w[0]),\ \textcolor{keyword}{false});}
\DoxyCodeLine{00344\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00345\ \}}
\DoxyCodeLine{00346\ }
\DoxyCodeLine{00347\ \textcolor{keywordtype}{void}\ subl\_r1\_r2()}
\DoxyCodeLine{00348\ \{}
\DoxyCodeLine{00349\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr]\};}
\DoxyCodeLine{00350\ \ \ \ \ addl\_gr(get\_r\_r1(w[0]),\ sys-\/>cpu-\/>gr[get\_x\_r2(w[0])],\ \textcolor{keyword}{false});}
\DoxyCodeLine{00351\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 1;}
\DoxyCodeLine{00352\ \}}
\DoxyCodeLine{00353\ }
\DoxyCodeLine{00354\ \textcolor{keywordtype}{void}\ and\_r\_adr\_x()}
\DoxyCodeLine{00355\ \{}
\DoxyCodeLine{00356\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00357\ \ \ \ \ setfr(sys-\/>cpu-\/>gr[get\_r\_r1(w[0])]\ \&=\ get\_val\_adr\_x(w[1],\ w[0]));}
\DoxyCodeLine{00358\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00359\ \}}
\DoxyCodeLine{00360\ }
\DoxyCodeLine{00361\ \textcolor{keywordtype}{void}\ and\_r1\_r2()}
\DoxyCodeLine{00362\ \{}
\DoxyCodeLine{00363\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr]\};}
\DoxyCodeLine{00364\ \ \ \ \ setfr(sys-\/>cpu-\/>gr[get\_r\_r1(w[0])]\ \&=\ sys-\/>cpu-\/>gr[get\_x\_r2(w[0])]);}
\DoxyCodeLine{00365\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 1;}
\DoxyCodeLine{00366\ \}}
\DoxyCodeLine{00367\ }
\DoxyCodeLine{00368\ \textcolor{keywordtype}{void}\ or\_r\_adr\_x()}
\DoxyCodeLine{00369\ \{}
\DoxyCodeLine{00370\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00371\ \ \ \ \ setfr(sys-\/>cpu-\/>gr[get\_r\_r1(w[0])]\ |=\ get\_val\_adr\_x(w[1],\ w[0]));}
\DoxyCodeLine{00372\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00373\ \}}
\DoxyCodeLine{00374\ }
\DoxyCodeLine{00375\ \textcolor{keywordtype}{void}\ or\_r1\_r2()}
\DoxyCodeLine{00376\ \{}
\DoxyCodeLine{00377\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr]\};}
\DoxyCodeLine{00378\ \ \ \ \ setfr(sys-\/>cpu-\/>gr[get\_r\_r1(w[0])]\ |=\ sys-\/>cpu-\/>gr[get\_x\_r2(w[0])]);}
\DoxyCodeLine{00379\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 1;}
\DoxyCodeLine{00380\ \}}
\DoxyCodeLine{00381\ }
\DoxyCodeLine{00382\ \textcolor{keywordtype}{void}\ xor\_r\_adr\_x()}
\DoxyCodeLine{00383\ \{}
\DoxyCodeLine{00384\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00385\ \ \ \ \ setfr(sys-\/>cpu-\/>gr[get\_r\_r1(w[0])]\ \string^=\ get\_val\_adr\_x(w[1],\ w[0]));}
\DoxyCodeLine{00386\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00387\ \}}
\DoxyCodeLine{00388\ }
\DoxyCodeLine{00389\ \textcolor{keywordtype}{void}\ xor\_r1\_r2()}
\DoxyCodeLine{00390\ \{}
\DoxyCodeLine{00391\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr]\};}
\DoxyCodeLine{00392\ \ \ \ \ setfr(sys-\/>cpu-\/>gr[get\_r\_r1(w[0])]\ \string^=\ sys-\/>cpu-\/>gr[get\_x\_r2(w[0])]);}
\DoxyCodeLine{00393\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 1;}
\DoxyCodeLine{00394\ \}}
\DoxyCodeLine{00395\ }
\DoxyCodeLine{00396\ \textcolor{keywordtype}{void}\ cpa(WORD\ r,\ WORD\ val)}
\DoxyCodeLine{00397\ \{}
\DoxyCodeLine{00398\ \ \ \ \ sys-\/>cpu-\/>fr\ =\ 0;}
\DoxyCodeLine{00399\ \ \ \ \ \textcolor{keywordflow}{if}((\textcolor{keywordtype}{short})sys-\/>cpu-\/>gr[r]\ <\ (\textcolor{keywordtype}{short})val)\ \{}
\DoxyCodeLine{00400\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ =\ SF;}
\DoxyCodeLine{00401\ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}(sys-\/>cpu-\/>gr[r]\ ==\ val)\ \{}
\DoxyCodeLine{00402\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ =\ ZF;}
\DoxyCodeLine{00403\ \ \ \ \ \}}
\DoxyCodeLine{00404\ \}}
\DoxyCodeLine{00405\ }
\DoxyCodeLine{00406\ \textcolor{keywordtype}{void}\ cpa\_r\_adr\_x()}
\DoxyCodeLine{00407\ \{}
\DoxyCodeLine{00408\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00409\ \ \ \ \ cpa(get\_r\_r1(w[0]),\ get\_val\_adr\_x(w[1],\ w[0]));}
\DoxyCodeLine{00410\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00411\ \}}
\DoxyCodeLine{00412\ }
\DoxyCodeLine{00413\ \textcolor{keywordtype}{void}\ cpa\_r1\_r2()}
\DoxyCodeLine{00414\ \{}
\DoxyCodeLine{00415\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr]\};}
\DoxyCodeLine{00416\ \ \ \ \ cpa(get\_r\_r1(w[0]),\ sys-\/>cpu-\/>gr[get\_x\_r2(w[0])]);}
\DoxyCodeLine{00417\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 1;}
\DoxyCodeLine{00418\ \}}
\DoxyCodeLine{00419\ }
\DoxyCodeLine{00420\ \textcolor{keywordtype}{void}\ cpl(WORD\ r,\ WORD\ val)}
\DoxyCodeLine{00421\ \{}
\DoxyCodeLine{00422\ \ \ \ \ sys-\/>cpu-\/>fr\ =\ 0x0;}
\DoxyCodeLine{00423\ \ \ \ \ \textcolor{keywordflow}{if}(sys-\/>cpu-\/>gr[r]\ <\ val)\ \{}
\DoxyCodeLine{00424\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ =\ SF;}
\DoxyCodeLine{00425\ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}(sys-\/>cpu-\/>gr[r]\ ==\ val)\ \{}
\DoxyCodeLine{00426\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ =\ ZF;}
\DoxyCodeLine{00427\ \ \ \ \ \}}
\DoxyCodeLine{00428\ \}}
\DoxyCodeLine{00429\ }
\DoxyCodeLine{00430\ \textcolor{keywordtype}{void}\ cpl\_r\_adr\_x()}
\DoxyCodeLine{00431\ \{}
\DoxyCodeLine{00432\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00433\ \ \ \ \ cpl(get\_r\_r1(w[0]),\ get\_val\_adr\_x(w[1],\ w[0]));}
\DoxyCodeLine{00434\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00435\ \}}
\DoxyCodeLine{00436\ }
\DoxyCodeLine{00437\ \textcolor{keywordtype}{void}\ cpl\_r1\_r2()}
\DoxyCodeLine{00438\ \{}
\DoxyCodeLine{00439\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr]\};}
\DoxyCodeLine{00440\ \ \ \ \ cpl(get\_r\_r1(w[0]),\ sys-\/>cpu-\/>gr[get\_x\_r2(w[0])]);}
\DoxyCodeLine{00441\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 1;}
\DoxyCodeLine{00442\ \}}
\DoxyCodeLine{00443\ }
\DoxyCodeLine{00444\ \textcolor{keywordtype}{void}\ sla()}
\DoxyCodeLine{00445\ \{}
\DoxyCodeLine{00446\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00447\ \ \ \ \ WORD\ r\ =\ get\_r\_r1(w[0]);}
\DoxyCodeLine{00448\ \ \ \ \ WORD\ sign\ =\ sys-\/>cpu-\/>gr[r]\ \&\ 0x8000;}
\DoxyCodeLine{00449\ \ \ \ \ WORD\ last\ =\ 0;}
\DoxyCodeLine{00450\ }
\DoxyCodeLine{00451\ \ \ \ \ sys-\/>cpu-\/>fr\ =\ 0;}
\DoxyCodeLine{00452\ \ \ \ \ sys-\/>cpu-\/>gr[r]\ \&=\ 0x7FFF;}
\DoxyCodeLine{00453\ \ \ \ \ \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ get\_adr\_x(w[1],\ w[0]);\ i++)\ \{}
\DoxyCodeLine{00454\ \ \ \ \ \ \ \ \ last\ =\ sys-\/>cpu-\/>gr[r]\ \&\ 0x4000;}
\DoxyCodeLine{00455\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>gr[r]\ <<=\ 1;}
\DoxyCodeLine{00456\ \ \ \ \ \}}
\DoxyCodeLine{00457\ \ \ \ \ sys-\/>cpu-\/>gr[r]\ =\ sign\ |\ (sys-\/>cpu-\/>gr[r]\ \&\ 0x7FFF);}
\DoxyCodeLine{00458\ \ \ \ \ \textcolor{comment}{/*\ OFに、レジスタから最後に送り出されたビットの値を設定\ */}}
\DoxyCodeLine{00459\ \ \ \ \ \textcolor{keywordflow}{if}(last\ >\ 0x0)\ \{}
\DoxyCodeLine{00460\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ OF;}
\DoxyCodeLine{00461\ \ \ \ \ \}}
\DoxyCodeLine{00462\ \ \ \ \ \textcolor{comment}{/*\ 符号(第15ビット)が1のとき、SFは1\ */}}
\DoxyCodeLine{00463\ \ \ \ \ \textcolor{keywordflow}{if}(sign\ >\ 0x0)\ \{}
\DoxyCodeLine{00464\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ SF;}
\DoxyCodeLine{00465\ \ \ \ \ \}}
\DoxyCodeLine{00466\ \ \ \ \ \textcolor{comment}{/*\ 演算結果が0のとき、ZFは1\ */}}
\DoxyCodeLine{00467\ \ \ \ \ \textcolor{keywordflow}{if}(sys-\/>cpu-\/>gr[r]\ ==\ 0x0)\ \{}
\DoxyCodeLine{00468\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ ZF;}
\DoxyCodeLine{00469\ \ \ \ \ \}}
\DoxyCodeLine{00470\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00471\ \}}
\DoxyCodeLine{00472\ }
\DoxyCodeLine{00473\ \textcolor{keywordtype}{void}\ sra()}
\DoxyCodeLine{00474\ \{}
\DoxyCodeLine{00475\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00476\ \ \ \ \ WORD\ r\ =\ get\_r\_r1(w[0]);}
\DoxyCodeLine{00477\ \ \ \ \ WORD\ sign\ =\ sys-\/>cpu-\/>gr[r]\ \&\ 0x8000;}
\DoxyCodeLine{00478\ \ \ \ \ WORD\ last\ =\ 0;}
\DoxyCodeLine{00479\ }
\DoxyCodeLine{00480\ \ \ \ \ sys-\/>cpu-\/>fr\ =\ 0;}
\DoxyCodeLine{00481\ \ \ \ \ sys-\/>cpu-\/>gr[r]\ \&=\ 0x7FFF;}
\DoxyCodeLine{00482\ \ \ \ \ \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ get\_adr\_x(w[1],\ w[0]);\ i++)\ \{}
\DoxyCodeLine{00483\ \ \ \ \ \ \ \ \ last\ =\ sys-\/>cpu-\/>gr[r]\ \&\ 0x1;}
\DoxyCodeLine{00484\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>gr[r]\ >>=\ 1;}
\DoxyCodeLine{00485\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(sign\ >\ 0)\ \{}
\DoxyCodeLine{00486\ \ \ \ \ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>gr[r]\ |=\ 0x4000;}
\DoxyCodeLine{00487\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00488\ \ \ \ \ \}}
\DoxyCodeLine{00489\ \ \ \ \ sys-\/>cpu-\/>gr[r]\ =\ sign\ |\ sys-\/>cpu-\/>gr[r];}
\DoxyCodeLine{00490\ \ \ \ \ \textcolor{comment}{/*\ OFに、レジスタから最後に送り出されたビットの値を設定\ */}}
\DoxyCodeLine{00491\ \ \ \ \ \textcolor{keywordflow}{if}(last\ >\ 0x0)\ \{}
\DoxyCodeLine{00492\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ OF;}
\DoxyCodeLine{00493\ \ \ \ \ \}}
\DoxyCodeLine{00494\ \ \ \ \ \textcolor{comment}{/*\ 符号(第15ビット)が1のとき、SFは1\ */}}
\DoxyCodeLine{00495\ \ \ \ \ \textcolor{keywordflow}{if}(sign\ >\ 0x0)\ \{}
\DoxyCodeLine{00496\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ SF;}
\DoxyCodeLine{00497\ \ \ \ \ \}}
\DoxyCodeLine{00498\ \ \ \ \ \textcolor{comment}{/*\ 演算結果が0のとき、ZFは1\ */}}
\DoxyCodeLine{00499\ \ \ \ \ \textcolor{keywordflow}{if}(sys-\/>cpu-\/>gr[r]\ ==\ 0x0)\ \{}
\DoxyCodeLine{00500\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ ZF;}
\DoxyCodeLine{00501\ \ \ \ \ \}}
\DoxyCodeLine{00502\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00503\ \}}
\DoxyCodeLine{00504\ }
\DoxyCodeLine{00505\ \textcolor{keywordtype}{void}\ sll()}
\DoxyCodeLine{00506\ \{}
\DoxyCodeLine{00507\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00508\ \ \ \ \ WORD\ last\ =\ 0;}
\DoxyCodeLine{00509\ \ \ \ \ WORD\ r\ =\ get\_r\_r1(w[0]);}
\DoxyCodeLine{00510\ }
\DoxyCodeLine{00511\ \ \ \ \ sys-\/>cpu-\/>fr\ =\ 0x0;}
\DoxyCodeLine{00512\ \ \ \ \ \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ get\_adr\_x(w[1],\ w[0]);\ i++)\ \{}
\DoxyCodeLine{00513\ \ \ \ \ \ \ \ \ last\ =\ sys-\/>cpu-\/>gr[r]\ \&\ 0x8000;}
\DoxyCodeLine{00514\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>gr[r]\ <<=\ 1;}
\DoxyCodeLine{00515\ \ \ \ \ \}}
\DoxyCodeLine{00516\ \ \ \ \ \textcolor{comment}{/*\ OFに、レジスタから最後に送り出されたビットの値を設定\ */}}
\DoxyCodeLine{00517\ \ \ \ \ \textcolor{keywordflow}{if}(last\ >\ 0x0)\ \{}
\DoxyCodeLine{00518\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ OF;}
\DoxyCodeLine{00519\ \ \ \ \ \}}
\DoxyCodeLine{00520\ \ \ \ \ \textcolor{comment}{/*\ 第15ビットが1のとき、SFは1\ */}}
\DoxyCodeLine{00521\ \ \ \ \ \textcolor{keywordflow}{if}((sys-\/>cpu-\/>gr[r]\ \&\ 0x8000)\ >\ 0x0)\ \{}
\DoxyCodeLine{00522\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ SF;}
\DoxyCodeLine{00523\ \ \ \ \ \}}
\DoxyCodeLine{00524\ \ \ \ \ \textcolor{comment}{/*\ 演算結果が0のとき、ZFは1\ */}}
\DoxyCodeLine{00525\ \ \ \ \ \textcolor{keywordflow}{if}(sys-\/>cpu-\/>gr[r]\ ==\ 0x0)\ \{}
\DoxyCodeLine{00526\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ ZF;}
\DoxyCodeLine{00527\ \ \ \ \ \}}
\DoxyCodeLine{00528\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00529\ \}}
\DoxyCodeLine{00530\ }
\DoxyCodeLine{00531\ \textcolor{keywordtype}{void}\ srl()}
\DoxyCodeLine{00532\ \{}
\DoxyCodeLine{00533\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00534\ \ \ \ \ WORD\ last\ =\ 0;}
\DoxyCodeLine{00535\ \ \ \ \ WORD\ r\ =\ get\_r\_r1(w[0]);}
\DoxyCodeLine{00536\ }
\DoxyCodeLine{00537\ \ \ \ \ sys-\/>cpu-\/>fr\ =\ 0x0;}
\DoxyCodeLine{00538\ \ \ \ \ \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ get\_adr\_x(w[1],\ w[0]);\ i++)\ \{}
\DoxyCodeLine{00539\ \ \ \ \ \ \ \ \ last\ =\ sys-\/>cpu-\/>gr[r]\ \&\ 0x0001;}
\DoxyCodeLine{00540\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>gr[r]\ >>=\ 1;}
\DoxyCodeLine{00541\ \ \ \ \ \}}
\DoxyCodeLine{00542\ \ \ \ \ \textcolor{comment}{/*\ OFに、レジスタから最後に送り出されたビットの値を設定\ */}}
\DoxyCodeLine{00543\ \ \ \ \ \textcolor{keywordflow}{if}(last\ >\ 0x0)\ \{}
\DoxyCodeLine{00544\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ OF;}
\DoxyCodeLine{00545\ \ \ \ \ \}}
\DoxyCodeLine{00546\ \ \ \ \ \textcolor{comment}{/*\ 第15ビットが1のとき、SFは1\ */}}
\DoxyCodeLine{00547\ \ \ \ \ \textcolor{keywordflow}{if}((sys-\/>cpu-\/>gr[r]\ \&\ 0x8000)\ >\ 0x0)\ \{}
\DoxyCodeLine{00548\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ SF;}
\DoxyCodeLine{00549\ \ \ \ \ \}}
\DoxyCodeLine{00550\ \ \ \ \ \textcolor{comment}{/*\ 演算結果が0のとき、ZFは1\ */}}
\DoxyCodeLine{00551\ \ \ \ \ \textcolor{keywordflow}{if}(sys-\/>cpu-\/>gr[r]\ ==\ 0x0)\ \{}
\DoxyCodeLine{00552\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>fr\ +=\ ZF;}
\DoxyCodeLine{00553\ \ \ \ \ \}}
\DoxyCodeLine{00554\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00555\ \}}
\DoxyCodeLine{00556\ }
\DoxyCodeLine{00557\ \textcolor{keywordtype}{void}\ jpl()}
\DoxyCodeLine{00558\ \{}
\DoxyCodeLine{00559\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00560\ \ \ \ \ \textcolor{keywordflow}{if}((sys-\/>cpu-\/>fr\ \&\ (SF\ |\ ZF))\ ==\ 0)\ \{}
\DoxyCodeLine{00561\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>pr\ =\ get\_adr\_x(w[1],\ w[0]);}
\DoxyCodeLine{00562\ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00563\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00564\ \ \ \ \ \}}
\DoxyCodeLine{00565\ \}}
\DoxyCodeLine{00566\ }
\DoxyCodeLine{00567\ \textcolor{keywordtype}{void}\ jmi()}
\DoxyCodeLine{00568\ \{}
\DoxyCodeLine{00569\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00570\ \ \ \ \ \textcolor{keywordflow}{if}((sys-\/>cpu-\/>fr\ \&\ SF)\ >\ 0)\ \{}
\DoxyCodeLine{00571\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>pr\ =\ get\_adr\_x(w[1],\ w[0]);}
\DoxyCodeLine{00572\ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00573\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00574\ \ \ \ \ \}}
\DoxyCodeLine{00575\ \}}
\DoxyCodeLine{00576\ }
\DoxyCodeLine{00577\ \textcolor{keywordtype}{void}\ jnz()}
\DoxyCodeLine{00578\ \{}
\DoxyCodeLine{00579\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00580\ \ \ \ \ \textcolor{keywordflow}{if}((sys-\/>cpu-\/>fr\ \&\ ZF)\ ==\ 0)\ \{}
\DoxyCodeLine{00581\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>pr\ =\ get\_adr\_x(w[1],\ w[0]);}
\DoxyCodeLine{00582\ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00583\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00584\ \ \ \ \ \}}
\DoxyCodeLine{00585\ \}}
\DoxyCodeLine{00586\ }
\DoxyCodeLine{00587\ \textcolor{keywordtype}{void}\ jze()}
\DoxyCodeLine{00588\ \{}
\DoxyCodeLine{00589\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00590\ \ \ \ \ \textcolor{keywordflow}{if}((sys-\/>cpu-\/>fr\ \&\ ZF)\ >\ 0)\ \{}
\DoxyCodeLine{00591\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>pr\ =\ get\_adr\_x(w[1],\ w[0]);}
\DoxyCodeLine{00592\ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00593\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00594\ \ \ \ \ \}}
\DoxyCodeLine{00595\ \}}
\DoxyCodeLine{00596\ }
\DoxyCodeLine{00597\ \textcolor{keywordtype}{void}\ jov()}
\DoxyCodeLine{00598\ \{}
\DoxyCodeLine{00599\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00600\ \ \ \ \ \textcolor{keywordflow}{if}((sys-\/>cpu-\/>fr\ \&\ OF)\ >\ 0)\ \{}
\DoxyCodeLine{00601\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>pr\ =\ get\_adr\_x(w[1],\ w[0]);}
\DoxyCodeLine{00602\ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00603\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00604\ \ \ \ \ \}}
\DoxyCodeLine{00605\ \}}
\DoxyCodeLine{00606\ }
\DoxyCodeLine{00607\ \textcolor{keywordtype}{void}\ jump()}
\DoxyCodeLine{00608\ \{}
\DoxyCodeLine{00609\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00610\ \ \ \ \ sys-\/>cpu-\/>pr\ =\ get\_adr\_x(w[1],\ w[0]);}
\DoxyCodeLine{00611\ \}}
\DoxyCodeLine{00612\ }
\DoxyCodeLine{00613\ \textcolor{keywordtype}{void}\ push()}
\DoxyCodeLine{00614\ \{}
\DoxyCodeLine{00615\ \ \ \ \ assert(sys-\/>cpu-\/>sp\ >\ execptr-\/>end\ \&\&\ sys-\/>cpu-\/>sp\ <=\ sys-\/>memsize);}
\DoxyCodeLine{00616\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00617\ \ \ \ \ sys-\/>memory[-\/-\/(sys-\/>cpu-\/>sp)]\ =\ get\_adr\_x(w[1],\ w[0]);}
\DoxyCodeLine{00618\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00619\ \}}
\DoxyCodeLine{00620\ }
\DoxyCodeLine{00621\ \textcolor{keywordtype}{void}\ pop()}
\DoxyCodeLine{00622\ \{}
\DoxyCodeLine{00623\ \ \ \ \ assert(sys-\/>cpu-\/>sp\ >\ execptr-\/>end);}
\DoxyCodeLine{00624\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr]\};}
\DoxyCodeLine{00625\ \ \ \ \ \textcolor{keywordtype}{char}\ *s\ =\ NULL;}
\DoxyCodeLine{00626\ }
\DoxyCodeLine{00627\ \ \ \ \ \textcolor{keywordflow}{if}(sys-\/>cpu-\/>sp\ >=\ sys-\/>memsize)\ \{}
\DoxyCodeLine{00628\ \ \ \ \ \ \ \ \ setcerr(203,\ s\ =\ pr2str(sys-\/>cpu-\/>pr));\ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Stack\ Pointer\ (SP)\ -\/\ stack\ underflow\ */}}
\DoxyCodeLine{00629\ \ \ \ \ \ \ \ \ FREE(s);}
\DoxyCodeLine{00630\ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00631\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>gr[get\_r\_r1(w[0])]\ =\ sys-\/>memory[(sys-\/>cpu-\/>sp)++];}
\DoxyCodeLine{00632\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 1;}
\DoxyCodeLine{00633\ \ \ \ \ \}}
\DoxyCodeLine{00634\ \}}
\DoxyCodeLine{00635\ }
\DoxyCodeLine{00636\ \textcolor{keywordtype}{void}\ call()}
\DoxyCodeLine{00637\ \{}
\DoxyCodeLine{00638\ \ \ \ \ assert(sys-\/>cpu-\/>sp\ >\ execptr-\/>end\ \&\&\ sys-\/>cpu-\/>sp\ <=\ sys-\/>memsize);}
\DoxyCodeLine{00639\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00640\ \ \ \ \ sys-\/>memory[-\/-\/(sys-\/>cpu-\/>sp)]\ =\ sys-\/>cpu-\/>pr\ +\ 1;}
\DoxyCodeLine{00641\ \ \ \ \ sys-\/>cpu-\/>pr\ =\ get\_adr\_x(w[1],\ w[0]);}
\DoxyCodeLine{00642\ \}}
\DoxyCodeLine{00643\ }
\DoxyCodeLine{00644\ \textcolor{keywordtype}{void}\ ret()}
\DoxyCodeLine{00645\ \{}
\DoxyCodeLine{00646\ \ \ \ \ assert(sys-\/>cpu-\/>sp\ <=\ sys-\/>memsize);}
\DoxyCodeLine{00647\ \ \ \ \ \textcolor{keywordflow}{if}(sys-\/>cpu-\/>sp\ ==\ sys-\/>memsize)\ \{}
\DoxyCodeLine{00648\ \ \ \ \ \ \ \ \ execptr-\/>stop\ =\ \textcolor{keyword}{true};}
\DoxyCodeLine{00649\ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}(sys-\/>cpu-\/>sp\ <\ sys-\/>memsize)\ \{}
\DoxyCodeLine{00650\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>pr\ =\ sys-\/>memory[(sys-\/>cpu-\/>sp)++]\ +\ 1;}
\DoxyCodeLine{00651\ \ \ \ \ \}}
\DoxyCodeLine{00652\ \}}
\DoxyCodeLine{00653\ }
\DoxyCodeLine{00654\ \textcolor{keywordtype}{void}\ svc()}
\DoxyCodeLine{00655\ \{}
\DoxyCodeLine{00656\ \ \ \ \ WORD\ w[]\ =\ \{sys-\/>memory[sys-\/>cpu-\/>pr],\ sys-\/>memory[sys-\/>cpu-\/>pr\ +\ 1]\};}
\DoxyCodeLine{00657\ \ \ \ \ \textcolor{keywordflow}{switch}(get\_adr\_x(w[1],\ w[0]))}
\DoxyCodeLine{00658\ \ \ \ \ \{}
\DoxyCodeLine{00659\ \ \ \ \ \textcolor{keywordflow}{case}\ 0x0:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ STOP\ */}}
\DoxyCodeLine{00660\ \ \ \ \ \ \ \ \ execptr-\/>stop\ =\ \textcolor{keyword}{true};}
\DoxyCodeLine{00661\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00662\ \ \ \ \ \textcolor{keywordflow}{case}\ 0x1:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ IN\ */}}
\DoxyCodeLine{00663\ \ \ \ \ \ \ \ \ svcin();}
\DoxyCodeLine{00664\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00665\ \ \ \ \ \textcolor{keywordflow}{case}\ 0x2:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ OUT\ */}}
\DoxyCodeLine{00666\ \ \ \ \ \ \ \ \ svcout();}
\DoxyCodeLine{00667\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00668\ \ \ \ \ \}}
\DoxyCodeLine{00669\ \ \ \ \ sys-\/>cpu-\/>pr\ +=\ 2;}
\DoxyCodeLine{00670\ \}}
\DoxyCodeLine{00671\ }
\DoxyCodeLine{00672\ \textcolor{keywordtype}{void}\ exec()}
\DoxyCodeLine{00673\ \{}
\DoxyCodeLine{00674\ \ \ \ \ clock\_t\ clock\_begin\ =\ 0;}
\DoxyCodeLine{00675\ \ \ \ \ clock\_t\ clock\_end\ =\ 0;}
\DoxyCodeLine{00676\ \ \ \ \ void\ (*cmdptr)()\ =\ NULL;}
\DoxyCodeLine{00677\ \ \ \ \ \textcolor{keywordtype}{char}\ *s\ =\ NULL;}
\DoxyCodeLine{00678\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *monmsg\ =\ \textcolor{stringliteral}{"{}COMET\ II\ machine\ code\ monitor.\ Type\ ?\ for\ help.\(\backslash\)n"{}};}
\DoxyCodeLine{00679\ }
\DoxyCodeLine{00680\ \ \ \ \ create\_cmdtable(HASH\_CODE);\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ 命令のコードとタイプがキーのハッシュ表を作成\ */}}
\DoxyCodeLine{00681\ }
\DoxyCodeLine{00682\ \ \ \ \ \textcolor{keywordflow}{if}(execmode.trace\ ==\ \textcolor{keyword}{true})\ \{}
\DoxyCodeLine{00683\ \ \ \ \ \ \ \ \ fprintf(stdout,\ \textcolor{stringliteral}{"{}\(\backslash\)nExecuting\ machine\ codes\(\backslash\)n"{}});}
\DoxyCodeLine{00684\ \ \ \ \ \}}
\DoxyCodeLine{00685\ \ \ \ \ \textcolor{comment}{/*\ 機械語の実行\ */}}
\DoxyCodeLine{00686\ \ \ \ \ \textcolor{keywordflow}{for}\ (sys-\/>cpu-\/>pr\ =\ execptr-\/>start;\ ;\ )\ \{}
\DoxyCodeLine{00687\ \ \ \ \ \ \ \ \ clock\_begin\ =\ clock();\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ クロック周波数設定のため、実行開始時間を格納\ */}}
\DoxyCodeLine{00688\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(execmode.dump\ ||\ execmode.trace)\ \{\ \ \ \ \ \ \textcolor{comment}{/*\ traceまたはdumpオプション指定時、改行を出力\ */}}
\DoxyCodeLine{00689\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(execmode.trace)\ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ traceオプション指定時、レジスタを出力\ */}}
\DoxyCodeLine{00690\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(stdout,\ \textcolor{stringliteral}{"{}\#\%04X:\ Register::::\(\backslash\)n"{}},\ sys-\/>cpu-\/>pr);}
\DoxyCodeLine{00691\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ dspregister();}
\DoxyCodeLine{00692\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00693\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(execmode.dump)\ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ dumpオプション指定時、メモリを出力\ */}}
\DoxyCodeLine{00694\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(stdout,\ \textcolor{stringliteral}{"{}\#\%04X:\ Memory::::\(\backslash\)n"{}},\ sys-\/>cpu-\/>pr);}
\DoxyCodeLine{00695\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ dumpmemory(execmode.dump\_start,\ execmode.dump\_end);}
\DoxyCodeLine{00696\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00697\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(stdout,\ \textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{00698\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00699\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ ステップモードまたはブレークポイントの場合、モニターを起動\ */}}
\DoxyCodeLine{00700\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(}
\DoxyCodeLine{00701\ \ \ \ \ \ \ \ \ \ \ \ \ (execmode.monitor\ ==\ \textcolor{keyword}{true}\ \&\&\ sys-\/>cpu-\/>pr\ ==\ execptr-\/>start)\ ||}
\DoxyCodeLine{00702\ \ \ \ \ \ \ \ \ \ \ \ \ execmode.step\ ==\ \textcolor{keyword}{true}\ ||\ getbps(sys-\/>cpu-\/>pr)\ ==\ \textcolor{keyword}{true})}
\DoxyCodeLine{00703\ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{00704\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(sys-\/>cpu-\/>pr\ ==\ execptr-\/>start)\ \{}
\DoxyCodeLine{00705\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(stdout,\ \textcolor{stringliteral}{"{}\%s"{}},\ monmsg);}
\DoxyCodeLine{00706\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00707\ \ \ \ \ \ \ \ \ \ \ \ \ monitor();}
\DoxyCodeLine{00708\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00709\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ プログラムレジスタをチェック\ */}}
\DoxyCodeLine{00710\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(sys-\/>cpu-\/>pr\ >=\ sys-\/>memsize)\ \{}
\DoxyCodeLine{00711\ \ \ \ \ \ \ \ \ \ \ \ \ setcerr(201,\ s\ =\ pr2str(sys-\/>cpu-\/>pr));\ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Program\ Register\ (PR)\ -\/\ memory\ overflow\ */}}
\DoxyCodeLine{00712\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ execfin;}
\DoxyCodeLine{00713\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00714\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ スタックポインタをチェック\ */}}
\DoxyCodeLine{00715\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(sys-\/>cpu-\/>sp\ <=\ execptr-\/>end)\ \{}
\DoxyCodeLine{00716\ \ \ \ \ \ \ \ \ \ \ \ \ setcerr(202,\ s\ =\ pr2str(sys-\/>cpu-\/>pr));\ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Stack\ Pointer\ (SP)\ -\/\ stack\ overflow\ */}}
\DoxyCodeLine{00717\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ execfin;}
\DoxyCodeLine{00718\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00719\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ コードから命令を取得\ */}}
\DoxyCodeLine{00720\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ 取得できない場合はエラー終了\ */}}
\DoxyCodeLine{00721\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}((cmdptr\ =\ getcmdptr(sys-\/>memory[sys-\/>cpu-\/>pr]\ \&\ 0xFF00))\ ==\ NULL)\ \{}
\DoxyCodeLine{00722\ \ \ \ \ \ \ \ \ \ \ \ \ setcerr(204,\ s\ =\ pr2str(sys-\/>cpu-\/>pr));\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ OP\ in\ word\ \#1\ -\/\ not\ command\ code\ */}}
\DoxyCodeLine{00723\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ execfin;}
\DoxyCodeLine{00724\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00725\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ 命令の実行\ */}}
\DoxyCodeLine{00726\ \ \ \ \ \ \ \ \ (*cmdptr)();}
\DoxyCodeLine{00727\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ エラー発生時はエラー終了\ */}}
\DoxyCodeLine{00728\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(cerr-\/>num\ >\ 0)\ \{}
\DoxyCodeLine{00729\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ execfin;}
\DoxyCodeLine{00730\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00731\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ 終了フラグがtrueの場合は、モニターまたは正常終了\ */}}
\DoxyCodeLine{00732\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(execptr-\/>stop\ ==\ \textcolor{keyword}{true})\ \{}
\DoxyCodeLine{00733\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(execmode.monitor\ ==\ \textcolor{keyword}{true})\ \{}
\DoxyCodeLine{00734\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(stdout,\ \textcolor{stringliteral}{"{}Return\ to\ top.\(\backslash\)n"{}});}
\DoxyCodeLine{00735\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ monitor();}
\DoxyCodeLine{00736\ \ \ \ \ \ \ \ \ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00737\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00738\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00739\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00740\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ クロック周波数の設定\ */}}
\DoxyCodeLine{00741\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{do}\ \{}
\DoxyCodeLine{00742\ \ \ \ \ \ \ \ \ \ \ \ \ clock\_end\ =\ clock();}
\DoxyCodeLine{00743\ \ \ \ \ \ \ \ \ \}\ \textcolor{keywordflow}{while}(clock\_end\ -\/\ clock\_begin\ <\ CLOCKS\_PER\_SEC\ /\ sys-\/>clocks);}
\DoxyCodeLine{00744\ \ \ \ \ \}}
\DoxyCodeLine{00745\ execfin:}
\DoxyCodeLine{00746\ \ \ \ \ FREE(s);}
\DoxyCodeLine{00747\ \ \ \ \ freebps();}
\DoxyCodeLine{00748\ \ \ \ \ free\_cmdtable(HASH\_CODE);\ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ 命令のコードとタイプがキーのハッシュ表を解放\ */}}
\DoxyCodeLine{00749\ \ \ \ \ \textcolor{keywordflow}{if}(cerr-\/>num\ >\ 0)\ \{}
\DoxyCodeLine{00750\ \ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}Execute\ error\ -\/\ \%d:\ \%s\(\backslash\)n"{}},\ cerr-\/>num,\ cerr-\/>msg);}
\DoxyCodeLine{00751\ \ \ \ \ \}}
\DoxyCodeLine{00752\ \}}

\end{DoxyCode}

/* [<][>][^][v][top][bottom][index][help] */