void interpret(Task_Data *IData)
{
	char *ptr;
	int *link;
	
	if (!word(IData))
		return;
	
	link = find(IData);
	
	ptr = (char*) (link + 1);
	if (link)
	{
		int len = (int)*ptr;
		ptr = ptr + RFLAGS(len) + 1 + ((int)(RFLAGS(len) + 1) % 2);
		
		if (IData->state == 0 || len & IMMED_FLAG)
		{
			IData->xt = (void (*)())(*(TOIP(ptr)) & 0xffff);
			
			
			IData->xt(&ptr,IData);
			
			//xt();
		} else
		{
			
			compile(TOIP(ptr),IData);
		}
	} else
	{
		
		if (isnumber(IData))
		{
			if (IData->state == 0)
			{
				
				DSPUSH(number(IData),IData->dsp);
				
			} else
			{
				ptr = (char*)find_a("LITERAL",Global_Dict->latest);
				compile(TOIP(get_exec_ptr(ptr)),IData);
				compile(TOIP(number(IData)),IData);
			}
		} else
		{
			EMITERRS("Error: Unrecognized command\n");
			//stacks_reset(); have to fix this
		}
	}
	
}
static void add_header (char *name,Task_Data * IData)
{
	int len = strlen(name);
	char *ptr;
	assert(len < 64);
	
	ptr = IData->here + sizeof(int*);
	*(TOIP(IData->here)) = (int)IData->latest;
	*(ptr++) = len;
	strncpy(ptr, name, RFLAGS(len));
	IData->latest = IData->here;
	IData->here += sizeof (int*) + sizeof (char) + RFLAGS(len);
	if (((int)IData->here) % 2)
		IData->here++;
}
//this function adds the word and also makes it immediate simultaneously
static void add_word_immediate(char *name, void (*code)()){
	int len = strlen(name);
	char *ptr;
	Task_Data * IData=Global_Dict;
	assert(len < 64);
	
	ptr = IData->here + sizeof(int*);
	*(TOIP(IData->here)) = (int)IData->latest;
	*(ptr++) = (len | 128);
	strncpy(ptr, name, RFLAGS(len));
	IData->latest = IData->here;
	IData->here += sizeof (int*) + sizeof (char) + RFLAGS(len);
	if (((int)IData->here) % 2)
		IData->here++;
	compile((int*)(int)code,Global_Dict);
}
static int* find_a(char *str,char* _latest)
{
	char *link = _latest;
	int len = strlen(str);
	while (link)
	{
		if (!HIDDEN(link[sizeof(int*)]) && ((int)(RFLAGS(link[sizeof(int)])) == len) && (!strncmp(link+1+sizeof(int*), str, (int)(RFLAGS(link[sizeof(int*)])))))
		{
			return TOIP(link);
		}
		link = (char*)*(TOIP(link));
	}
	return 0;
}
예제 #5
0
파일: x86.c 프로젝트: CRYP706URU/pyrebox
bool x86_is_v8086(struct CPUState *cpu)
{
    X86CPU *x86_cpu = X86_CPU(cpu);
    CPUX86State *env = &x86_cpu->env;
    return x86_is_protected(cpu) && (RFLAGS(env) & RFLAGS_VM);
}
static char* get_exec_ptr(char *ptr)
{
	int len = RFLAGS((int)ptr[sizeof(int*)]);
	return ((ptr + len + 1 +  sizeof(int*))  +  ((int)(ptr + len + 1 +  sizeof(int*)) % 2));
}