list9.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. package ppc64
  30. import (
  31. "github.com/twitchyliquid64/golang-asm/obj"
  32. "fmt"
  33. )
  34. func init() {
  35. obj.RegisterRegister(obj.RBasePPC64, REG_DCR0+1024, rconv)
  36. obj.RegisterOpcode(obj.ABasePPC64, Anames)
  37. }
  38. func rconv(r int) string {
  39. if r == 0 {
  40. return "NONE"
  41. }
  42. if r == REGG {
  43. // Special case.
  44. return "g"
  45. }
  46. if REG_R0 <= r && r <= REG_R31 {
  47. return fmt.Sprintf("R%d", r-REG_R0)
  48. }
  49. if REG_F0 <= r && r <= REG_F31 {
  50. return fmt.Sprintf("F%d", r-REG_F0)
  51. }
  52. if REG_V0 <= r && r <= REG_V31 {
  53. return fmt.Sprintf("V%d", r-REG_V0)
  54. }
  55. if REG_VS0 <= r && r <= REG_VS63 {
  56. return fmt.Sprintf("VS%d", r-REG_VS0)
  57. }
  58. if REG_CR0 <= r && r <= REG_CR7 {
  59. return fmt.Sprintf("CR%d", r-REG_CR0)
  60. }
  61. if r == REG_CR {
  62. return "CR"
  63. }
  64. if REG_SPR0 <= r && r <= REG_SPR0+1023 {
  65. switch r {
  66. case REG_XER:
  67. return "XER"
  68. case REG_LR:
  69. return "LR"
  70. case REG_CTR:
  71. return "CTR"
  72. }
  73. return fmt.Sprintf("SPR(%d)", r-REG_SPR0)
  74. }
  75. if REG_DCR0 <= r && r <= REG_DCR0+1023 {
  76. return fmt.Sprintf("DCR(%d)", r-REG_DCR0)
  77. }
  78. if r == REG_FPSCR {
  79. return "FPSCR"
  80. }
  81. if r == REG_MSR {
  82. return "MSR"
  83. }
  84. return fmt.Sprintf("Rgok(%d)", r-obj.RBasePPC64)
  85. }
  86. func DRconv(a int) string {
  87. s := "C_??"
  88. if a >= C_NONE && a <= C_NCLASS {
  89. s = cnames9[a]
  90. }
  91. var fp string
  92. fp += s
  93. return fp
  94. }