github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/cmd/obj/mips/list0.go (about)

     1  // cmd/9l/list.c from Vita Nuova.
     2  //
     3  //	Copyright © 1994-1999 Lucent Technologies Inc.  All rights reserved.
     4  //	Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
     5  //	Portions Copyright © 1997-1999 Vita Nuova Limited
     6  //	Portions Copyright © 2000-2008 Vita Nuova Holdings Limited (www.vitanuova.com)
     7  //	Portions Copyright © 2004,2006 Bruce Ellis
     8  //	Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
     9  //	Revisions Copyright © 2000-2008 Lucent Technologies Inc. and others
    10  //	Portions Copyright © 2009 The Go Authors. All rights reserved.
    11  //
    12  // Permission is hereby granted, free of charge, to any person obtaining a copy
    13  // of this software and associated documentation files (the "Software"), to deal
    14  // in the Software without restriction, including without limitation the rights
    15  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    16  // copies of the Software, and to permit persons to whom the Software is
    17  // furnished to do so, subject to the following conditions:
    18  //
    19  // The above copyright notice and this permission notice shall be included in
    20  // all copies or substantial portions of the Software.
    21  //
    22  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    23  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    24  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    25  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    26  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    27  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    28  // THE SOFTWARE.
    29  
    30  package mips
    31  
    32  import (
    33  	"fmt"
    34  
    35  	"github.com/go-asm/go/cmd/obj"
    36  )
    37  
    38  func init() {
    39  	obj.RegisterRegister(obj.RBaseMIPS, REG_LAST+1, rconv)
    40  	obj.RegisterOpcode(obj.ABaseMIPS, Anames)
    41  }
    42  
    43  func rconv(r int) string {
    44  	if r == 0 {
    45  		return "NONE"
    46  	}
    47  	if r == REGG {
    48  		// Special case.
    49  		return "g"
    50  	}
    51  	if REG_R0 <= r && r <= REG_R31 {
    52  		return fmt.Sprintf("R%d", r-REG_R0)
    53  	}
    54  	if REG_F0 <= r && r <= REG_F31 {
    55  		return fmt.Sprintf("F%d", r-REG_F0)
    56  	}
    57  	if REG_M0 <= r && r <= REG_M31 {
    58  		return fmt.Sprintf("M%d", r-REG_M0)
    59  	}
    60  	if REG_FCR0 <= r && r <= REG_FCR31 {
    61  		return fmt.Sprintf("FCR%d", r-REG_FCR0)
    62  	}
    63  	if REG_W0 <= r && r <= REG_W31 {
    64  		return fmt.Sprintf("W%d", r-REG_W0)
    65  	}
    66  	if r == REG_HI {
    67  		return "HI"
    68  	}
    69  	if r == REG_LO {
    70  		return "LO"
    71  	}
    72  
    73  	return fmt.Sprintf("Rgok(%d)", r-obj.RBaseMIPS)
    74  }
    75  
    76  func DRconv(a int) string {
    77  	s := "C_??"
    78  	if a >= C_NONE && a <= C_NCLASS {
    79  		s = cnames0[a]
    80  	}
    81  	var fp string
    82  	fp += s
    83  	return fp
    84  }