Spring 1999, Computer Org, Assignment 4

Due Thursday 6/10 at the start of class.

  1. (4 points) In the microprogram on page 234,
    1. What would be the hex machine code for the iand3 instruction? Assume the next address field in binary is 100010001.
    2. What would be the MAL code for the hex machine code of
      0003604A4
  2. (7 points) Translate the following high level language code into IJVM symbolic instructions (like IADD, BIPUSH, etc). Make the function call and return as is described in the text. All variables are local on the stack, be sure to allocate space for them. Remember to make space for OBJREF when making the call. Use IRETURN to indicate when the main program terminates.
    main {
    	int total = 0;
    	int count;
    	int answer;
    
    	for (count = 0; count < 10; count++) {
    		answer = calculate(count, 10);
    		if (answer > 0) {
    			total += answer;
    		}
    	}
    	return 0;
    }
    
    function calculate(int count, int max) {
    	int result;
    	result = count + max - 30;
    	return result;
    }
    
    
  3. (3 points) Draw a circuit diagram for the "High Bit" box in Fig. 4-6. 
  4. (3 points) The full JVM has a special opcode for loading the third local variable: ILOAD_3. It is equivalent to ILOAD 3. However, it is only 1 byte long, with no index following it. How could this be implemented in Mic-1? Try to do it in 5 or less instructions.
  5. (3 points) State succinctly what each of the following code fragments are doing.
    1. PC = PC+1; fetch
      PC = PC+1; fetch
      H = MBRU << 8
      H = MBRU OR H
    2. MAR = SP = SP-1;rd

      TOS = MDR
    3. TOS = MDR
      MAR = SP = SP+1; wr