Assume variables A, B, C, D, and E are stored in memory locations 100, 101, 102, 103, and 104, respectively. Using any of the sample machine language instructions given in this section, translate the following pseudocode operations into machine language instruction sequences. Have your instruction sequences begin in memory location 50:
(a) Set A to the value of (B x C) – (D x E) (that is A = BC - DE). You can use a MULTIPLY and SUBTRACT command for the multiplication and subtraction, respectively.
(b) Set A to the value of (B + C) – D/E (that is A = B + C – D/E). You can use an ADD and DIVIDE command for the addition and division, respectively.
"\\& A=100, \\&B= 101, \\&C= 102, \\&D= 103" , "\\& E= 104"
Now,
If we will use MIPS then each instruction will use 32 bit and 4 bytes
So,
a)
"\\$mul(*101x*102)"
"\\$mul (*103x*104)"
"=\\$ sub(\\$mul(*101x*102),\\$mul (*103x*104))"
b)
"\\$add(*B, *C)"
"\\$div(*D,*E)"
"=\\$ sub(\\$add(*B,*C), \\$div(*D,*E))"
Comments
Leave a comment