これは、sic /xe.asmファイルのsymtabを作成するために作成したコードです。
#include<iostream>
#include<fstream>
#include<iomanip>
#include"aviasm.h"
using namespace std;
void aviasm::crsymtab()
{
ofstream outs("symtab.txt",ios::out);//creating the symtab
ofstream outi("intermfile.txt",ios::out);//creating the intermediate file
ifstream in("asmfile.txt",ios::in);//opening the asmfile which i have already written
in.seekg(0,ios::beg);
char c;
string str[3];
string subset;
long locctr=0;
int i=0;
while((c=in.get())!=EOF)
{
in.putback(c);
while((c=in.get())!='\n')
{
in.putback(c); //putting back the first encountered letter
in>>str[i++]; //the asm file has three or less fields in every row
}
if(str[0].size()!=0 && str[1].size()!=0 && str[2].size()!=0)//if all 3 are there
{
if(str[1]=="start")
{
outi<<hex<<locctr;
outs<<str[1]<<" "<<locctr<<"\n";
outs<<resetiosflags(ios::hex);
outi<<" "<<str[0]<<" "<<str[1]<<" "<<str[2]<<"\n";
locctr=stol(str[2],0,16);
}//str[1]=start
}//end of all the three fields
}
in.close();
outi.close();
outs.close();
}//end of crsymtab
.....ここにサンプルのsic/xe .asmファイルがあります.....上記のコードには、コード全体をコメントアウトしても問題が発生するため、コード全体を含めていないことに注意してください。上記...発生する問題は、コードを実行するたびに発生します。
次のメッセージボックスが
'Unhandled exception at 0x00ba7046 in aviasm.exe: 0xC0000005: Access violation writing location 0xcccccccc.'
表示され、プログラムが
デバッグモードになります...また、次の関数iosfwd(std::char_traits<char>)
の行に矢印の付いた名前のファイルが表示 されます。_Left=_Right;
static void __CLRCALL_OR_CDECL assign(_Elem& _Left, const _Elem& _Right) { // assign an element _Left = _Right; }
また、ブロックの最初と最後でコンソールにいくつかの単語を出力して、
str[1]="start"
この関数が機能しているかどうかを確認します...両方の行が機能
していて、プログラムがasmから入力を正常に取得していることも確認しています。 file(これを確認しました)、intermfileとsymtabに行が出力されていません...plzヘルプ??