bdoor_386.s 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #include "textflag.h"
  2. // Doc of the golang plan9 assembler
  3. // http://p9.nyx.link/labs/sys/doc/asm.html
  4. //
  5. // A good primer of how to write golang with some plan9 flavored assembly
  6. // http://www.doxsey.net/blog/go-and-assembly
  7. //
  8. // Some x86 references
  9. // http://www.eecg.toronto.edu/~amza/www.mindsec.com/files/x86regs.html
  10. // https://cseweb.ucsd.edu/classes/sp10/cse141/pdf/02/S01_x86_64.key.pdf
  11. // https://en.wikibooks.org/wiki/X86_Assembly/Other_Instructions
  12. //
  13. // (This one is invaluable. Has a working example of how a standard function
  14. // call looks on the stack with the associated assembly.)
  15. // https://www.recurse.com/blog/7-understanding-c-by-learning-assembly
  16. //
  17. // Reference with raw form of the Opcode
  18. // http://x86.renejeschke.de/html/file_module_x86_id_139.html
  19. //
  20. // Massive x86_64 reference
  21. // http://ref.x86asm.net/coder64.html#xED
  22. //
  23. // Adding instructions to the go assembler
  24. // https://blog.klauspost.com/adding-unsupported-instructions-in-golang-assembler/
  25. //
  26. // Backdoor commands
  27. // https://sites.google.com/site/chitchatvmback/backdoor
  28. // func bdoor_inout(ax, bx, cx, dx, si, di, bp uint32) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint32)
  29. TEXT ·bdoor_inout(SB), NOSPLIT|WRAPPER, $0
  30. MOVL ax+0(FP), AX
  31. MOVL bx+4(FP), BX
  32. MOVL cx+8(FP), CX
  33. MOVL dx+12(FP), DX
  34. MOVL si+16(FP), SI
  35. MOVL di+20(FP), DI
  36. MOVL bp+24(FP), BP
  37. // IN to DX from EAX
  38. INL
  39. MOVL AX, retax+28(FP)
  40. MOVL BX, retbx+32(FP)
  41. MOVL CX, retcx+36(FP)
  42. MOVL DX, retdx+40(FP)
  43. MOVL SI, retsi+44(FP)
  44. MOVL DI, retdi+48(FP)
  45. MOVL BP, retbp+52(FP)
  46. RET
  47. // func bdoor_hbout(ax, bx, cx, dx, si, di, bp uint32) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint32)
  48. TEXT ·bdoor_hbout(SB), NOSPLIT|WRAPPER, $0
  49. MOVL ax+0(FP), AX
  50. MOVL bx+4(FP), BX
  51. MOVL cx+8(FP), CX
  52. MOVL dx+12(FP), DX
  53. MOVL si+16(FP), SI
  54. MOVL di+20(FP), DI
  55. MOVL bp+24(FP), BP
  56. CLD; REP; OUTSB
  57. MOVL AX, retax+28(FP)
  58. MOVL BX, retbx+32(FP)
  59. MOVL CX, retcx+36(FP)
  60. MOVL DX, retdx+40(FP)
  61. MOVL SI, retsi+44(FP)
  62. MOVL DI, retdi+48(FP)
  63. MOVL BP, retbp+52(FP)
  64. RET
  65. // func bdoor_hbin(ax, bx, cx, dx, si, di, bp uint32) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint32)
  66. TEXT ·bdoor_hbin(SB), NOSPLIT|WRAPPER, $0
  67. MOVL ax+0(FP), AX
  68. MOVL bx+4(FP), BX
  69. MOVL cx+8(FP), CX
  70. MOVL dx+12(FP), DX
  71. MOVL si+16(FP), SI
  72. MOVL di+20(FP), DI
  73. MOVL bp+24(FP), BP
  74. CLD; REP; INSB
  75. MOVL AX, retax+28(FP)
  76. MOVL BX, retbx+32(FP)
  77. MOVL CX, retcx+40(FP)
  78. MOVL DX, retdx+44(FP)
  79. MOVL SI, retsi+48(FP)
  80. MOVL DI, retdi+52(FP)
  81. MOVL BP, retbp+56(FP)
  82. RET
  83. // func bdoor_inout_test(ax, bx, cx, dx, si, di, bp uint32) (retax, retbx, retcx, retdx, retsi, retdi, retbp uint32)
  84. TEXT ·bdoor_inout_test(SB), NOSPLIT|WRAPPER, $0
  85. MOVL ax+0(FP), AX
  86. MOVL bx+4(FP), BX
  87. MOVL cx+8(FP), CX
  88. MOVL dx+12(FP), DX
  89. MOVL si+16(FP), SI
  90. MOVL di+20(FP), DI
  91. MOVL bp+24(FP), BP
  92. MOVL AX, retax+28(FP)
  93. MOVL BX, retbx+32(FP)
  94. MOVL CX, retcx+36(FP)
  95. MOVL DX, retdx+40(FP)
  96. MOVL SI, retsi+44(FP)
  97. MOVL DI, retdi+48(FP)
  98. MOVL BP, retbp+52(FP)
  99. RET