MIPS Assembly Coding how can I calculate this in assembly t0

MIPS- Assembly Coding:

how can I calculate this in assembly:

[($t0)-2017]*365 + [($t1)-1]*30 + $t2

$t0 = register t0, have a integervalue inputed by the user

minus 2017

all multiplied by 365

+

$t1 = register t1, again integervalue given by user earlier in program

minus 1

all multiplied by 30

+

$t2 = register t2, again another integer value given by user earlier in the program

Solution

Load r1, $t0

sub r1, 2017,r1 ; Subtract the values and store the result in r1

mul r1*365, r1 ; Multiply the result with 365 and store the result in r1

load r2, $t1

sub r2,1, r2 ; subtract the values and store the value in r2

mul r2, 30, r2 ; multiply the result of above statement and store it in r2

load r3, $t2

add r1,r2, r1 ; add the results of r1 and r2 and store the result in r1

add r1, r3,r1 ; add the results of r1 and r3 and store the result in r1

store r1, result ; result being the variable where final values are stored

MIPS- Assembly Coding: how can I calculate this in assembly: [($t0)-2017]*365 + [($t1)-1]*30 + $t2 $t0 = register t0, have a integervalue inputed by the user mi

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site