Write a program equivalent to the C language assignment
statement
z = a + (b * c) + (d * e) - (f / g) - (h * i);
Use only:
(a) Three-address instructions
(b) Two-address instructions
Please explain the process as clearly as possible. I would like to LEARN how this is done in so little address instructions. Thank you.
z = a + (b * c) + (d * e) - (f / g) - (h * i)
(a) Three-address instructions
It is assumed that the computer has two processor registers, R1 and R2. The symbol M [A] denotes the operand at memory address A.
Every instruction has 2 source operands and a destination register/memory address
Instruction format : Operation destination operand, source operand1, source operand2.
destination operand = source operand1 Operation source operand2.
MUL R1, b, c -------- R1 <- M[b] * M[c] R1 = b * c
MUL R2, d, e -------- R2 <- M[d] * M[e] R2 = d * e
ADD R1, R1, R2 ---- R1 <- R1 + R2 R1 = (b * c) + (d * e)
DIV R2, f, g ---------- R2 <- M[f] / M[g] R2 = f / g
SUB R1, R1, R2 ---- R1 <- R1 - R2 R1 = (b * c) + (d * e) - (f / g)
MUL R2, h, i --------- R2 <- M[h] * M[i] R2 = h * i
SUB R1, R1, R2 ---- R1 <- R1 - R2 R1 = (b * c) + (d * e) - (f / g) - (h * i)
ADD z, R1, R2 ------ z <- R1 + R2 z = a + (b * c) + (d * e) - (f / g) - (h * i)
(b) Two-address instructions
Every instruction has 2 source operands and the first source operand acts as the destination register/memory address
Instruction format : Operation destination operand, source operand
destination operand = destination operand Operation source operand.
MOV R1, b ------ R1 <- M[b] R1 = b
MUL R1, c ------ R1 <- R1 * c R1 = b*c
MOV R2, d ----- R2 <- M[d] R2 = d
MUL R2, e ------ R2 <- R2 * e R2 = d*e
ADD R1, R2 ---- R1 <- R1 + R2 R1 = (b * c) + (d * e)
MOV R2, f ------ R2 <- M[f] R2 = f
DIV R2, g ------- R2 <- R2 / g R2 = f/g
SUB R1, R2 ---- R1 <- R1 - R2 R1 = (b * c) + (d * e) - (f / g)
MOV R2, h ----- R2 <- M[h] R2 = f
MUL R2, i ------ R2 <- R2 * i R2 = h*i
SUB R1, R1, R2 ----- R1 <- R1 - R2 R1 = (b * c) + (d * e) - (f / g) - (h * i)
ADD R1, a -------- R1 <- R1 + a R1 = a + (b * c) + (d * e) - (f / g) - (h * i)
MOV z, R1 ------- z <- R1 z = a + (b * c) + (d * e) - (f / g) - (h * i)
Write a program equivalent to the C language assignment statement z = a + (b *...
Write a C++ program that computes a student’s grade for an assignment as a percentage given the student’s score and the total points. The final score should be rounded up to the nearest whole value using the ceil function in the <math> header file. You should also display the floating-point result up to 5 decimal places. The input to the program must come from a file containing a single line with the score and total separated by a space. If...
I am using programming language of DEV C++, and here is my assignment. Write a program, maxmin.c to find the maximum and minimum of values in the file maxminin.txt. Your output should look like: There are 6 values in the file The maximum value is 9.500000 The minimum value is 1.100000 and this is maxminin.txt: 8.2 1.1 3.7 2.2 9.5 4.3
Write an assembly language program that evaluates X = (A + B) / (C-D) considering each of the following instruction formats: a) Three-address instruction format b) Two-Address instruction format c) One-address instruction format
Write a program that counts the number of characters and words in the following statement: This is a long exercise. I would like to get done with it. END Hint: In order to count words, count the transitions from non-white space to white space characters Please use C Language and complete program.
Please help and explain in detail! For practice! Write the assembly language equivalent of the following MARIE machine language instructions: a. 0100010111000010 b. 0001001110011010 c. 1100000101101100
2. a)Write the ARM ALP conditional code snippet for the following statements written in C-language. Assume R1 to Rn as06 variables Let R1, R2, R3 contain the starting addresses of arrays X, Y and Z respectively Use Register R4 for variable i. Display appropriate messages. While (i+10) else Z[i] XiYi; b)i Write a program to display a message "This is an examination Question" on the screen using 06 a function sub program Note the following Address of the string to...
This program is in C language: Write a statement that reads a decimal integer from standard input and stores it into a variable named boxes. -------------------------------- Everything I enter is wrong, can someone help me out.
1. [2 points] Write a MIPS assembly language program of the following C function and the code to call the function: int leaf_example (int g, h, i, j) { int f; f = (g + h) - (i + j); return f; مهه Arguments g, h, i, and j are passed to the function in registers $a0, $al, Şa2, and $a3, respectively while f in $50 (hence, need to save $50 on stack), and the result is to be stored...
please use the c language
Assignment 12 The program to write in this assignment is a program that calculates score statistics and manages the grades of the students. First, the student list and are given in a file named "student.dat" as in the following: 이성우 77 홍길동 88 scores 201 1710086 2012700091 This program reads the input file "student.dat" and keeps this data in a linear linked list. Each node must be a struct which contains the following: student id...
in c++ language 1.Re-write the following for loop statement by using a while loop statement: int sum = 0; for(int i=0;i<=1000;i++){ sum+=i; } 1 (b). Following is the main () function of a program. The program asks a user to enter 150 integers and print the largest integer user entered. int main() { int score, highest; //missing portion of the program return 0; } 1(c). Find the missing portion of the following code, so the...