HW2_Chp4

docx

School

Prairie View A&M University *

*We aren’t endorsed by this school

Course

2319

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

3

Uploaded by martaesia1216

Report
Homework 2 (Chapter 4) Question 1: (a) [20 points] Translate the following C++ code segment into Mic-1 IJVM machine language, assuming i, j, and k are the first, the second and third local variables, respectively. (b) [15 points] Translate the code segment in Mic-1 IJVM instructions you derive above into machine instructions. Please use hexadecimals to represent machine language instructions. (c) [20 points] Assuming the initial values of the three local variables are i=3, j=2, k=1, how long does a 2-GHz Mic-1 take to execute this C++ code segment? Give your answer in nanoseconds. C++ sentences Mic-1 IJVM instructions Machine Instructions Time clock cycles needed i=i+j; if (i==5) k=i&&j; else k=i||j;
Question 2: [15 points ] Write microcode for the Mic-1 to implement the IJVM DUPTHREE instruction. This instruction copies the current top word on stack and pushes it onto stack two times. Question 3: [20 points] In Mic-1 , we know each microinstruction has 36 bits. Please (1) use your words to describe what actions the following microinstruction does and (2) define its 36 bits: OPC = MAR = LV ADD H; rd; goto Main1 Assume the micro-address of Main1 is 000000000 (binary). Question 4: [10 points] Give the Java statement that produced the following IJVM code, and briefly describe what this piece of code does. BIPUSH 0 ISTORE i BIPUSH 0 ISTORE j AGN: ILOAD i BIPUSH 1 IADD ISTORE i ILOAD i ILOAD j IADD ISTORE j ILOAD i BIPUSH 5 IF_ICMPEQ STOP GOTO AGN STOP: ……
Notes: 1. Name your file as “Last name, First name_hw2.docx/.pdf”, for example, my last name is Wang and first name is Yonghui, so, my word file will be named as “Wang, Yonghui_hw2.docx” 2. Submit your answers to eCourses either in a word file or in a pdf file; 3. Due time: 11/8/2023, 11:59pm
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help