UMBC | CMSC 313 -- Expressions | Previous | Next |
temp = 4 / 7; i = 3 + temp;
The last one becomes:
i = (((temp1 + ((7 * 8) / 2)) - e) + (c * d)) ; // temp1 = a /b;
i = (((temp1 + (temp2 / 2)) - e) + (c * d)); // temp2 = 7 * 8; i = (((temp1 + temp3) - e) + (c * d)); // temp3 = temp2 / 2; i = ((temp4 - e) + (c * d)); // temp4 = temp1 + temp3; i = (temp5 + (c * d)); // temp5 = temp4 - e; i = (temp5 + temp6); // temp6 = c * d; i = temp7; // temp7 = temp5 + temp6;
Put it all together:
;; temp1 = a /b; ;; temp2 = 7 * 8; ;; temp3 = temp2 / 2; ;; temp4 = temp1 + temp3; ;; temp5 = temp4 - e; ;; temp6 = c * d; ;; temp7 = temp5 + temp6; ;; i = temp7;Now translate that into assembly language! It is possible to do this in less instructions, but a simple compiler would do it this way.