CPS 104 Problem P3 _R_e_d_u_c_e_d _M_a_c_h_i_n_e _I_n_s_t_r_u_c_t_i_o_n _S_e_t (_R_M_I) _P_r_o_g_r_a_m_m_i_n_g The instruction set of the RMI consists of just five operations, R, P, SUB, BLTZ, and XIT, defined as follows: #include int ICT=0; #define R(F,X) \ scanf(F,&X); ICT++; #define P(F,A) \ printf(F,A); ICT++; #define SUB(X,A,B) \ X = (A=A) - B; ICT++; #define BLTZ(A,S) \ ICT++; if (A<0) goto S; #define XIT() \ printf("%d RMI Instructions executed.\n", ICT); Here, F is an appropriate format string, A and X must be scalar integer C variables, S must be a label, and B may be either an integer constant, or an integer C variable: The format string F may contain no conversion specifiers other than %c and %d, but feel free to use any characters you want which are simply copied to the output, such as "E", and "\n". Using ONLY these statements (and C declarations, and subroutine definitions and calls, but no other C commands such as "return" or "for", and no other C operators or com- parisons), write a program which does the following: Reads a series of integers from stdin, until one whose value is 0 is encountered, and for each integer I except the final 0, prints one line of output: I bbb...bbb Q j Here, I is the original number, bbb...bbb is its binary representation, consisting of 32 1s and 0s; Q is the letter E if I is even, and is the letter O (capital "o", not digit "0") if I is odd; j is the decimal representation of the value of I>>5, where I>>5 is an expression whose value is the result of shifting I RIGHT 5 bit positions. Each output field must be separated from any previous field on the line by ONE SPACE; no space should follow the last field of a line, and no other out- put should be printed, except that produced by the final XIT() command. End the program by executing command "XIT();". Your program should use fewer than 1000 RMI istructions per number processed, regardless of the size of that number. Use "submit_cps104 P3 FILE" to submit this program. I found it useful to add definitions for "ADD" and "BNZ" to these, each defined in terms of the above "given" instructions: (I assume the variables "Zero" and "M1" have previously been initialized to 0 and -1, respectively, and that variable "t" has been declared.) #define ADD(X,A,B) \ SUB(t,Zero,B); \ SUB(X,A,t); #define BNZ(A,S) \ BLTZ(A,S); \ SUB(t,Zero,A); \ BLTZ(t,S); The "#defines" above can be copied into your program, making sure that the "#" sign appears in the first column of the line. After their occurrence in the source text, state- ments like R("%d",q), and ADD(q,r,4), can appear in your program. Before using a particular variable, that variable must be declared, and you can use intialization to set its initial value to any constant, as in "int i=1;". The "\" that terminates some lines in the #defines "continues" the definition to another line of input; the"body" of a #define extends to the end of the current logical line of text. To allow "define bodies" of several input lines, the "\" is used to end intermediate input lines that don't end the log- ical line. To return a value from a subroutine without using "return", try defining a global variable into which the sub- routine stores the value it wants to return. A statement STMNT in C can be given a label, XXX, by writing XXX: STMNT Then executing "goto XXX;" from within the same - 2 - subroutine causes the statement labeled XXX to be executed next.