int main (int argc, char* argv[]) { if (argc != 2) { printf("Usage: seeLC3 opcode\n"); printf("e.g. seeLC3 ADD\n"); } else { opcode_t opcode = util_get_opcode(argv[1]); LC3_inst_t* info = lc3_get_inst_info(opcode); if (! info) { printf("%s is no an opcode\n", argv[1]); } else { printf("form bit:%2d\n", info->formBit); for (int i = 0; i < 2; i++) { if (info->forms[i].name != NULL) { printf("form: %d name: %s operands: %s operandsnum: %d prototype x%04x\n", i, info->forms[i].name, lc3_get_format_name(info->forms[i].operands), info->forms[i].operands, //operand numeric representatio info->forms[i].prototype); } } } } }
//done char* check_for_label (char* token) { if(util_get_opcode (token) == -1){ //if it is then is it a vaild label? if(util_is_valid_label(token)){ //if it is a vaild label add that shit //return the next token broski //fprintf(stderr, "adding symbol: %s\n",token); if(symbol_add(lc3_sym_tab,token,currAddr) == 0){ asm_error(ERR_DUPLICATE_LABEL,token); } return next_token(); } else{ //damn that shit anint wokring right asm_error(ERR_BAD_LABEL,token); } } return token; }
//done void check_line_syntax (char* token) { printf("check_line_syntax('%s')\n", token); //check if its a label token = check_for_label(token); printf(" my token is %s \n ", token); //store the op in an int if(token == NULL) return; int myop = util_get_opcode(token); printf("opcode is: %d\n", myop ); //store it itno my data structure.. currInfo -> opcode = myop; if(myop == OP_BR){ currInfo->reg1 = util_parse_cond(token+2); token = next_token(); currInfo->reference = strdup(token); //get_operand(op,token); } LC3_inst_t* inst = lc3_get_inst_info(myop); printf("inst is: %p \n" , inst); int position = 0; if(strcasecmp(inst ->forms[0].name,token) != 0){ position = 1; } /*if(inst ->forms[1].name != NULL &&strcasecmp(inst ->forms[1].name,token) == 0){ position = 1; if(strcasecmp(inst ->forms[0].name,token) != 0) position = 1; }*/ if(myop != OP_BR){ currInfo->form=position;} printf("%d\n whats my position", position); operands_t format = inst -> forms[position].operands; scan_operands(format); }