This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Allocating 32-bit variables input/output and calculating

Assume a 32-bit input value contains 4 signed integers a, b, c and d in the packed format below:

a: input[31:23]
b: input[22:16]
c: input[15:9]
d: input[8:0].

or in binary format: aaaaaaaaabbbbbbbcccccccddddddddd

A 32-bit output value contains the result composed of 2 signed integers x and y in the format below:

x: output[26:16]
y: output[10:0]

or in binary format: 00000xxxxxxxxxxx00000yyyyyyyyyyy

Integers x and y are calculated according to the following formulas:

x = 4a + 9b , 1024 > x >= -1024

y = x + (c * d) , 1024 > y >= -1024


Write an assembly program to do the following:

Allocate and initialize a 32-bit variable called input. The initial value of input should be: 0x8534D67A

Allocate a 32-bit variable called output to hold the result of x and y in the packed format above.

Extract signed integers a, b, c and d from input into a separate register for each. (Remember to maintain the sign bit.)

Calculate x and y using the formulas above. (Remember to take care of saturation condition.)

Combine x and y into the packed format specified above and store to output

To verify the result, you should be getting:

Output = 0x05FC0400