# Mips64 assembly language

• 10-29-2012
ammuga
Mips64 assembly language
Code:

``` W = 1; forever {   if (n % 2 != 0)     w *= x;   n /= 2;   if (n == 0)     break;   x *= x; }```
How To CONVERT This pgm TO MIPS64 ASSEMBLY LANGUAGE
• 10-29-2012
Salem
I guess the first place to start is by locating a MIPS64 instruction reference, possibly on the web.
But your instructor should be able (and indeed should have already done so) to give you such a reference.

Then you can look up instructions for assignment, mul, div, comparisons and jumps.
• 10-30-2012
Nominal Animal
Also, you could start by rewriting it into assembly pseudocode (not specific to any architecture, just generally assembly-like). For example:
Code:

```# Calculate W = XN set N = set X = set W = 1 loop:     test bit 0 in N     if clear, jump to okay     multiply W and X, saving result in W okay:     multiply X by X, saving result in X     shift N one bit down (right)     compare N to zero     if not equal, jump to loop```
• 10-30-2012
Elkvis
Quote:

Originally Posted by Nominal Animal
Also, you could start by rewriting it into assembly pseudocode (not specific to any architecture, just generally assembly-like). For example:
Code:

```# Calculate W = XN set N = set X = set W = 1 loop:     test bit 0 in N     if clear, jump to okay     multiply W and X, saving result in W okay:     multiply X by X, saving result in X     shift N one bit down (right)     compare N to zero     if not equal, jump to loop```

reminds me a bit of COBOL's verbosity.
• 10-30-2012
Nominal Animal
Quote:

Originally Posted by Elkvis
reminds me a bit of COBOL's verbosity.

Hey, that was uncalled for! ;) No need to insult, I was just trying to help someone learn.

When learning programming, it is important to learn how to express yourself in terms appropriate for the language. Assembly directives and opcodes are all very simple, performing just one simple action at a time.

I thought that breaking down a high level code snippet to the very basic operations needed to achieve the same results would be instructive.
• 10-30-2012
stahta01
Quote:

Originally Posted by Elkvis
reminds me a bit of COBOL's verbosity.

Quote:

Originally Posted by Nominal Animal
Hey, that was uncalled for! ;) No need to insult, I was just trying to help someone learn.

When learning programming, it is important to learn how to express yourself in terms appropriate for the language. Assembly directives and opcodes are all very simple, performing just one simple action at a time.

I thought that breaking down a high level code snippet to the very basic operations needed to achieve the same results would be instructive.

Yes, you have to be careful with remarks like this or the whole thing can SNOBOL.

Tim S.