]> j8takagi.net git repositories - yacasl2.git/commitdiff
includeの整理
authorj8takagi <j8takagi@nifty.com>
Mon, 22 Jun 2026 05:28:36 +0000 (14:28 +0900)
committerj8takagi <j8takagi@nifty.com>
Mon, 22 Jun 2026 05:28:36 +0000 (14:28 +0900)
https://claude.ai/share/3bc3ab2e-d766-4208-8907-4bfad3e6ca7d

include/assemble.h
include/cerr.h
include/cmem.h
include/monitor.h
include/struct.h
src/assemble.c
src/cerr.c
src/comet2.c
src/struct.c

index aab56da762adca020927ea292c32dfd3726a51e6..c824cff8979de65b471250b6ca6355f74561768b 100644 (file)
@@ -1,17 +1,12 @@
 #ifndef YACASL2_ASSEMBLE_H_INCLUDED
 #define YACASL2_ASSEMBLE_H_INCLUDED
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 #include <stdbool.h>
-#include <ctype.h>
-#include <assert.h>
-#include <errno.h>
 #include "cerr.h"
 #include "struct.h"
 #include "token.h"
 
+
 /**
  * @brief アセンブルモードを表すデータ型
  */
index f5d0a2d3a54b458bde1f6002c4ce9e0efd85a7a1..c361c6b908ecf1849ee78034d4bc61f5d0596f9d 100644 (file)
@@ -75,7 +75,7 @@ void setcerr(int num, const char *str);
  *
  * @param num エラー番号
  */
-char *getcerrmsg(int num);
+const char *getcerrmsg(int num);
 
 /**
  * @brief エラーリストと現在のエラーを解放する
index 19de9be2532161c3fad54f8bda2d208a976beffa..2ddeddbe93d6cd0075f7e62fb3b371ac1318566d 100644 (file)
@@ -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
 
 /**
index 097242dc6bff5756dbefd15fa0e0d46e7e0954c2..603505eb376cffa7f2085730cd1bfe74d8d37678 100644 (file)
@@ -131,6 +131,7 @@ void freebps();
 /**
  * @brief モニター終了時の処理をする
  *
+ * @return エラーがない場合は0、エラーがある場合は1
  */
 int monquit();
 
index e57a5a2b18dd50d15c4030890b448848b5da21a3..949538548a9221718c4e468246283410b71e17c9 100644 (file)
@@ -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));
 
 /**
  * 命令コードから命令のタイプを返す
index 1c4f8a7027f47869722980228c9bee6940e4d09e..ed3a9b1a26cf8767f41ee7b70781b6c95a21b762 100644 (file)
@@ -1,4 +1,10 @@
 #include "assemble.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+#include <errno.h>
 
 /**
  * @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;
index afb2b069e4dd701f55c2e9249caff5d5b73e46ad..753a5f9078f899d718e0958e10251fcdfb0b06ff 100644 (file)
@@ -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";
index e381780c0fb24f58ea6cf9d4becad267e383b6ae..62b91e9492f56379a468faa1a26a771e1e241b97 100644 (file)
@@ -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();                 /* プログラム実行 */
     }
index 086c28644208f4d49e16cda41f297cc93b364985..855a2664c8d10030111510724839e91738f0f3ac 100644 (file)
@@ -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) {