Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
/* * verifyMIPSInstruction * * This function verifies that the string provided to it as a paramater * contains 32 characters representing binary digits (characters '0' and * '1'), followed by a null byte. If the string contains the wrong * number of characters or contains invalid charaters (not '0' or '1'), * then the function prints an error message to stderr giving the line * number and an appropriate error message. * * int verifyMIPSInstruction (int lineNum, char instruction[]); * @param lineNum line number of current instruction (for error messages) * @param instruction string containing what should be machine code * for a MIPS instruction * Pre-condition: instruction is a null-terminated string * Post-condition: the string "instruction" has not been modified * Returns: 1 if instruction contained 32 characters representing binary * digits ('0' and '1') followed by a null byte * 0 if instruction has the wrong number of characters or * contains invalid characters * Output: Prints an error message to stderr if necessary * * Author: * with assistance from: * working side-by-side with: * * Creation Date: Creation_Date * modified: Modification_Date reason * modified: Modification_Date reason * */ /* include files go here */ #include "disUtil.h" static const int INSTR_LENGTH = 32; int verifyMIPSInstruction (int lineNum, char instr[]) /* returns 1 if instr contains INSTR_LENGTH characters representing binary * digits ('0' and '1'); 0 otherwise */ { int length; length = strlen(instr); printDebug ("\tLength: %d\n", length); if (length != INSTR_LENGTH) { printError ("Error: line %d does not have %d chars.\n", lineNum, INSTR_LENGTH); return 0; } /* CODE MISSING!!! (to verify contents of string or report error) */ return -1234; /* ridiculous & temporary; see function comments for appropriate return value at this point */ }