app.codes.nr 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. .QQ
  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. .LP
  21. Flags :
  22. .IP ""
  23. Opcode type, only one of the following may be specified.
  24. .RS
  25. .IP \-
  26. opcode without argument
  27. .IP m
  28. mini
  29. .IP s
  30. shortie
  31. .IP 2
  32. opcode with 2-byte signed argument
  33. .IP 4
  34. opcode with 4-byte signed argument
  35. .IP 8
  36. opcode with 8-byte signed argument
  37. .IP u
  38. opcode with 2-byte unsigned argument
  39. .RE
  40. .IP ""
  41. Secondary (escaped) opcodes.
  42. .RS
  43. .IP e
  44. The opcode thus marked is in the secondary opcode group instead
  45. of the primary
  46. .RE
  47. .IP ""
  48. restrictions on arguments
  49. .RS
  50. .IP N
  51. Negative arguments only
  52. .IP P
  53. Positive and zero arguments only
  54. .RE
  55. .IP ""
  56. mapping of arguments
  57. .RS
  58. .IP w
  59. argument must be divisible by the wordsize and is divided by the
  60. wordsize before use as opcode argument.
  61. .IP o
  62. argument ( possibly after division ) must be >= 1 and is
  63. decremented before use as opcode argument
  64. .RE
  65. .LP
  66. If the opcode type is 2,4 or 8 the resulting argument is used as
  67. opcode argument (least significant byte first).
  68. If the opcode type is mini, the argument is added
  69. to the first opcode \- if in range \- .
  70. If the argument is negative, the absolute value minus one is
  71. used in the algorithm above.
  72. .br
  73. For shorties with positive arguments the first opcode is used
  74. for arguments in the range 0..255, the second for the range
  75. 256..511, etc..
  76. For shorties with negative arguments the first opcode is used
  77. for arguments in the range \-1..\-256, the second for the range
  78. \-257..\-512, etc..
  79. The byte following the opcode contains the least significant
  80. byte of the argument.
  81. First some examples of these specifications.
  82. .IP "aar mwPo 1 34"
  83. .br
  84. Indicates that opcode 34 is used as a mini for Positive
  85. instruction arguments only.
  86. The w and o indicate division and decrementing of the
  87. instruction argument.
  88. Because the resulting argument must be zero ( only opcode 34 may be used),
  89. this mini can only be used for instruction argument 2.
  90. Conclusion: opcode 34 is for "AAR 2".
  91. .IP "adp sP 1 41"
  92. .br
  93. Opcode 41 is used as shortie for ADP with arguments in the range
  94. 0..255.
  95. .IP "bra sN 2 60"
  96. .br
  97. Opcode 60 is used as shortie for BRA with arguments \-1..\-256,
  98. 61 is used for arguments \-257..\-512.
  99. .IP "zer e\- 145"
  100. .br
  101. Escaped opcode 145 is used for ZER.
  102. .LP
  103. The interpreter opcode table:
  104. .DS
  105. .so itables
  106. .DE
  107. .PP
  108. The table above results in the following dispatch tables.
  109. Dispatch tables are used by interpreters to jump to the
  110. routines implementing the EM instructions, indexed by the next opcode.
  111. Each line of the dispatch tables gives the routine names
  112. of eight consecutive opcodes, preceded by the first opcode number
  113. on that line.
  114. Routine names consist of an EM mnemonic followed by a suffix.
  115. The suffices show the encoding used for each opcode.
  116. .LP
  117. The following suffices exist:
  118. .TS
  119. tab(:);
  120. l l.
  121. .z:no arguments
  122. .l:16-bit argument
  123. .L:32-bit argument
  124. .u:16-bit unsigned argument
  125. .lw:16-bit argument divided by the wordsize
  126. .Lw:32-bit argument divided by the wordsize
  127. .p:positive 16-bit argument
  128. .P:positive 32-bit argument
  129. .pw:positive 16-bit argument divided by the wordsize
  130. .Pw:positive 32-bit argument divided by the wordsize
  131. .n:negative 16-bit argument
  132. .N:negative 32-bit argument
  133. .nw:negative 16-bit argument divided by the wordsize
  134. .Nw:negative 32-bit argument divided by the wordsize
  135. .s<num>:shortie with <num> as high order argument byte
  136. .w<num>:shortie with argument divided by the wordsize
  137. .<num>:mini with <num> as argument
  138. .<num>W:mini with <num>*wordsize as argument
  139. .TE
  140. .LP
  141. <num> is a possibly negative integer.
  142. .LP
  143. The dispatch table for the 256 primary opcodes:
  144. .sp 1
  145. .so dispat1
  146. .sp 2
  147. The list of secondary opcodes (escape1):
  148. .sp 1
  149. .so dispat2
  150. .sp 2
  151. Finally, the list of opcodes with four byte arguments (escape2).
  152. .sp 1
  153. .so dispat3