list6.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. package x86
  31. import (
  32. "github.com/twitchyliquid64/golang-asm/obj"
  33. "fmt"
  34. )
  35. var Register = []string{
  36. "AL", // [D_AL]
  37. "CL",
  38. "DL",
  39. "BL",
  40. "SPB",
  41. "BPB",
  42. "SIB",
  43. "DIB",
  44. "R8B",
  45. "R9B",
  46. "R10B",
  47. "R11B",
  48. "R12B",
  49. "R13B",
  50. "R14B",
  51. "R15B",
  52. "AX", // [D_AX]
  53. "CX",
  54. "DX",
  55. "BX",
  56. "SP",
  57. "BP",
  58. "SI",
  59. "DI",
  60. "R8",
  61. "R9",
  62. "R10",
  63. "R11",
  64. "R12",
  65. "R13",
  66. "R14",
  67. "R15",
  68. "AH",
  69. "CH",
  70. "DH",
  71. "BH",
  72. "F0", // [D_F0]
  73. "F1",
  74. "F2",
  75. "F3",
  76. "F4",
  77. "F5",
  78. "F6",
  79. "F7",
  80. "M0",
  81. "M1",
  82. "M2",
  83. "M3",
  84. "M4",
  85. "M5",
  86. "M6",
  87. "M7",
  88. "K0",
  89. "K1",
  90. "K2",
  91. "K3",
  92. "K4",
  93. "K5",
  94. "K6",
  95. "K7",
  96. "X0",
  97. "X1",
  98. "X2",
  99. "X3",
  100. "X4",
  101. "X5",
  102. "X6",
  103. "X7",
  104. "X8",
  105. "X9",
  106. "X10",
  107. "X11",
  108. "X12",
  109. "X13",
  110. "X14",
  111. "X15",
  112. "X16",
  113. "X17",
  114. "X18",
  115. "X19",
  116. "X20",
  117. "X21",
  118. "X22",
  119. "X23",
  120. "X24",
  121. "X25",
  122. "X26",
  123. "X27",
  124. "X28",
  125. "X29",
  126. "X30",
  127. "X31",
  128. "Y0",
  129. "Y1",
  130. "Y2",
  131. "Y3",
  132. "Y4",
  133. "Y5",
  134. "Y6",
  135. "Y7",
  136. "Y8",
  137. "Y9",
  138. "Y10",
  139. "Y11",
  140. "Y12",
  141. "Y13",
  142. "Y14",
  143. "Y15",
  144. "Y16",
  145. "Y17",
  146. "Y18",
  147. "Y19",
  148. "Y20",
  149. "Y21",
  150. "Y22",
  151. "Y23",
  152. "Y24",
  153. "Y25",
  154. "Y26",
  155. "Y27",
  156. "Y28",
  157. "Y29",
  158. "Y30",
  159. "Y31",
  160. "Z0",
  161. "Z1",
  162. "Z2",
  163. "Z3",
  164. "Z4",
  165. "Z5",
  166. "Z6",
  167. "Z7",
  168. "Z8",
  169. "Z9",
  170. "Z10",
  171. "Z11",
  172. "Z12",
  173. "Z13",
  174. "Z14",
  175. "Z15",
  176. "Z16",
  177. "Z17",
  178. "Z18",
  179. "Z19",
  180. "Z20",
  181. "Z21",
  182. "Z22",
  183. "Z23",
  184. "Z24",
  185. "Z25",
  186. "Z26",
  187. "Z27",
  188. "Z28",
  189. "Z29",
  190. "Z30",
  191. "Z31",
  192. "CS", // [D_CS]
  193. "SS",
  194. "DS",
  195. "ES",
  196. "FS",
  197. "GS",
  198. "GDTR", // [D_GDTR]
  199. "IDTR", // [D_IDTR]
  200. "LDTR", // [D_LDTR]
  201. "MSW", // [D_MSW]
  202. "TASK", // [D_TASK]
  203. "CR0", // [D_CR]
  204. "CR1",
  205. "CR2",
  206. "CR3",
  207. "CR4",
  208. "CR5",
  209. "CR6",
  210. "CR7",
  211. "CR8",
  212. "CR9",
  213. "CR10",
  214. "CR11",
  215. "CR12",
  216. "CR13",
  217. "CR14",
  218. "CR15",
  219. "DR0", // [D_DR]
  220. "DR1",
  221. "DR2",
  222. "DR3",
  223. "DR4",
  224. "DR5",
  225. "DR6",
  226. "DR7",
  227. "TR0", // [D_TR]
  228. "TR1",
  229. "TR2",
  230. "TR3",
  231. "TR4",
  232. "TR5",
  233. "TR6",
  234. "TR7",
  235. "TLS", // [D_TLS]
  236. "MAXREG", // [MAXREG]
  237. }
  238. func init() {
  239. obj.RegisterRegister(REG_AL, REG_AL+len(Register), rconv)
  240. obj.RegisterOpcode(obj.ABaseAMD64, Anames)
  241. obj.RegisterRegisterList(obj.RegListX86Lo, obj.RegListX86Hi, rlconv)
  242. obj.RegisterOpSuffix("386", opSuffixString)
  243. obj.RegisterOpSuffix("amd64", opSuffixString)
  244. }
  245. func rconv(r int) string {
  246. if REG_AL <= r && r-REG_AL < len(Register) {
  247. return Register[r-REG_AL]
  248. }
  249. return fmt.Sprintf("Rgok(%d)", r-obj.RBaseAMD64)
  250. }
  251. func rlconv(bits int64) string {
  252. reg0, reg1 := decodeRegisterRange(bits)
  253. return fmt.Sprintf("[%s-%s]", rconv(reg0), rconv(reg1))
  254. }
  255. func opSuffixString(s uint8) string {
  256. return "." + opSuffix(s).String()
  257. }