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

     1  // Inferno utils/6c/list.c
     2  // https://bitbucket.org/inferno-os/inferno-os/src/master/utils/6c/list.c
     3  //
     4  //	Copyright © 1994-1999 Lucent Technologies Inc.  All rights reserved.
     5  //	Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
     6  //	Portions Copyright © 1997-1999 Vita Nuova Limited
     7  //	Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
     8  //	Portions Copyright © 2004,2006 Bruce Ellis
     9  //	Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
    10  //	Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
    11  //	Portions Copyright © 2009 The Go Authors. All rights reserved.
    12  //
    13  // Permission is hereby granted, free of charge, to any person obtaining a copy
    14  // of this software and associated documentation files (the "Software"), to deal
    15  // in the Software without restriction, including without limitation the rights
    16  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    17  // copies of the Software, and to permit persons to whom the Software is
    18  // furnished to do so, subject to the following conditions:
    19  //
    20  // The above copyright notice and this permission notice shall be included in
    21  // all copies or substantial portions of the Software.
    22  //
    23  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    24  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    25  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    26  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    27  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    28  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    29  // THE SOFTWARE.
    30  
    31  package x86
    32  
    33  import (
    34  	"fmt"
    35  
    36  	"github.com/go-asm/go/cmd/obj"
    37  )
    38  
    39  var Register = []string{
    40  	"AL", // [D_AL]
    41  	"CL",
    42  	"DL",
    43  	"BL",
    44  	"SPB",
    45  	"BPB",
    46  	"SIB",
    47  	"DIB",
    48  	"R8B",
    49  	"R9B",
    50  	"R10B",
    51  	"R11B",
    52  	"R12B",
    53  	"R13B",
    54  	"R14B",
    55  	"R15B",
    56  	"AX", // [D_AX]
    57  	"CX",
    58  	"DX",
    59  	"BX",
    60  	"SP",
    61  	"BP",
    62  	"SI",
    63  	"DI",
    64  	"R8",
    65  	"R9",
    66  	"R10",
    67  	"R11",
    68  	"R12",
    69  	"R13",
    70  	"R14",
    71  	"R15",
    72  	"AH",
    73  	"CH",
    74  	"DH",
    75  	"BH",
    76  	"F0", // [D_F0]
    77  	"F1",
    78  	"F2",
    79  	"F3",
    80  	"F4",
    81  	"F5",
    82  	"F6",
    83  	"F7",
    84  	"M0",
    85  	"M1",
    86  	"M2",
    87  	"M3",
    88  	"M4",
    89  	"M5",
    90  	"M6",
    91  	"M7",
    92  	"K0",
    93  	"K1",
    94  	"K2",
    95  	"K3",
    96  	"K4",
    97  	"K5",
    98  	"K6",
    99  	"K7",
   100  	"X0",
   101  	"X1",
   102  	"X2",
   103  	"X3",
   104  	"X4",
   105  	"X5",
   106  	"X6",
   107  	"X7",
   108  	"X8",
   109  	"X9",
   110  	"X10",
   111  	"X11",
   112  	"X12",
   113  	"X13",
   114  	"X14",
   115  	"X15",
   116  	"X16",
   117  	"X17",
   118  	"X18",
   119  	"X19",
   120  	"X20",
   121  	"X21",
   122  	"X22",
   123  	"X23",
   124  	"X24",
   125  	"X25",
   126  	"X26",
   127  	"X27",
   128  	"X28",
   129  	"X29",
   130  	"X30",
   131  	"X31",
   132  	"Y0",
   133  	"Y1",
   134  	"Y2",
   135  	"Y3",
   136  	"Y4",
   137  	"Y5",
   138  	"Y6",
   139  	"Y7",
   140  	"Y8",
   141  	"Y9",
   142  	"Y10",
   143  	"Y11",
   144  	"Y12",
   145  	"Y13",
   146  	"Y14",
   147  	"Y15",
   148  	"Y16",
   149  	"Y17",
   150  	"Y18",
   151  	"Y19",
   152  	"Y20",
   153  	"Y21",
   154  	"Y22",
   155  	"Y23",
   156  	"Y24",
   157  	"Y25",
   158  	"Y26",
   159  	"Y27",
   160  	"Y28",
   161  	"Y29",
   162  	"Y30",
   163  	"Y31",
   164  	"Z0",
   165  	"Z1",
   166  	"Z2",
   167  	"Z3",
   168  	"Z4",
   169  	"Z5",
   170  	"Z6",
   171  	"Z7",
   172  	"Z8",
   173  	"Z9",
   174  	"Z10",
   175  	"Z11",
   176  	"Z12",
   177  	"Z13",
   178  	"Z14",
   179  	"Z15",
   180  	"Z16",
   181  	"Z17",
   182  	"Z18",
   183  	"Z19",
   184  	"Z20",
   185  	"Z21",
   186  	"Z22",
   187  	"Z23",
   188  	"Z24",
   189  	"Z25",
   190  	"Z26",
   191  	"Z27",
   192  	"Z28",
   193  	"Z29",
   194  	"Z30",
   195  	"Z31",
   196  	"CS", // [D_CS]
   197  	"SS",
   198  	"DS",
   199  	"ES",
   200  	"FS",
   201  	"GS",
   202  	"GDTR", // [D_GDTR]
   203  	"IDTR", // [D_IDTR]
   204  	"LDTR", // [D_LDTR]
   205  	"MSW",  // [D_MSW]
   206  	"TASK", // [D_TASK]
   207  	"CR0",  // [D_CR]
   208  	"CR1",
   209  	"CR2",
   210  	"CR3",
   211  	"CR4",
   212  	"CR5",
   213  	"CR6",
   214  	"CR7",
   215  	"CR8",
   216  	"CR9",
   217  	"CR10",
   218  	"CR11",
   219  	"CR12",
   220  	"CR13",
   221  	"CR14",
   222  	"CR15",
   223  	"DR0", // [D_DR]
   224  	"DR1",
   225  	"DR2",
   226  	"DR3",
   227  	"DR4",
   228  	"DR5",
   229  	"DR6",
   230  	"DR7",
   231  	"TR0", // [D_TR]
   232  	"TR1",
   233  	"TR2",
   234  	"TR3",
   235  	"TR4",
   236  	"TR5",
   237  	"TR6",
   238  	"TR7",
   239  	"TLS",    // [D_TLS]
   240  	"MAXREG", // [MAXREG]
   241  }
   242  
   243  func init() {
   244  	obj.RegisterRegister(REG_AL, REG_AL+len(Register), rconv)
   245  	obj.RegisterOpcode(obj.ABaseAMD64, Anames)
   246  	obj.RegisterRegisterList(obj.RegListX86Lo, obj.RegListX86Hi, rlconv)
   247  	obj.RegisterOpSuffix("386", opSuffixString)
   248  	obj.RegisterOpSuffix("amd64", opSuffixString)
   249  }
   250  
   251  func rconv(r int) string {
   252  	if REG_AL <= r && r-REG_AL < len(Register) {
   253  		return Register[r-REG_AL]
   254  	}
   255  	return fmt.Sprintf("Rgok(%d)", r-obj.RBaseAMD64)
   256  }
   257  
   258  func rlconv(bits int64) string {
   259  	reg0, reg1 := decodeRegisterRange(bits)
   260  	return fmt.Sprintf("[%s-%s]", rconv(reg0), rconv(reg1))
   261  }
   262  
   263  func opSuffixString(s uint8) string {
   264  	return "." + opSuffix(s).String()
   265  }