Commit a93ad542 authored by Masahiko Sakai's avatar Masahiko Sakai

adopt to 64bit by modifying /unsigned long/ to /unsigned int/

parent 8a17c556
malbolge20: malbolge20.c
CC -o malbolge20 malbolge20.c -lm
${CC} -o malbolge20 malbolge20.c -lm
clean:
rm -rf malbolge20 malbolge20.o
......@@ -10,13 +10,13 @@
#ifdef __GNUC__
static inline
#endif
void exec(int flag[59049], unsigned long **mem, unsigned long init[59049][2] );
void exec(int flag[59049], unsigned int **mem, unsigned int init[59049][2] );
#ifdef __GNUC__
static inline
#endif
unsigned long op( unsigned long x, unsigned long y );
void make_init_mem(int id, unsigned long **mem, unsigned long init[59049][2]);
unsigned int op( unsigned int x, unsigned int y );
void make_init_mem(int id, unsigned int **mem, unsigned int init[59049][2]);
const char xlat1[] =
"+b(29e*j1VMEKLyC})8&m#~W>qxdRp0wkrUo[D7,XTcA\"lI"
......@@ -30,10 +30,10 @@ const char xlat2[] =
int main( int argc, char **argv )
{
unsigned long **mem;
unsigned int **mem;
int flag[59049];// ブロックが使用済みか否か
unsigned long init[59050][2]; // 各ブロックの最初2つ分の初期値を記憶
unsigned long i,ii = 0;
unsigned int init[59050][2]; // 各ブロックの最初2つ分の初期値を記憶
unsigned int i,ii = 0;
int x;
for(i=0;i<59049;i++){// フラグ初期化
......@@ -51,7 +51,7 @@ int main( int argc, char **argv )
return ( 1 );
}
mem = (unsigned long **)malloc( sizeof(unsigned long) * 59049 );
mem = (unsigned int **)malloc( sizeof(unsigned int) * 59049 );
if ( mem == NULL )
{
fclose( f );
......@@ -61,7 +61,7 @@ int main( int argc, char **argv )
int id=0;
//第0ブロックのメモリ領域確保
mem[id] = (unsigned long *)malloc( sizeof(unsigned long) * 59049 );
mem[id] = (unsigned int *)malloc( sizeof(unsigned int) * 59049 );
if ( mem[id] == NULL )
{
fclose( f );
......@@ -102,7 +102,7 @@ int main( int argc, char **argv )
return ( 1 );
}
//次ブロックのメモリ領域を確保
mem[id] = (unsigned long *)malloc( sizeof(unsigned long) * 59049 );
mem[id] = (unsigned int *)malloc( sizeof(unsigned int) * 59049 );
if ( mem[id] == NULL )
{
fclose( f );
......@@ -138,7 +138,7 @@ int main( int argc, char **argv )
/* 各ブロックの遅延初期化を行うための準備をする関数 */
/* 各ブロックの最初の2ワードを計算し, initに格納 */
void make_init_mem(int id, unsigned long **mem, unsigned long init[59049][2]){
void make_init_mem(int id, unsigned int **mem, unsigned int init[59049][2]){
int i,j;
int x, y, temp0, temp1;
int num0[3][3] = {{0, 1, 2}, {0, 1, 1}, {0, 2, 2}, };
......@@ -169,7 +169,7 @@ static inline
#endif
/* JMPとMOV_Dの時に呼ばれ, その処理を実行する. */
void mem_manage(unsigned long *reg_addr, unsigned long num, int *id, unsigned long **mem, unsigned long init[59049][2], int flag[59049]){
void mem_manage(unsigned int *reg_addr, unsigned int num, int *id, unsigned int **mem, unsigned int init[59049][2], int flag[59049]){
int new_reg_addr=0;
int new_id;
int i;
......@@ -182,7 +182,7 @@ void mem_manage(unsigned long *reg_addr, unsigned long num, int *id, unsigned lo
/* 初期化されていないブロックだった場合、初期化する*/
if(flag[new_id]==UNALLOCATED){ //すでに初期化済みかチェック
mem[new_id] = (unsigned long *)malloc( sizeof(unsigned long) * 59049 );
mem[new_id] = (unsigned int *)malloc( sizeof(unsigned int) * 59049 );
if ( mem[new_id] == NULL ){
fclose( f );
free(mem);
......@@ -202,7 +202,7 @@ void mem_manage(unsigned long *reg_addr, unsigned long num, int *id, unsigned lo
}
/* 命令実行後のインクリメント. increment(c, c_id)*/
void increment(unsigned long *reg_addr, int *id, int flag[59049], unsigned long **mem, unsigned long init[59049][2]){
void increment(unsigned int *reg_addr, int *id, int flag[59049], unsigned int **mem, unsigned int init[59049][2]){
int i;
if ( *reg_addr == 59048 ){
if(*id == 59048){
......@@ -210,7 +210,7 @@ void increment(unsigned long *reg_addr, int *id, int flag[59049], unsigned long
}else{
*id+=1; *reg_addr=0;
if(flag[*id]==UNALLOCATED){ //すでに初期化済みかチェック
mem[*id] = (unsigned long *)malloc( sizeof(unsigned long) * 59049 );
mem[*id] = (unsigned int *)malloc( sizeof(unsigned int) * 59049 );
if ( mem[*id] == NULL ){
fclose( f );
fputs( "can't allocate memory\n", stderr );
......@@ -230,9 +230,9 @@ void increment(unsigned long *reg_addr, int *id, int flag[59049], unsigned long
}
void exec( int flag[59049], unsigned long **mem, unsigned long init[59049][2] )
void exec( int flag[59049], unsigned int **mem, unsigned int init[59049][2] )
{
unsigned long a = 0, c = 0, d = 0;
unsigned int a = 0, c = 0, d = 0;
int x;
int c_id=0, d_id=0;
for (;;)
......@@ -281,12 +281,12 @@ void exec( int flag[59049], unsigned long **mem, unsigned long init[59049][2] )
static inline
#endif
unsigned long op( unsigned long x, unsigned long y )
unsigned int op( unsigned int x, unsigned int y )
{
unsigned long i = 0, j;
static const unsigned long p9[10] =
unsigned int i = 0, j;
static const unsigned int p9[10] =
{ 1, 9, 81, 729, 6561 ,59049, 531441, 4782969, 43046721, 387420489};
static const unsigned long o[9][9] =
static const unsigned int o[9][9] =
{
{ 4, 3, 3, 1, 0, 0, 1, 0, 0 },
{ 4, 3, 5, 1, 0, 2, 1, 0, 2 },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment