bird-vm/design.md

1.3 KiB

Op Layout

The first three bits are the category, the next four are the op, the last one is whether or not the op should operate on two bytes (1 for 2byte/16bit, 0 for 1byte/8bit)

[ 000  0000  0 ]
   |    \/   |
  Cat   Op 2byte
  1. memory - 000
  2. set - 000
  3. get - 001
  4. sei - 010 - set indirect (use a pointer stores elswhere)
  5. gei - 011
  6. .
  7. .
  8. .
  9. stack - 001
  10. psh - 000
  11. pop - 001
  12. ovr - 010
  13. swp - 011
  14. rot - 100
  15. dup - 101
  16. .
  17. math - 010
  18. add - 000
  19. sub - 001
  20. mul - 010
  21. div - 011
  22. inc - 100
  23. dec - 101
  24. .
  25. bits - 011
  26. and - 000
  27. bor - 001 (bitwise or)
  28. xor - 010
  29. not - 011
  30. shr - 100
  31. shl - 101
  32. eql - 111
  33. jump - 100
  34. jmp - 000
  35. sub - 001
  36. jcd - 010
  37. ret - 011
  38. .
  39. .
  40. .
  41. sys - 101
  42. gch - 000
  43. gst - 001
  44. pch - 010
  45. pst - 011
  46. hlt - 100
  47. .
  48. .
  49. .
  50. .
  51. .
  52. .
  53. .
  54. .
  55. .
  56. .
  57. .
  58. .
  59. .
  60. .
  61. .
  62. .
  63. .
  64. .
  65. .
  66. .
  67. .
  68. .
  69. .
  70. dev - 111
  71. .
  72. .
  73. .
  74. .
  75. .
  76. .
  77. .
  78. .
  79. .
  80. .
  81. .
  82. .
  83. .
  84. .
  85. .
  86. .
  87. .
  88. .
  89. .
  90. .
  91. .
  92. .
  93. .
  94. .
  95. .
  96. .
  97. .
  98. .

Memory Layout

var memory = [MAX_uint16]byte{}

Stack