Like Tree2Likes
  • 2 Post By stahta01

Mips64 assembly language

This is a discussion on Mips64 assembly language within the Tech Board forums, part of the Community Boards category; Code: W = 1; forever { if (n % 2 != 0) w *= x; n /= 2; if (n ...

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    1

    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
    Last edited by Salem; 10-29-2012 at 11:02 PM. Reason: demunged the tagging horror

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,505
    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.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    838
    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

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    2,370
    Quote Originally Posted by Nominal Animal View Post
    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.

  5. #5
    Registered User
    Join Date
    Oct 2011
    Posts
    838
    Quote Originally Posted by Elkvis View Post
    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.

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    2,553
    Quote Originally Posted by Elkvis View Post
    reminds me a bit of COBOL's verbosity.
    Quote Originally Posted by Nominal Animal View Post
    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.
    Elkvis and laserlight like this.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Assembly Language Help ;)
    By shrink_tubing in forum C++ Programming
    Replies: 24
    Last Post: 03-10-2011, 11:47 PM
  2. Assembly language ???
    By kinda in forum C Programming
    Replies: 7
    Last Post: 11-02-2010, 08:28 PM
  3. Assembly language.
    By JOZZY& Wakko in forum Tech Board
    Replies: 0
    Last Post: 12-18-2009, 04:58 AM
  4. help in assembly language
    By ema in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 12-14-2002, 01:22 AM
  5. Assembly Language...
    By Yoshi in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 12-20-2001, 09:04 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21