Exemplo n.º 1
0
int _tmain(int argc, _TCHAR* argv[])
{

	stack_t st1 = {};
	cpu stk1 = {};
	Stack_ctor(&stk1, &st1);


	char* argvName = (char*)calloc(wcslen(argv[0]), sizeof(argvName));
	size_t len = wcstombs(argvName, argv[0], wcslen(argv[0]));

	//for (int i = 0; i < argc; i++)
		//std::cout << argv[i] << std::endl;
	//	wprintf(L"%s \n", argv[i]);

	//const char* argv1 = "commands.asm";
	int CountOfCom = 0;
	const int* commandBuff = ReadComm(argv[argc - 1], &CountOfCom);
	int ResultOfDo = doCommand(&stk1, commandBuff, argv[argc - 1], CountOfCom);
	//if (ResultOfDo == 0) printf("Wrong Command. \n"
	//	"WHAT ARE YOU DOING? READ HELP ONE'S MORE TIME!");

	Stack_dtor(&st1);
	Stack_dtor(&stk1);  
	
	return 0;
}
Exemplo n.º 2
0
void CPU_ctor(CPU_t* This) {
    assert(This);
    Stack_ctor(&This->stack);
    printf("The %d memory has been callocated for stack\n",STACK_SIZE);
    This->cmd_num = 20;
    This->cmd = (int*) calloc(This->cmd_num, sizeof(int));
    printf("The %d memory has been callocated for commands\n",STACK_SIZE);
    for (int k = 0; k<=REG_NUM; k++) {
        This->R[k] = 0;
    };
    This->cmp_flag = 0;
    This->pc = 0;
}