int is_valid_args(char *mnemonic, char **args) { char arg_type; int it; op_t op; it = 0; op = get_op(mnemonic); while (args[it] != NULL) { arg_type = get_arg_type(args[it]); if ((op.type[it] & arg_type) == 0) return (0); it++; } return (1); }
ArgInfo * read_ArgInfo_line(char * line) { ArgInfo * out; char * runner; char * fix; out = ArgInfo_alloc(); for(runner=line;*runner && !isalpha(*runner) ;runner++) ; fix = runner; for(runner=line;*runner && iscword(*runner);runner++) ; /*** got first word ***/ *runner = '\0'; out->name = stringalloc(fix); /*** next word ***/ for(runner++;*runner && !isalpha(*runner);runner++) ; /*** if it is a valid arg type, get it and move on ***/ if( (out->argtype=get_arg_type(runner,&out->should_NULL)) != ARGTYPE_UNKNOWN) { for(;*runner && isalnum(*runner);runner++) ; for(;*runner && isspace(*runner);runner++) ; } fix = runner; for(;*runner && *runner != '\n';runner++) ; *runner = '\0'; out->desc = stringalloc(fix); return out; }
/* * Load one action attribute. */ static int get_action_attribute( FILE * inFile, ABObj obj, ABObj module, ABObj action, AB_GIL_ATTRIBUTE attr ) { int return_value = 0; int rc = 0; /* r turn code */ if (abio_get_eof(inFile)) { return (abil_print_load_err(ERR_EOF), -1); } switch (attr) { case AB_GIL_FROM: rc = get_from(inFile, obj, module, action); break; case AB_GIL_ACTION: rc = get_operation(inFile, action); break; case AB_GIL_TO: rc = get_to(inFile, obj, module, action); break; case AB_GIL_WHEN: rc = get_when(inFile, obj, action); break; case AB_GIL_FUNCTION_TYPE: rc = get_function_type(inFile, action); break; case AB_GIL_ARG_TYPE: rc = get_arg_type(inFile, action); break; default: abil_print_load_err(ERR_UNKNOWN); } return return_value; }
void instr_st(vm_t* vm, warrior_t* warrior) { char code = vm_read_char(vm, warrior); int reg = vm_read_int(vm, warrior); if (reg < 1 || reg > REG_NUMBER) { warrior->pc += sizeof(int); return; /* we don't have that reg. */ } if (get_arg_type(2, code) == T_REG) { int reg_read = vm_read_int(vm, warrior); if (reg_read < 1 || reg_read > REG_NUMBER) { return; /* we don't have that reg. */ } warrior->regs[reg - 1] = warrior->regs[reg_read - 1]; } else { int offset = vm_read_int(vm, warrior); warrior->regs[reg - 1] = read_int(vm->memory + (warrior->pc + (offset % IDX_MOD)) % MEM_SIZE); } }
OperationData::OperationData( int argc, char *argv[] ) { spc_mode = true; show_help = false; hirom = false; verbose_mode = false; banknumber = 5; // search for params for( int arg = 1; arg < argc; ) { int ptype = get_arg_type( argv[arg] ); switch( ptype ) { case ARG_INVALID: // nothing arg++; break; case ARG_OPTION: // long command #define TESTARG2(str1,str2) (strmatch( argv[arg], str1 ) || strmatch( argv[arg], str2 )) if( TESTARG2( "--soundbank", "-s" ) ) { spc_mode = false; } else if( TESTARG2( "--output", "-o" ) ) { arg++; if( arg == argc ) { printf( "\nERROR: No output file specified." ); return; } output = argv[arg]; } else if( TESTARG2( "--hirom", "-i" )) { hirom = true; } else if( TESTARG2( "--verbose", "-v" )) { verbose_mode = true; } else if( TESTARG2( "--help", "-h" )) { show_help = true; } else if( strmatch( argv[arg], "-b" ) ) { arg++; if( arg == argc ) { printf( "\nERROR: No bank number specified." ); return; } if (isdigit(argv[arg][0])) { banknumber = atoi(argv[arg]); } else { printf( "\nERROR: Incorrect bank number." ); return; } } arg++; break; case ARG_INPUT: // input files.push_back( argv[arg] ); arg++; break; } } if( spc_mode ) { if( output.empty() ) { if( !files.empty() ) { output = files[0]; int extstart = output.find_last_of('.'); output = output.substr( 0 ,extstart ); output += ".spc"; } } } }