app.codes.nr 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. .BP
  2. .AP "EM CODE TABLES"
  3. The following table is used by the assembler for EM machine
  4. language.
  5. It specifies the opcodes used for each instruction and
  6. how arguments are mapped to machine language arguments.
  7. The table is presented in three columns,
  8. each line in each column contains three or four fields.
  9. Each line describes a range of interpreter opcodes by
  10. specifying for which instruction the range is used, the type of the
  11. opcodes (mini, shortie, etc..) and range for the instruction
  12. argument.
  13. .A
  14. The first field on each line gives the EM instruction mnemonic,
  15. the second field gives some flags.
  16. If the opcodes are minis or shorties the third field specifies
  17. how many minis/shorties are used.
  18. The last field gives the number of the (first) interpreter
  19. opcode.
  20. .N 1
  21. Flags :
  22. .IS 3
  23. .N 1
  24. Opcode type, only one of the following may be specified.
  25. .PS - 5 " "
  26. .PT \-
  27. opcode without argument
  28. .PT m
  29. mini
  30. .PT s
  31. shortie
  32. .PT 2
  33. opcode with 2-byte signed argument
  34. .PT 4
  35. opcode with 4-byte signed argument
  36. .PT 8
  37. opcode with 8-byte signed argument
  38. .PT u
  39. opcode with 2-byte unsigned argument
  40. .PE
  41. Secondary (escaped) opcodes.
  42. .PS - 5 " "
  43. .PT e
  44. The opcode thus marked is in the secondary opcode group instead
  45. of the primary
  46. .PE
  47. restrictions on arguments
  48. .PS - 5 " "
  49. .PT N
  50. Negative arguments only
  51. .PT P
  52. Positive and zero arguments only
  53. .PE
  54. mapping of arguments
  55. .PS - 5 " "
  56. .PT w
  57. argument must be divisible by the wordsize and is divided by the
  58. wordsize before use as opcode argument.
  59. .PT o
  60. argument ( possibly after division ) must be >= 1 and is
  61. decremented before use as opcode argument
  62. .PE
  63. .IE
  64. If the opcode type is 2,4 or 8 the resulting argument is used as
  65. opcode argument (least significant byte first).
  66. .N
  67. If the opcode type is mini, the argument is added
  68. to the first opcode \- if in range \- .
  69. If the argument is negative, the absolute value minus one is
  70. used in the algorithm above.
  71. .N
  72. For shorties with positive arguments the first opcode is used
  73. for arguments in the range 0..255, the second for the range
  74. 256..511, etc..
  75. For shorties with negative arguments the first opcode is used
  76. for arguments in the range \-1..\-256, the second for the range
  77. \-257..\-512, etc..
  78. The byte following the opcode contains the least significant
  79. byte of the argument.
  80. First some examples of these specifications.
  81. .PS - 5
  82. .PT "aar mwPo 1 34"
  83. Indicates that opcode 34 is used as a mini for Positive
  84. instruction arguments only.
  85. The w and o indicate division and decrementing of the
  86. instruction argument.
  87. Because the resulting argument must be zero ( only opcode 34 may be used
  88. ), this mini can only be used for instruction argument 2.
  89. Conclusion: opcode 34 is for "AAR 2".
  90. .PT "adp sP 1 41"
  91. Opcode 41 is used as shortie for ADP with arguments in the range
  92. 0..255.
  93. .PT "bra sN 2 60"
  94. Opcode 60 is used as shortie for BRA with arguments \-1..\-256,
  95. 61 is used for arguments \-257..\-512.
  96. .PT "zer e\- 145"
  97. Escaped opcode 145 is used for ZER.
  98. .PE
  99. The interpreter opcode table:
  100. .N 1
  101. .IS 3
  102. .so itables
  103. .IE
  104. .P
  105. The table above results in the following dispatch tables.
  106. Dispatch tables are used by interpreters to jump to the
  107. routines implementing the EM instructions, indexed by the next opcode.
  108. Each line of the dispatch tables gives the routine names
  109. of eight consecutive opcodes, preceded by the first opcode number
  110. on that line.
  111. Routine names consist of an EM mnemonic followed by a suffix.
  112. The suffices show the encoding used for each opcode.
  113. .N
  114. The following suffices exist:
  115. .N 1
  116. .VS 1 0
  117. .IS 4
  118. .PS - 11
  119. .PT .z
  120. no arguments
  121. .PT .l
  122. 16-bit argument
  123. .PT .L
  124. 32-bit argument
  125. .PT .u
  126. 16-bit unsigned argument
  127. .PT .lw
  128. 16-bit argument divided by the wordsize
  129. .PT .Lw
  130. 32-bit argument divided by the wordsize
  131. .PT .p
  132. positive 16-bit argument
  133. .PT .P
  134. positive 32-bit argument
  135. .PT .pw
  136. positive 16-bit argument divided by the wordsize
  137. .PT .Pw
  138. positive 32-bit argument divided by the wordsize
  139. .PT .n
  140. negative 16-bit argument
  141. .PT .N
  142. negative 32-bit argument
  143. .PT .nw
  144. negative 16-bit argument divided by the wordsize
  145. .PT .Nw
  146. negative 32-bit argument divided by the wordsize
  147. .PT .s<num>
  148. shortie with <num> as high order argument byte
  149. .PT .w<num>
  150. shortie with argument divided by the wordsize
  151. .PT .<num>
  152. mini with <num> as argument
  153. .PT .<num>W
  154. mini with <num>*wordsize as argument
  155. .PE 1
  156. <num> is a possibly negative integer.
  157. .VS
  158. .IE
  159. The dispatch table for the 256 primary opcodes:
  160. .N 1
  161. .so dispat1
  162. .N 2
  163. The list of secondary opcodes (escape1):
  164. .N 1
  165. .so dispat2
  166. .N 2
  167. Finally, the list of opcodes with four byte arguments (escape2).
  168. .N 1
  169. .so dispat3