コード例 #1
0
ファイル: vm_minimal.c プロジェクト: oriansj/stage0
void execute_vm(struct lilith* vm)
{
	struct Instruction* current;
	current = calloc(1, sizeof(struct Instruction));

	while(!vm->halted)
	{
		read_instruction(vm, current);
		eval_instruction(vm, current);
	}

	free(current);
	return;
}
コード例 #2
0
ファイル: eval.c プロジェクト: zbenjamin/vmscheme
void
eval_instructions(struct vm_context **ctx)
{
  while (! eval_instruction(ctx)) { }
}
コード例 #3
0
ファイル: vasm.c プロジェクト: ezrec/vasm
static void assemble(void)
{
    section *sec;
    atom *p;
    char *attr;
    int bss;

    final_pass=1;
    for(sec=first_section; sec; sec=sec->next) {
        source *lasterrsrc=NULL;
        int lasterrline=0;
        sec->pc=sec->org;
        attr=sec->attr;
        bss=0;
        while(*attr) {
            if(*attr++=='u') {
                bss=1;
                break;
            }
        }
        for(p=sec->first; p; p=p->next) {
            sec->pc=(sec->pc+p->align-1)/p->align*p->align;
            cur_src=p->src;
            cur_src->line=p->line;
            if(p->list&&p->list->atom==p) {
                p->list->sec=sec;
                p->list->pc=sec->pc;
            }
            if(p->type==INSTRUCTION) {
                dblock *db;
                cur_listing=p->list;
                db=eval_instruction(p->content.inst,sec,sec->pc);
                if(pic_check)
                    do_pic_check(db->relocs);
                cur_listing=0;
                if(DEBUG) {
                    if(db->size!=instruction_size(p->content.inst,sec,sec->pc))
                        ierror(0);
                }
                /*FIXME: sauber freigeben */
                myfree(p->content.inst);
                p->content.db=db;
                p->type=DATA;
            }
            else if(p->type==DATADEF) {
                dblock *db;
                cur_listing=p->list;
                db=eval_data(p->content.defb->op,p->content.defb->bitsize,sec,sec->pc);
                if(pic_check)
                    do_pic_check(db->relocs);
                cur_listing=0;
                /*FIXME: sauber freigeben */
                myfree(p->content.defb);
                p->content.db=db;
                p->type=DATA;
            }
            else if(p->type==RORG) {
                sblock *sb;
                taddr space;
                if(eval_expr(p->content.roffs,&space,sec,sec->pc)) {
                    space=sec->org+space-sec->pc;
                    if (space>=0) {
                        sb=new_sblock(number_expr(space),1,0);
                        p->content.sb=sb;
                        p->type=SPACE;
                    }
                    else
                        general_error(20);  /* rorg is lower than current pc */
                }
                else
                    general_error(30);  /* expression must be constant */
            }
            else if(p->type==DATA&&bss) {
                if(lasterrsrc!=p->src||lasterrline!=p->line) {
                    general_error(31);  /* initialized data in bss */
                    lasterrsrc=p->src;
                    lasterrline=p->line;
                }
            }
#ifdef HAVE_CPU_OPTS
            else if(p->type==OPTS)
                cpu_opts(p->content.opts);
#endif
            else if(p->type==PRINTTEXT)
                printf("%s\n",p->content.ptext);
            else if (p->type==PRINTEXPR) {
                taddr val;
                eval_expr(p->content.pexpr,&val,sec,sec->pc);
                printf("%ld (0x%lx)\n",(long)val,(unsigned long)val);
            }
            sec->pc+=atom_size(p,sec,sec->pc);
        }
    }
}