Пример #1
0
//done
void scan_operands (operands_t operands) {
  printf("scan_operands() for %s\n", lc3_get_format_name(operands));
  int operandCount = 0;
  int numOperands  = count_bits(operands);
  int errorCount   = numErrors;
  for (operand_t op = FMT_R1; op <= FMT_STR; op <<= 1) {
    //if the bits are set
    //printf(" ");
    if(op & operands){
      //create a token
      char* token = next_token();
      //get the operand of that token
      if(token != NULL){
      get_operand(op,token);
      
        //if errorocunt is not equal return
       if (errorCount != numErrors)
        return; // error, so skip processing remainder of line
      //inc operand count
      operandCount++;
      //if the count is less then the operands 
      if(operandCount < numOperands){
        //get comma or error
        get_comma_or_error();
      }
      //check errorcount again
      if (errorCount != numErrors)
      return; // error, so skip processing remainder of line

    }
  }
  }
}
Пример #2
0
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); 
	}
      }
    }
  }
}