This exercise is intended to help you understand the process of turning a formula into assembly-language code.
It is not a homework assignment and will not be graded.
You need to write a program.
NUM1 DC F'317' NUM2 DC F'-9' NUM3 DC F'40' NUM4 DC F'18' NUM5 DC F'3' RESULT DS F
RESULT = (NUM1 - NUM2) / NUM4 + NUM3 * NUM5
As this is binary arithmetic, we will need to use some registers. As multiplication and division are both involved, we will need at least 4 registers, 2 for each operation.
You may want to insert XDUMP into the code here and there to watch what is happening to the values in the registers.
L 5,NUM1 5 now contains the number 317 S 5,NUM2 Subtract M 4,=F'1' Extend the sign to a 64-bit value D 4,NUM4 Divide
We now have the quotient in register 5. Notice we had to plan ahead, as division requires an even-odd pair of registers.
L 7,NUM3 7 now contains the number 40 M 6,NUM5 Multiply
The product is now in registers 6 and 7, 64 bits long. As the numbers are small, only the part in register 7 is significant.
AR 5,7 Add ST 5,RESULT Store the sum
RESULT = NUM1 / (NUM2 + NUM3) + NUM4 / NUM5