Doubt if my pseudo code in Assembly is right

Asked

Viewed 33 times

0

Oops, hello, good afternoon! I am in doubt if my pseudo code on Assembly is correct, if anyone can verify and explain to me why it is wrong I would appreciate it very much.

The code is simple. Imagine that I want to pass this passage:

for (int i = 1; i <= k; i++) {
    b = b + n[i] * 2;
}

For a micro Assembly code, I got to this code.

0:  $i := 1;
1:  mar := $k; rd;
2:  ac := mbr + 1;
3:  ac := ac + inv($i); if n then goto 10;
4:  ac := $n;
5:  ac := ac + $i;
6:  mar := ac; rd;
7:  ac := mbr + mbr;
8:  $b := ac + $b;
9:  $i := $i + 1; goto 1;
10:

But I don’t know if I made a mistake because I’m learning Assembly now.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.