From 65161f3ec4e3b65693987012503cba1ab49787cb Mon Sep 17 00:00:00 2001 From: j8takagi Date: Mon, 22 Jun 2026 14:28:36 +0900 Subject: [PATCH] =?utf8?q?include=E3=81=AE=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit https://claude.ai/share/3bc3ab2e-d766-4208-8907-4bfad3e6ca7d --- include/assemble.h | 7 +------ include/cerr.h | 2 +- include/cmem.h | 2 +- include/monitor.h | 1 + include/struct.h | 11 ++++++----- src/assemble.c | 8 +++++++- src/cerr.c | 2 +- src/comet2.c | 2 +- src/struct.c | 4 ++-- 9 files changed, 21 insertions(+), 18 deletions(-) diff --git a/include/assemble.h b/include/assemble.h index aab56da..c824cff 100644 --- a/include/assemble.h +++ b/include/assemble.h @@ -1,17 +1,12 @@ #ifndef YACASL2_ASSEMBLE_H_INCLUDED #define YACASL2_ASSEMBLE_H_INCLUDED -#include -#include -#include #include -#include -#include -#include #include "cerr.h" #include "struct.h" #include "token.h" + /** * @brief アセンブルモードを表すデータ型 */ diff --git a/include/cerr.h b/include/cerr.h index f5d0a2d..c361c6b 100644 --- a/include/cerr.h +++ b/include/cerr.h @@ -75,7 +75,7 @@ void setcerr(int num, const char *str); * * @param num エラー番号 */ -char *getcerrmsg(int num); +const char *getcerrmsg(int num); /** * @brief エラーリストと現在のエラーを解放する diff --git a/include/cmem.h b/include/cmem.h index 19de9be..2ddeddb 100644 --- a/include/cmem.h +++ b/include/cmem.h @@ -19,7 +19,7 @@ * @brief メモリを解放するマクロ */ #ifndef FREE -#define FREE(ptr) {free(ptr); ptr = NULL;} +#define FREE(ptr) do { free(ptr); (ptr) = NULL; } while(0) #endif /** diff --git a/include/monitor.h b/include/monitor.h index 097242d..603505e 100644 --- a/include/monitor.h +++ b/include/monitor.h @@ -131,6 +131,7 @@ void freebps(); /** * @brief モニター終了時の処理をする * + * @return エラーがない場合は0、エラーがある場合は1 */ int monquit(); diff --git a/include/struct.h b/include/struct.h index e57a5a2..9495385 100644 --- a/include/struct.h +++ b/include/struct.h @@ -106,7 +106,7 @@ typedef enum { */ typedef struct { char *name; /**<命令名 */ - const void (*ptr); /**<命令の関数ポインタ */ + void (*ptr); /**<命令の関数ポインタ */ } CMD; /** @@ -116,7 +116,7 @@ typedef struct { char *name; /**<命令名 */ CMDTYPE type; /**<命令タイプ */ WORD code; /**<命令コード */ - const void (*ptr); /**<命令の関数ポインタ */ + void (*ptr); /**<命令の関数ポインタ */ } COMET2CMD; /** @@ -145,8 +145,8 @@ typedef struct { bool trace; /**<レジストリの内容をステップごとに表示する場合はtrue */ bool logical; /**<レジストリの内容を論理値(0から65535)で表示する場合はtrue */ bool dump; /**<メモリの内容をステップごとに表示する場合はtrue */ - int dump_start; /**<メモリの内容をステップごとに表示する場合の開始アドレス */ - int dump_end; /**<メモリの内容をステップごとに表示する場合の終了アドレス */ + WORD dump_start; /**<メモリの内容をステップごとに表示する場合の開始アドレス */ + WORD dump_end; /**<メモリの内容をステップごとに表示する場合の終了アドレス */ bool monitor; /**<モニターモードの場合はtrue */ bool step; /**<ステップ実行の場合はtrue */ } EXECMODE; @@ -215,10 +215,11 @@ void free_cmdtable(CMDTAB_HASH hash); */ WORD getcmdcode(const char *cmd, CMDTYPE type); + /** * 命令コードから命令の関数ポインタを返す */ -const void (*getcmdptr(WORD code)); +void (*getcmdptr(WORD code)); /** * 命令コードから命令のタイプを返す diff --git a/src/assemble.c b/src/assemble.c index 1c4f8a7..ed3a9b1 100644 --- a/src/assemble.c +++ b/src/assemble.c @@ -1,4 +1,10 @@ #include "assemble.h" +#include +#include +#include +#include +#include +#include /** * @brief ファイルストリームの現在行を番号付きで表示する @@ -354,7 +360,7 @@ void writememory(WORD word, WORD adr, PASS pass) /* メモリオーバーの場合、エラー発生 */ if(adr >= sys->memsize) { setcerr(119, (n = word2n(adr))); /* out of COMET II memory */ - FREE(n) + FREE(n); return; } (sys->memory)[adr] = word; diff --git a/src/cerr.c b/src/cerr.c index afb2b06..753a5f9 100644 --- a/src/cerr.c +++ b/src/cerr.c @@ -55,7 +55,7 @@ void setcerr(int num, const char *str) } } -char *getcerrmsg(int num) +const char *getcerrmsg(int num) { CERRLIST *p = NULL; char *msg = "unknown error"; diff --git a/src/comet2.c b/src/comet2.c index e381780..62b91e9 100644 --- a/src/comet2.c +++ b/src/comet2.c @@ -89,10 +89,10 @@ int main(int argc, char *argv[]) comet2_init(memsize, clocks); /* COMET II仮想マシンの初期化 */ execptr->start = 0; execptr->end = loadassemble(argv[optind++], execptr->start); + /* 残りの引数(オプション以外の引数)があればInfoを表示 */ if(optind < argc) { warn_ignore_arg(argc - optind, argv + optind); } - /* 残りの引数(オプション以外の引数)があるかチェック */ if(execptr->end > 0 && cerr->num == 0) { exec(); /* プログラム実行 */ } diff --git a/src/struct.c b/src/struct.c index 086c286..855a266 100644 --- a/src/struct.c +++ b/src/struct.c @@ -196,10 +196,10 @@ unsigned hash_code(WORD code) /** * 命令コードから命令の関数ポインタを返す */ -const void (*getcmdptr(WORD code)) +void (*getcmdptr(WORD code)) { CMDTAB *t = NULL; - const void *ptr = NULL; + void *ptr = NULL; for(t = cmdtab[HASH_CODE][hash_code(code)]; t != NULL; t = t->next) { if(code == t->cmd->code) { -- 2.47.3