Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following code multiplies two vectors that contain single-precision complex

ID: 3768830 • Letter: T

Question

The following code multiplies two vectors that contain single-precision complex values.

for ( i = 0; i < 64; i++ )

c_re[i] = a_re[i] * b_re[i] – a_im[i] * b_im[i];

c_im[i] = a_re[i] * b_im[i] – a_im[i] * b_re[i];

Using the following vector instructions and assuming the processor has a maximum vector length of 64, convert the above code to to VMIPS assembly code.

lv, sv                     : load/store vector

addv.s                   : add vectors of single-precision

addvs.s                 : add scalar to each element of vector of single-precision

subv.s                   : sub vectors of single-precision

subvs.s                 : sub scalar to each element of vector of single-precision

mulv.s                  : multiply vectors of single-precision

mulvs.s : multiply scalar to each element of vector of single-precision

Explanation / Answer

VMIPS Assembly code

li   $r1,0
loop: lv   $v1,a_re+$r1
lv   $v3,b_re+$r1
mulvv,s   $v5,$v1,$v3
lv   $v2,a_im+$r1
lv   $v4,b_im+$r1
mulvv,s   $v6,$v2,$v4
subvv,s   $v5,$v5,$v6
sv   $v5,c_re+$r1
mulvv,s   $v5,$v1,$v4
mulvv,s   $v6,$v2,$v3
subvv,s   $v5,$v5,$v6
sv   $v5,c_im+$r1
bne   $r1,0,else
j loop
else: addi   $r1,$r1,#1

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote