\doxysection{struct.\+c}
\label{struct_8c_source}\index{src/struct.c@{src/struct.c}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#include\ "{}struct.h"{}}}
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#include\ "{}exec.h"{}}}
\DoxyCodeLine{00003\ }
\DoxyCodeLine{00007\ SYSTEM\ *sys\ =\ NULL;}
\DoxyCodeLine{00008\ }
\DoxyCodeLine{00012\ EXECPTR\ *execptr\ =\ NULL;}
\DoxyCodeLine{00013\ }
\DoxyCodeLine{00017\ \textcolor{keyword}{static}\ \textcolor{keyword}{const}\ COMET2CMD\ comet2cmd[]\ =\ \{}
\DoxyCodeLine{00018\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}NOP"{}},\ NONE,\ 0x0,\ nop\ \},}
\DoxyCodeLine{00019\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}LD"{}},\ R\_ADR\_X,\ 0x1000,\ ld\_r\_adr\_x\ \},}
\DoxyCodeLine{00020\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}ST"{}},\ R\_ADR\_X,\ 0x1100,\ st\ \},}
\DoxyCodeLine{00021\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}LAD"{}},\ R\_ADR\_X,\ 0x1200,\ lad\ \},}
\DoxyCodeLine{00022\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}LD"{}},\ R1\_R2,\ 0x1400,\ ld\_r1\_r2\ \},}
\DoxyCodeLine{00023\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}ADDA"{}},\ R\_ADR\_X,\ 0x2000,\ adda\_r\_adr\_x\ \},}
\DoxyCodeLine{00024\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}SUBA"{}},\ R\_ADR\_X,\ 0x2100,\ suba\_r\_adr\_x\ \},}
\DoxyCodeLine{00025\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}ADDL"{}},\ R\_ADR\_X,\ 0x2200,\ addl\_r\_adr\_x\ \},}
\DoxyCodeLine{00026\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}SUBL"{}},\ R\_ADR\_X,\ 0x2300,\ subl\_r\_adr\_x\ \},}
\DoxyCodeLine{00027\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}ADDA"{}},\ R1\_R2,\ 0x2400,\ adda\_r1\_r2\ \},}
\DoxyCodeLine{00028\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}SUBA"{}},\ R1\_R2,\ 0x2500,\ suba\_r1\_r2\ \},}
\DoxyCodeLine{00029\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}ADDL"{}},\ R1\_R2,\ 0x2600,\ addl\_r1\_r2\ \},}
\DoxyCodeLine{00030\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}SUBL"{}},\ R1\_R2,\ 0x2700,\ subl\_r1\_r2\ \},}
\DoxyCodeLine{00031\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}AND"{}},\ R\_ADR\_X,\ 0x3000,\ and\_r\_adr\_x\ \},}
\DoxyCodeLine{00032\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}OR"{}},\ R\_ADR\_X,\ 0x3100,\ or\_r\_adr\_x\ \},}
\DoxyCodeLine{00033\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}XOR"{}},\ R\_ADR\_X,\ 0x3200,\ xor\_r\_adr\_x\ \},}
\DoxyCodeLine{00034\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}AND"{}},\ R1\_R2,\ 0x3400,\ and\_r1\_r2\ \},}
\DoxyCodeLine{00035\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}OR"{}},\ R1\_R2,\ 0x3500,\ or\_r1\_r2\ \},}
\DoxyCodeLine{00036\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}XOR"{}},\ R1\_R2,\ 0x3600,\ xor\_r1\_r2\ \},}
\DoxyCodeLine{00037\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}CPA"{}},\ R\_ADR\_X,\ 0x4000,\ cpa\_r\_adr\_x\ \},}
\DoxyCodeLine{00038\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}CPL"{}},\ R\_ADR\_X,\ 0x4100,\ cpl\_r\_adr\_x\ \},}
\DoxyCodeLine{00039\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}CPA"{}},\ R1\_R2,\ 0x4400,\ cpa\_r1\_r2\ \},}
\DoxyCodeLine{00040\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}CPL"{}},\ R1\_R2,\ 0x4500,\ cpl\_r1\_r2\ \},}
\DoxyCodeLine{00041\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}SLA"{}},\ R\_ADR\_X,\ 0x5000,\ sla\ \},}
\DoxyCodeLine{00042\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}SRA"{}},\ R\_ADR\_X,\ 0x5100,\ sra\ \},}
\DoxyCodeLine{00043\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}SLL"{}},\ R\_ADR\_X,\ 0x5200,\ sll\ \},}
\DoxyCodeLine{00044\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}SRL"{}},\ R\_ADR\_X,\ 0x5300,\ srl\ \},}
\DoxyCodeLine{00045\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}JMI"{}},\ ADR\_X,\ 0x6100,\ jmi\ \},}
\DoxyCodeLine{00046\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}JNZ"{}},\ ADR\_X,\ 0x6200,\ jnz\ \},}
\DoxyCodeLine{00047\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}JZE"{}},\ ADR\_X,\ 0x6300,\ jze\ \},}
\DoxyCodeLine{00048\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}JUMP"{}},\ ADR\_X,\ 0x6400,\ jump\ \},}
\DoxyCodeLine{00049\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}JPL"{}},\ ADR\_X,\ 0x6500,\ jpl\ \},}
\DoxyCodeLine{00050\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}JOV"{}},\ ADR\_X,\ 0x6600,\ jov\ \},}
\DoxyCodeLine{00051\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}PUSH"{}},\ ADR\_X,\ 0x7000,\ push\ \},}
\DoxyCodeLine{00052\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}POP"{}},\ R\_,\ 0x7100,\ pop\ \},}
\DoxyCodeLine{00053\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}CALL"{}},\ ADR\_X,\ 0x8000,\ call\ \},}
\DoxyCodeLine{00054\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}SVC"{}},\ ADR\_X,\ 0xF000,\ svc\ \},}
\DoxyCodeLine{00055\ \ \ \ \ \{\ \textcolor{stringliteral}{"{}RET"{}},\ NONE,\ 0x8100,\ ret\ \},}
\DoxyCodeLine{00056\ \};}
\DoxyCodeLine{00057\ }
\DoxyCodeLine{00061\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ comet2cmdsize\ =\ ARRAYSIZE(comet2cmd);}
\DoxyCodeLine{00062\ }
\DoxyCodeLine{00066\ \textcolor{keyword}{enum}\ \{}
\DoxyCodeLine{00067\ \ \ \ \ CMDTABSIZE\ =\ 41,}
\DoxyCodeLine{00068\ \};}
\DoxyCodeLine{00069\ }
\DoxyCodeLine{00073\ \textcolor{keyword}{static}\ CMDTAB\ *cmdtab[HASH\_MAX][CMDTABSIZE]\ =\ \{\{NULL\}\};}
\DoxyCodeLine{00074\ }
\DoxyCodeLine{00078\ \textcolor{keywordtype}{unsigned}\ hash\_cmdtype(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *cmd,\ CMDTYPE\ type);}
\DoxyCodeLine{00079\ }
\DoxyCodeLine{00083\ \textcolor{keywordtype}{unsigned}\ hash\_code(WORD\ code);}
\DoxyCodeLine{00084\ }
\DoxyCodeLine{00088\ \textcolor{keywordtype}{unsigned}\ hash\_cmdtype(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *cmd,\ CMDTYPE\ type)}
\DoxyCodeLine{00089\ \{}
\DoxyCodeLine{00090\ \ \ \ \ HKEY\ *keys[2]\ =\ \{NULL\};}
\DoxyCodeLine{00091\ \ \ \ \ \textcolor{keywordtype}{unsigned}\ hashval\ =\ 0;}
\DoxyCodeLine{00092\ }
\DoxyCodeLine{00093\ \ \ \ \ \textcolor{comment}{/*\ 命令名を設定\ */}}
\DoxyCodeLine{00094\ \ \ \ \ keys[0]\ =\ malloc\_chk(\textcolor{keyword}{sizeof}(HKEY),\ \textcolor{stringliteral}{"{}hash\_cmdtype.keys[0]"{}});}
\DoxyCodeLine{00095\ \ \ \ \ keys[0]-\/>type\ =\ CHARS;}
\DoxyCodeLine{00096\ \ \ \ \ keys[0]-\/>val.s\ =\ strdup\_chk(cmd,\ \textcolor{stringliteral}{"{}keys[0].val.s"{}});}
\DoxyCodeLine{00097\ \ \ \ \ \textcolor{comment}{/*\ 命令タイプを設定\ */}}
\DoxyCodeLine{00098\ \ \ \ \ keys[1]\ =\ malloc\_chk(\textcolor{keyword}{sizeof}(HKEY),\ \textcolor{stringliteral}{"{}hash\_cmdtype.keys[1]"{}});}
\DoxyCodeLine{00099\ \ \ \ \ keys[1]-\/>type\ =\ INT;}
\DoxyCodeLine{00100\ \ \ \ \ keys[1]-\/>val.i\ =\ (int)(type\ \&\ 070);}
\DoxyCodeLine{00101\ \ \ \ \ \textcolor{comment}{/*\ ハッシュ値の計算\ */}}
\DoxyCodeLine{00102\ \ \ \ \ hashval\ =\ hash(2,\ keys,\ CMDTABSIZE);}
\DoxyCodeLine{00103\ \ \ \ \ FREE(keys[0]-\/>val.s);}
\DoxyCodeLine{00104\ \ \ \ \ FREE(keys[0]);}
\DoxyCodeLine{00105\ \ \ \ \ FREE(keys[1]);}
\DoxyCodeLine{00106\ \ \ \ \ \textcolor{comment}{/*\ ハッシュ値を返す\ */}}
\DoxyCodeLine{00107\ \ \ \ \ \textcolor{keywordflow}{return}\ hashval;}
\DoxyCodeLine{00108\ \}}
\DoxyCodeLine{00109\ }
\DoxyCodeLine{00113\ \textcolor{keywordtype}{bool}\ create\_cmdtable(CMDTAB\_HASH\ hash)}
\DoxyCodeLine{00114\ \{}
\DoxyCodeLine{00115\ \ \ \ \ CMDTAB\ *p\ =\ NULL;}
\DoxyCodeLine{00116\ \ \ \ \ \textcolor{keywordtype}{unsigned}\ hashval;}
\DoxyCodeLine{00117\ }
\DoxyCodeLine{00118\ \ \ \ \ \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ comet2cmdsize;\ i++)\ \{}
\DoxyCodeLine{00119\ \ \ \ \ \ \ \ \ p\ =\ malloc\_chk(\textcolor{keyword}{sizeof}(CMDTAB),\ \textcolor{stringliteral}{"{}create\_cmdtable.p"{}});}
\DoxyCodeLine{00120\ \ \ \ \ \ \ \ \ p-\/>cmd\ =\ \&comet2cmd[i];}
\DoxyCodeLine{00121\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(hash\ ==\ HASH\_CMDTYPE)\ \{}
\DoxyCodeLine{00122\ \ \ \ \ \ \ \ \ \ \ \ \ hashval\ =\ hash\_cmdtype(comet2cmd[i].name,\ comet2cmd[i].type);}
\DoxyCodeLine{00123\ \ \ \ \ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}(hash\ ==\ HASH\_CODE)\ \{}
\DoxyCodeLine{00124\ \ \ \ \ \ \ \ \ \ \ \ \ hashval\ =\ hash\_code(comet2cmd[i].code);}
\DoxyCodeLine{00125\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00126\ \ \ \ \ \ \ \ \ p-\/>next\ =\ cmdtab[hash][hashval];}
\DoxyCodeLine{00127\ \ \ \ \ \ \ \ \ cmdtab[hash][hashval]\ =\ p;}
\DoxyCodeLine{00128\ \ \ \ \ \}}
\DoxyCodeLine{00129\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{true};}
\DoxyCodeLine{00130\ \}}
\DoxyCodeLine{00131\ }
\DoxyCodeLine{00135\ \textcolor{keywordtype}{void}\ free\_cmdtable(CMDTAB\_HASH\ hash)}
\DoxyCodeLine{00136\ \{}
\DoxyCodeLine{00137\ \ \ \ \ CMDTAB\ *p\ =\ NULL;}
\DoxyCodeLine{00138\ \ \ \ \ CMDTAB\ *q\ =\ NULL;}
\DoxyCodeLine{00139\ }
\DoxyCodeLine{00140\ \ \ \ \ \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ CMDTABSIZE;\ i++)\ \{}
\DoxyCodeLine{00141\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}(p\ =\ cmdtab[hash][i];\ p\ !=\ NULL;\ p\ =\ q)\ \{}
\DoxyCodeLine{00142\ \ \ \ \ \ \ \ \ \ \ \ \ q\ =\ p-\/>next;}
\DoxyCodeLine{00143\ \ \ \ \ \ \ \ \ \ \ \ \ FREE(p);}
\DoxyCodeLine{00144\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00145\ \ \ \ \ \ \ \ \ cmdtab[hash][i]\ =\ NULL;}
\DoxyCodeLine{00146\ \ \ \ \ \}}
\DoxyCodeLine{00147\ \}}
\DoxyCodeLine{00148\ }
\DoxyCodeLine{00153\ WORD\ getcmdcode(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *cmd,\ CMDTYPE\ type)}
\DoxyCodeLine{00154\ \{}
\DoxyCodeLine{00155\ \ \ \ \ CMDTAB\ *p\ =\ NULL;}
\DoxyCodeLine{00156\ \ \ \ \ WORD\ w\ =\ 0xFFFF;}
\DoxyCodeLine{00157\ }
\DoxyCodeLine{00158\ \ \ \ \ assert(cmd\ !=\ NULL);}
\DoxyCodeLine{00159\ \ \ \ \ \textcolor{keywordflow}{for}(p\ =\ cmdtab[HASH\_CMDTYPE][hash\_cmdtype(cmd,\ type)];\ p\ !=\ NULL;\ p\ =\ p-\/>next)\ \{}
\DoxyCodeLine{00160\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(strcmp(cmd,\ p-\/>cmd-\/>name)\ ==\ 0\ \&\&\ type\ ==\ p-\/>cmd-\/>type)\ \{}
\DoxyCodeLine{00161\ \ \ \ \ \ \ \ \ \ \ \ \ w\ =\ p-\/>cmd-\/>code;}
\DoxyCodeLine{00162\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00163\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00164\ \ \ \ \ \}}
\DoxyCodeLine{00165\ \ \ \ \ \textcolor{keywordflow}{return}\ w;}
\DoxyCodeLine{00166\ \}}
\DoxyCodeLine{00167\ }
\DoxyCodeLine{00171\ \textcolor{keywordtype}{unsigned}\ hash\_code(WORD\ code)}
\DoxyCodeLine{00172\ \{}
\DoxyCodeLine{00173\ \ \ \ \ HKEY\ *keys[1]\ =\ \{NULL\};}
\DoxyCodeLine{00174\ \ \ \ \ \textcolor{keywordtype}{unsigned}\ h\ =\ 0;}
\DoxyCodeLine{00175\ }
\DoxyCodeLine{00176\ \ \ \ \ \textcolor{comment}{/*\ 命令コードを設定\ */}}
\DoxyCodeLine{00177\ \ \ \ \ keys[0]\ =\ malloc\_chk(\textcolor{keyword}{sizeof}(HKEY),\ \textcolor{stringliteral}{"{}hash\_code.key"{}});}
\DoxyCodeLine{00178\ \ \ \ \ keys[0]-\/>type\ =\ INT;}
\DoxyCodeLine{00179\ \ \ \ \ keys[0]-\/>val.i\ =\ (int)(code\ >>\ 8);}
\DoxyCodeLine{00180\ \ \ \ \ h\ =\ hash(1,\ keys,\ CMDTABSIZE);}
\DoxyCodeLine{00181\ \ \ \ \ FREE(keys[0]);}
\DoxyCodeLine{00182\ \ \ \ \ \textcolor{keywordflow}{return}\ h;}
\DoxyCodeLine{00183\ \}}
\DoxyCodeLine{00184\ }
\DoxyCodeLine{00188\ \textcolor{keyword}{const}\ void\ (*getcmdptr(WORD\ code))}
\DoxyCodeLine{00189\ \{}
\DoxyCodeLine{00190\ \ \ \ \ CMDTAB\ *t\ =\ NULL;}
\DoxyCodeLine{00191\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{void}\ *ptr\ =\ NULL;}
\DoxyCodeLine{00192\ }
\DoxyCodeLine{00193\ \ \ \ \ \textcolor{keywordflow}{for}(t\ =\ cmdtab[HASH\_CODE][hash\_code(code)];\ t\ !=\ NULL;\ t\ =\ t-\/>next)\ \{}
\DoxyCodeLine{00194\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(code\ ==\ t-\/>cmd-\/>code)\ \{}
\DoxyCodeLine{00195\ \ \ \ \ \ \ \ \ \ \ \ \ ptr\ =\ t-\/>cmd-\/>ptr;}
\DoxyCodeLine{00196\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00197\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00198\ \ \ \ \ \}}
\DoxyCodeLine{00199\ \ \ \ \ \textcolor{keywordflow}{return}\ ptr;}
\DoxyCodeLine{00200\ \}}
\DoxyCodeLine{00201\ }
\DoxyCodeLine{00205\ CMDTYPE\ getcmdtype(WORD\ code)}
\DoxyCodeLine{00206\ \{}
\DoxyCodeLine{00207\ \ \ \ \ CMDTAB\ *t\ =\ NULL;}
\DoxyCodeLine{00208\ \ \ \ \ CMDTYPE\ type\ =\ NONE;}
\DoxyCodeLine{00209\ }
\DoxyCodeLine{00210\ \ \ \ \ \textcolor{keywordflow}{for}(t\ =\ cmdtab[HASH\_CODE][hash\_code(code)];\ t\ !=\ NULL;\ t\ =\ t-\/>next)\ \{}
\DoxyCodeLine{00211\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(code\ ==\ t-\/>cmd-\/>code)\ \{}
\DoxyCodeLine{00212\ \ \ \ \ \ \ \ \ \ \ \ \ type\ =\ t-\/>cmd-\/>type;}
\DoxyCodeLine{00213\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00214\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00215\ \ \ \ \ \}}
\DoxyCodeLine{00216\ \ \ \ \ \textcolor{keywordflow}{return}\ type;}
\DoxyCodeLine{00217\ \}}
\DoxyCodeLine{00218\ }
\DoxyCodeLine{00222\ \textcolor{keywordtype}{char}\ *getcmdname(WORD\ code)}
\DoxyCodeLine{00223\ \{}
\DoxyCodeLine{00224\ \ \ \ \ CMDTAB\ *t\ =\ NULL;}
\DoxyCodeLine{00225\ \ \ \ \ \textcolor{keywordtype}{char}\ *cmd\ =\ NULL;}
\DoxyCodeLine{00226\ }
\DoxyCodeLine{00227\ \ \ \ \ \textcolor{keywordflow}{for}(t\ =\ cmdtab[HASH\_CODE][hash\_code(code)];\ t\ !=\ NULL;\ t\ =\ t-\/>next)\ \{}
\DoxyCodeLine{00228\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(code\ ==\ t-\/>cmd-\/>code)\ \{}
\DoxyCodeLine{00229\ \ \ \ \ \ \ \ \ \ \ \ \ cmd\ =\ t-\/>cmd-\/>name;}
\DoxyCodeLine{00230\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00231\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00232\ \ \ \ \ \}}
\DoxyCodeLine{00233\ \ \ \ \ \textcolor{keywordflow}{return}\ cmd;}
\DoxyCodeLine{00234\ \}}
\DoxyCodeLine{00235\ }
\DoxyCodeLine{00239\ }
\DoxyCodeLine{00240\ \textcolor{keywordtype}{char}\ *grstr(WORD\ word)}
\DoxyCodeLine{00241\ \{}
\DoxyCodeLine{00242\ \ \ \ \ assert(word\ <=\ 7);}
\DoxyCodeLine{00243\ \ \ \ \ \textcolor{keywordtype}{char}\ *str\ =\ NULL;}
\DoxyCodeLine{00244\ }
\DoxyCodeLine{00245\ \ \ \ \ str\ =\ malloc\_chk(3\ +\ 1,\ \textcolor{stringliteral}{"{}grstr.str"{}});}
\DoxyCodeLine{00246\ \ \ \ \ sprintf(str,\ \textcolor{stringliteral}{"{}GR\%d"{}},\ word);}
\DoxyCodeLine{00247\ \ \ \ \ \textcolor{keywordflow}{return}\ str;}
\DoxyCodeLine{00248\ \}}
\DoxyCodeLine{00249\ }
\DoxyCodeLine{00253\ \textcolor{keywordtype}{void}\ reset(\textcolor{keywordtype}{int}\ memsize,\ \textcolor{keywordtype}{int}\ clocks)}
\DoxyCodeLine{00254\ \{}
\DoxyCodeLine{00255\ \ \ \ \ sys\ =\ malloc\_chk(\textcolor{keyword}{sizeof}(SYSTEM),\ \textcolor{stringliteral}{"{}sys"{}});}
\DoxyCodeLine{00256\ \ \ \ \ \textcolor{comment}{/*\ メモリサイズを設定\ */}}
\DoxyCodeLine{00257\ \ \ \ \ sys-\/>memsize\ =\ memsize;}
\DoxyCodeLine{00258\ \ \ \ \ \textcolor{comment}{/*\ クロック周波数を設定\ */}}
\DoxyCodeLine{00259\ \ \ \ \ sys-\/>clocks\ =\ clocks;}
\DoxyCodeLine{00260\ \ \ \ \ \textcolor{comment}{/*\ メモリを初期化\ */}}
\DoxyCodeLine{00261\ \ \ \ \ sys-\/>memory\ =\ calloc\_chk(sys-\/>memsize,\ \textcolor{keyword}{sizeof}(WORD),\ \textcolor{stringliteral}{"{}memory"{}});}
\DoxyCodeLine{00262\ \ \ \ \ \textcolor{comment}{/*\ CPUを初期化\ */}}
\DoxyCodeLine{00263\ \ \ \ \ sys-\/>cpu\ =\ malloc\_chk(\textcolor{keyword}{sizeof}(CPU),\ \textcolor{stringliteral}{"{}cpu"{}});}
\DoxyCodeLine{00264\ \ \ \ \ \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ GRSIZE;\ i++)\ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ 汎用レジスタ\ \ */}}
\DoxyCodeLine{00265\ \ \ \ \ \ \ \ \ sys-\/>cpu-\/>gr[i]\ =\ 0x0;}
\DoxyCodeLine{00266\ \ \ \ \ \}}
\DoxyCodeLine{00267\ \ \ \ \ sys-\/>cpu-\/>sp\ =\ sys-\/>memsize;\ \ \ \textcolor{comment}{/*\ スタックポインタ\ */}}
\DoxyCodeLine{00268\ \ \ \ \ sys-\/>cpu-\/>pr\ =\ 0x0;\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ プログラムレジスタ\ */}}
\DoxyCodeLine{00269\ \ \ \ \ sys-\/>cpu-\/>fr\ =\ 0x0;\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ フラグレジスタ\ */}}
\DoxyCodeLine{00270\ \ \ \ \ \textcolor{comment}{/*\ CASL2プログラムの開始と終了のアドレスを初期化\ */}}
\DoxyCodeLine{00271\ \ \ \ \ execptr\ =\ malloc\_chk(\textcolor{keyword}{sizeof}(EXECPTR),\ \textcolor{stringliteral}{"{}execptr"{}});}
\DoxyCodeLine{00272\ \ \ \ \ execptr-\/>stop\ =\ \textcolor{keyword}{false};}
\DoxyCodeLine{00273\ \}}
\DoxyCodeLine{00274\ }
\DoxyCodeLine{00278\ \textcolor{keywordtype}{void}\ shutdown()}
\DoxyCodeLine{00279\ \{}
\DoxyCodeLine{00280\ \ \ \ \ FREE(execptr);}
\DoxyCodeLine{00281\ \ \ \ \ FREE(sys-\/>memory);}
\DoxyCodeLine{00282\ \ \ \ \ FREE(sys-\/>cpu);}
\DoxyCodeLine{00283\ \ \ \ \ FREE(sys);}
\DoxyCodeLine{00284\ \}}
\end{DoxyCode}