X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=blobdiff_plain;f=include%2Fassemble.h;h=594157c1d3299e33f285f1ea7a62d24e76e798ba;hp=fddad63565f18ab25ce0fb9e89fc8f7c58e88c0e;hb=e07b6371cc8a59c6793a895e968ff2c6cf28181b;hpb=1e636c95bf237645b6c9117e3eb64aa2d8aa4c90 diff --git a/include/assemble.h b/include/assemble.h index fddad63..594157c 100644 --- a/include/assemble.h +++ b/include/assemble.h @@ -1,10 +1,13 @@ +#ifndef YACASL2_ASSEMBLE_INCLUDED +#define YACASL2_ASSEMBLE_INCLUDED + /* CASL IIの制限 */ enum { - LINESIZE = 1024, /* 行の最大文字数 */ - TOKENSIZE = 256, /* トークンの最大文字数 */ - LABELSIZE = 8, /* ラベルの最大文字数 */ + LINESIZE = 1024, /* 行の最大文字数 */ + TOKENSIZE = 256, /* トークンの最大文字数 */ + LABELSIZE = 8, /* ラベルの最大文字数 */ LABELTABSIZE = 256, /* ラベルの最大数 */ - OPDSIZE = 40 /* オペラントの最大数 */ + OPDSIZE = 40, /* オペラントの最大数 */ }; /* 値を格納するポインタ */ @@ -13,6 +16,9 @@ extern WORD ptr; /* リテラル(=付きの値)を格納するポインタ */ extern WORD lptr; +/* 他のプログラムで参照する入口名 */ +extern char *prog; + /* アセンブラ命令とマクロ命令を表す番号 */ typedef enum { START = 01, @@ -22,7 +28,7 @@ typedef enum { IN = 011, OUT = 012, RPUSH = 013, - RPOP = 014 + RPOP = 014, } CASLCMD; /* アセンブラ命令とマクロ命令を表す配列 */ @@ -36,21 +42,25 @@ typedef struct { /* ラベル表 */ typedef struct _LABELTAB { struct _LABELTAB *next; - char *name; + char *prog; + char *label; WORD adr; } LABELTAB; /* アセンブラが、1回目か、2回目か、を表す */ typedef enum { FIRST = 0, - SECOND = 1 + SECOND = 1, } PASS; -/* ラベル表からアドレスを検索する */ -WORD getlabel(const char *label); +/* プログラム名とラベルに対応するハッシュ値を返す */ +unsigned labelhash(const char *prog, const char *label); + +/* プログラム名とラベルに対応するアドレスをラベル表から検索する */ +WORD getlabel(const char *prog, const char *label); /* ラベルを表に追加する */ -bool addlabel(const char *label, WORD word); +bool addlabel(const char *prog, const char *label, WORD word); /* ラベル表を表示する */ void printlabel(); @@ -94,7 +104,7 @@ WORD gethex(const char *str); /* アドレスを返す */ /* アドレスには、リテラル/10進定数/16進定数/アドレス定数が含まれる */ -WORD getadr(const char *str, PASS pass); +WORD getadr(const char *prog, const char *str, PASS pass); /* 定数の前に等号(=)をつけて記述される、リテラルを返す */ /* リテラルには、10進定数/16進定数/文字定数が含まれる */ @@ -141,3 +151,5 @@ bool writeRPUSH(PASS pass); /* マクロ命令「RPOP」をメモリに書込 */ bool writeRPOP(PASS pass); + +#endif