YACASL2
Loading...
Searching...
No Matches
assemble.c File Reference
#include "assemble.h"
Include dependency graph for assemble.c:

Go to the source code of this file.

Functions

void printline (FILE *stream, const char *filename, int lineno, char *line)
 ファイルストリームの現在行を番号付きで表示する
WORD getadr (const char *prog, const char *str, PASS pass)
 アドレスを返す
WORD grword (const char *str, bool is_x)
 汎用レジスタを表す文字列からレジスタ番号を返す
WORD getliteral (const char *str, PASS pass)
 リテラルを返す
void writememory (WORD word, WORD adr, PASS pass)
 アドレス値をメモリに書き込む
void writestr (const char *str, bool literal, PASS pass)
 文字をメモリに書き込む
void writedc (const char *str, PASS pass)
 DC命令を書込
void assemble_start (const CMDLINE *cmdl, PASS pass)
 アセンブラ命令STARTの処理
void assemble_ds (const CMDLINE *cmdl, PASS pass)
 アセンブラ命令DSの処理
void assemble_end (const CMDLINE *cmdl, PASS pass)
 アセンブラ命令ENDの処理
void assemble_dc (const CMDLINE *cmdl, PASS pass)
 アセンブラ命令DCの処理
void assemble_in (const CMDLINE *cmdl, PASS pass)
 マクロ命令 "IN IBUF,LEN" をアセンブル
void assemble_out (const CMDLINE *cmdl, PASS pass)
 マクロ命令 "OUT OBUF,LEN" をアセンブル
void assemble_rpush (const CMDLINE *cmdl, PASS pass)
 マクロ命令 "RPUSH" をメモリに書き込む
void assemble_rpop (const CMDLINE *cmdl, PASS pass)
 マクロ命令 "RPOP" をメモリに書き込む
bool casl2cmd (CMD *cmdtbl, const CMDLINE *cmdl, PASS pass)
 アセンブラ言語CASL IIの命令を処理する。
bool assemble_comet2cmd (const CMDLINE *cmdl, PASS pass)
 システムCOMET IIの命令をアセンブルする
bool assembletok (const CMDLINE *cmdl, PASS pass)
 トークンをアセンブルする
bool assembleline (const char *line, PASS pass)
 1行をアセンブルする
bool assemblefile (const char *file, PASS pass)
 指定された名前のファイルをアセンブル
bool assemble (int filec, char *filev[], WORD adr)
 指定された1つまたは複数のファイルを2回アセンブル
void addcerrlist_assemble ()
 アセンブルエラーをエラーリストに追加する
void outassemble (const char *file)
 ファイルにアセンブル結果を書き込む

Variables

static CERR cerr_assemble []
 アセンブルのエラー
static CMD ascmd []
 アセンブラ命令
static CMD macrocmd []
 マクロ命令
ASPTRasptr = NULL
 アセンブル時の、現在およびリテラルのアドレスとプログラム入口名: ptr, lptr, prog
ASMODE asmode = {false, false, false, false, false}
 アセンブルモード: src, label, onlylabel, asdetail, onlyassemble

Function Documentation

◆ addcerrlist_assemble()

void addcerrlist_assemble ( )

アセンブルエラーをエラーリストに追加する

Definition at line 773 of file assemble.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ assemble()

bool assemble ( int filec,
char * filev[],
WORD adr )

指定された1つまたは複数のファイルを2回アセンブル

Returns
アセンブル完了時はtrue、エラー発生時はfalseを返す
Parameters
filecアセンブルするファイルの数
filevアセンブルするファイル名の配列
adrアセンブル結果を格納するアドレス

Definition at line 727 of file assemble.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ assemble_comet2cmd()

bool assemble_comet2cmd ( const CMDLINE * cmdl,
PASS pass )

システムCOMET IIの命令をアセンブルする

Returns
アセンブル成功時はtrue、失敗時はfalseを返す
Parameters
*cmdl1行分のラベル・コマンド・オペランド
passアセンブルが何回目か

Definition at line 557 of file assemble.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ assemble_dc()

void assemble_dc ( const CMDLINE * cmdl,
PASS pass )

アセンブラ命令DCの処理

Parameters
*cmdl1行分のラベル・コマンド・オペランド
passアセンブラが何回目かを表す数

Definition at line 456 of file assemble.c.

◆ assemble_ds()

void assemble_ds ( const CMDLINE * cmdl,
PASS pass )

アセンブラ命令DSの処理

Parameters
*cmdl1行分のラベル・コマンド・オペランド
passアセンブラが何回目かを表す数

Definition at line 442 of file assemble.c.

◆ assemble_end()

void assemble_end ( const CMDLINE * cmdl,
PASS pass )

アセンブラ命令ENDの処理

Parameters
*cmdl1行分のラベル・コマンド・オペランド
passアセンブラが何回目かを表す数

Definition at line 425 of file assemble.c.

◆ assemble_in()

void assemble_in ( const CMDLINE * cmdl,
PASS pass )

マクロ命令 "IN IBUF,LEN" をアセンブル

PUSH 0,GR1
PUSH 0,GR2
LAD GR1,IBUF
LAD GR2,LEN
SVC 1
POP GR2
POP GR1
Parameters
*cmdl1行分のラベル・コマンド・オペランド
passアセンブラが何回目かを表す数

Definition at line 470 of file assemble.c.

◆ assemble_out()

void assemble_out ( const CMDLINE * cmdl,
PASS pass )

マクロ命令 "OUT OBUF,LEN" をアセンブル

PUSH 0,GR1
PUSH 0,GR2
LAD GR1,OBUF
LAD GR2,LEN
SVC 2
LAD GR1,=#A
LAD GR2,=1
SVC 2
POP GR2
POP GR1
Parameters
*cmdl1行分のラベル・コマンド・オペランド
passアセンブラが何回目かを表す数

Definition at line 490 of file assemble.c.

◆ assemble_rpop()

void assemble_rpop ( const CMDLINE * cmdl,
PASS pass )

マクロ命令 "RPOP" をメモリに書き込む

POP GR7
POP GR6
POP GR5
POP GR4
POP GR3
POP GR3
POP GR2
POP GR1
Parameters
*cmdl1行分のラベル・コマンド・オペランド
passアセンブラが何回目かを表す数

Definition at line 528 of file assemble.c.

◆ assemble_rpush()

void assemble_rpush ( const CMDLINE * cmdl,
PASS pass )

マクロ命令 "RPUSH" をメモリに書き込む

PUSH 0,GR1
PUSH 0,GR2
PUSH 0,GR3
PUSH 0,GR4
PUSH 0,GR5
PUSH 0,GR6
PUSH 0,GR7
Parameters
*cmdl1行分のラベル・コマンド・オペランド
passアセンブラが何回目かを表す数

Definition at line 513 of file assemble.c.

◆ assemble_start()

void assemble_start ( const CMDLINE * cmdl,
PASS pass )

アセンブラ命令STARTの処理

Parameters
*cmdl1行分のラベル・コマンド・オペランド
passアセンブラが何回目かを表す数

Definition at line 407 of file assemble.c.

◆ assemblefile()

bool assemblefile ( const char * file,
PASS pass )

指定された名前のファイルをアセンブル

指定された名前のファイルをアセンブル
アセンブル完了時はtrue、エラー発生時はfalseを返す

Definition at line 699 of file assemble.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ assembleline()

bool assembleline ( const char * line,
PASS pass )

1行をアセンブルする

passが1の場合はラベルを登録し、2の場合はラベルからアドレスを読み込む

Returns
アセンブル成功時はtrue、失敗時はfalseを返す
Parameters
*line1行分の文字列
passアセンブラが何回目かを表す数

Definition at line 665 of file assemble.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ assembletok()

bool assembletok ( const CMDLINE * cmdl,
PASS pass )

トークンをアセンブルする

Returns
アセンブル成功時はtrue、失敗時はfalseを返す
Parameters
*cmdl1行分のラベル・コマンド・オペランド
passアセンブラが何回目かを表す数

Definition at line 647 of file assemble.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ casl2cmd()

bool casl2cmd ( CMD * cmdtbl,
const CMDLINE * cmdl,
PASS pass )

アセンブラ言語CASL IIの命令を処理する。

エラー発生時は、cerrを設定

Returns
命令が表で定義されている場合はtrue、それ以外の場合はfalseを返す
Parameters
*cmdtblアセンブラ言語CASL IIの命令表
*cmdl1行分のラベル・コマンド・オペランド
passアセンブルが何回目か

Definition at line 543 of file assemble.c.

Here is the caller graph for this function:

◆ getadr()

WORD getadr ( const char * prog,
const char * str,
PASS pass )

アドレスを返す

アドレスには、リテラル/10進定数/16進定数/アドレス定数が含まれる

Returns
アドレス
Parameters
*progプログラム名
*strアドレスを表す文字列
passアセンブラが何回目かを表す数

Definition at line 295 of file assemble.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getliteral()

WORD getliteral ( const char * str,
PASS pass )

リテラルを返す

リテラルには、10進定数/16進定数/文字定数が含まれる

Parameters
*strリテラル。定数の前に等号(=)をつけて記述される
passアセンブラが何回目かを表す数

Definition at line 333 of file assemble.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ grword()

WORD grword ( const char * str,
bool is_x )

汎用レジスタを表す文字列からレジスタ番号を返す

文字列が汎用レジスタを表さない場合は、0xFFFFを返す

is_xがtrueの場合は指標レジスタとなり、GR0が指定された場合はCOMET IIの仕様によりエラー発生

Returns
レジスタ番号[0-7]を表すWORD値
Parameters
*str汎用レジスタを表す文字列。「GR0」「GR1」・・・「GR7」のいずれか
is_xtrueの場合は指標レジスタ

Definition at line 313 of file assemble.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ outassemble()

void outassemble ( const char * file)

ファイルにアセンブル結果を書き込む

Parameters
*fileファイル名

Definition at line 781 of file assemble.c.

Here is the caller graph for this function:

◆ printline()

void printline ( FILE * stream,
const char * filename,
int lineno,
char * line )

ファイルストリームの現在行を番号付きで表示する

Parameters
*streamファイルストリーム
*filenameファイル名
lineno行番号
line行の文字列

Definition at line 290 of file assemble.c.

Here is the caller graph for this function:

◆ writedc()

void writedc ( const char * str,
PASS pass )

DC命令を書込

Parameters
strアドレスを表す文字列。10進定数/16進定数/アドレス定数が含まれる
passアセンブラが何回目かを表す数

Definition at line 389 of file assemble.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writememory()

void writememory ( WORD word,
WORD adr,
PASS pass )

アドレス値をメモリに書き込む

Parameters
wordアドレス値
adrアドレス
passアセンブラが何回目かを表す数

Definition at line 347 of file assemble.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writestr()

void writestr ( const char * str,
bool literal,
PASS pass )

文字をメモリに書き込む

Parameters
*strアドレスを表す文字列。リテラル/10進定数/16進定数/アドレス定数が含まれる
literalリテラルの場合はtrue
passアセンブラが何回目かを表す数

Definition at line 363 of file assemble.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ascmd

CMD ascmd[]
static
Initial value:
= {
{ "START", assemble_start },
{ "END", assemble_end },
{ "DS", assemble_ds },
{ "DC", assemble_dc },
{ "", NULL }
}
void assemble_start(const CMDLINE *cmdl, PASS pass)
アセンブラ命令STARTの処理
Definition assemble.c:407
void assemble_ds(const CMDLINE *cmdl, PASS pass)
アセンブラ命令DSの処理
Definition assemble.c:442
void assemble_dc(const CMDLINE *cmdl, PASS pass)
アセンブラ命令DCの処理
Definition assemble.c:456
void assemble_end(const CMDLINE *cmdl, PASS pass)
アセンブラ命令ENDの処理
Definition assemble.c:425

アセンブラ命令

Definition at line 267 of file assemble.c.

◆ asmode

ASMODE asmode = {false, false, false, false, false}

アセンブルモード: src, label, onlylabel, asdetail, onlyassemble

Definition at line 288 of file assemble.c.

◆ asptr

ASPTR* asptr = NULL

アセンブル時の、現在およびリテラルのアドレスとプログラム入口名: ptr, lptr, prog

Definition at line 286 of file assemble.c.

◆ cerr_assemble

CERR cerr_assemble[]
static
Initial value:
= {
{ 106, "operand mismatch in CASL II command" },
{ 107, "no label in START" },
{ 108, "not command of operand \"r\"" },
{ 109, "not command of operand \"r1,r2\"" },
{ 110, "not command of operand \"r,adr[,x]\"" },
{ 111, "not command of operand \"adr[,x]\"" },
{ 112, "not command of no operand" },
{ 113, "operand too many in COMET II command" },
{ 119, "out of COMET II memory" },
{ 120, "GR0 in operand x" },
{ 122, "cannot create hash table" },
{ 124, "more than one character in literal" },
{ 125, "not GR in operand x" },
}

アセンブルのエラー

Definition at line 248 of file assemble.c.

◆ macrocmd

CMD macrocmd[]
static
Initial value:
= {
{ "OUT", assemble_out },
{ "IN", assemble_in },
{ "RPUSH", assemble_rpush },
{ "RPOP", assemble_rpop },
{ "", NULL }
}
void assemble_rpop(const CMDLINE *cmdl, PASS pass)
マクロ命令 "RPOP" をメモリに書き込む
Definition assemble.c:528
void assemble_out(const CMDLINE *cmdl, PASS pass)
マクロ命令 "OUT OBUF,LEN" をアセンブル
Definition assemble.c:490
void assemble_in(const CMDLINE *cmdl, PASS pass)
マクロ命令 "IN IBUF,LEN" をアセンブル
Definition assemble.c:470
void assemble_rpush(const CMDLINE *cmdl, PASS pass)
マクロ命令 "RPUSH" をメモリに書き込む
Definition assemble.c:513

マクロ命令

Definition at line 278 of file assemble.c.