home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / alt / sources / 2866 < prev    next >
Encoding:
Internet Message Format  |  1992-12-23  |  111.2 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!rutgers!rochester!rit!moscom!pap
  2. From: pap@moscom.com (Patrick Palmer)
  3. Newsgroups: alt.sources
  4. Subject: YAMPC (part 1/2)
  5. Message-ID: <4808@moscom.com>
  6. Date: 23 Dec 92 17:26:55 GMT
  7. Organization: Moscom Corp., E. Rochester, NY
  8. Lines: 3148
  9. X-Newsreader: TIN [version 1.3 beta PL7]
  10.  
  11. Yet Another Microcode Program Compiler.  This is useful for learning
  12. microcode programming. 
  13.  
  14. Patrick
  15. ----
  16. Patrick Palmer                                       Multimedia is the answer. 
  17. Slo-mo Mail: PO Box 23322, Rochester, NY 14692       What's the question?
  18.  
  19. --------CUT HERE---------
  20. # This is a shell archive.  cd to an empty directory and feed to sh.
  21. cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > cmemory
  22. XX
  23. X; YAMPC Microcode Development KitX
  24. X; Patrick PalmerX
  25. XX
  26. X.decimalX
  27. XX
  28. X;X
  29. X;WRITE -  Write MAR into memoryX
  30. X;|  READ - Read MAR address into MBRX
  31. X;|  |  ASOURCE - Source for ABUSX
  32. X;|  |  |  CCCNTRL - CC controlX
  33. X;|  |  |  |  SHFTCTRL - shift controlX
  34. X;|  |  |  |  |   ALUCTRL - Function from ALUX
  35. X;|  |  |  |  |   |  ZDEST - Destination on ZBUSX
  36. X;|  |  |  |  |   |  |  LOADFLAGS - Load FLAGS from ALUX
  37. X;|  |  |  |  |   |  |  |  LOADHOLD - Load HOLD from ABUSX
  38. X;|  |  |  |  |   |  |  |  |  TEST - Select bit from ALU status bitsX
  39. X;|  |  |  |  |   |  |  |  |  |  COND - Type of next addressX
  40. X;|  |  |  |  |   |  |  |  |  |  |    ADDRF - Address for micro jumpX
  41. X;|  |  |  |  |   |  |  |  |  |  |    |    Decimal AddressX
  42. X;|  |  |  |  |   |  |  |  |  |  |    |    |   Hex AddressX
  43. X;|  |  |  |  |   |  |  |  |  |  |    |    |   |    CommentX
  44. X;|  |  |  |  |   |  |  |  |  |  |    |    |   |    | X
  45. X;|  |  |  |  |   |  |  |  |  |  |    |    |   |    |X
  46. X;|  |  |  |  |   |  |  |  |  |  |    |    |   |    |X
  47. X;|  |  |  |  |   |  |  |  |  |  |    |    |   |    |X
  48. X;|  |  |  |  |   |  |  |  |  |  |    |    |   |    |X
  49. X;|  |  |  |  |   |  |  |  |  |  |    |    |   |    |X
  50. X;|  |  |  |  |   |  |  |  |  |  |    |    |   |    |X
  51. X;A  B  C  D  E   F  G  H  I  J  K    L    Dec Hex  RemX
  52. X;******** Initialize PC to 0 ****************************************X
  53. X 0  0  0  0  0  15  2  0  0  0  0    0  ; 0   00 ; PC    <- 0X
  54. X 0  0  0  0  0  15  5  0  0  0  0    0  ; 1   01 ; FLAGS <- 0X
  55. X 0  0  0  0  0  15  1  0  0  0  0    0  ; 2   02 ; AC    <- 0X
  56. X 0  0  0  0  0  14  3  0  0  0  0    0  ; 3   03 ; SP    <- 0xFFX
  57. X 0  0  0  0  0  15  6  0  0  0  0    0  ; 4   04 ; X     <- 0X
  58. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 5   05 ; goto fetchX
  59. XX
  60. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 6   06 ; nopX
  61. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 7   07 ; nopX
  62. XX
  63. X;******** Fetch Next Instruction ***********************************X
  64. X 0  1  2  0  0   1 10  0  0  0  0    0  ; 8   08 ; MAR <- PC; READX
  65. X 0  1  2  0  0   9  2  0  0  0  0    0  ; 9   09 ; PC <- PC + 1; READX
  66. X 0  0  9  0  0   1  4  0  0  0  6   12  ; 10  0a ; IR <- MBR;X
  67. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 11  0b ; nopX
  68. X;                                                ; start instruction decodeX
  69. X;                                                ; goto 12 + IR7 * 2 + IR6X
  70. X 0  0  0  0  0   0  0  0  0  0  1  115  ; 12  0c ; IR76 00; goto 115X
  71. X 0  0  0  0  0   0  0  0  0  0  1  115  ; 13  0d ; IR76 01; goto 115X
  72. X 0  0  0  0  0   0  0  0  0  0  1   50  ; 14  0e ; IR76 10; goto 50X
  73. X;X
  74. X; OpCodes that have IR7=1 and IR6=1X
  75. X 0  0  0  0  0   0  0  0  0  0  5   16  ; 15  0f ; test IR5, IR4X
  76. X 0  0  0  0  0   0  0  0  0  0  1   20  ; 16  10 ; IR54 00; goto 20 X
  77. X 0  0  0  0  0   0  0  0  0  0  1   32  ; 17  11 ; IR54 01; goto 32X
  78. X 0  0  0  0  0   0  0  0  0  0  1   46  ; 18  12 ; IR54 10; goto 46X
  79. X;X
  80. X; HALT (1111 0000) - halt executionX
  81. X 999 999 999 999 999 999 999 999 999 999 999 999 ; 19  13 ; DIE!!X
  82. X;X
  83. X; pop instructions  X
  84. X 0  1  3  0  0   1 10  0  0  0  0    0  ; 20  14 ; MAR <- SP; READX
  85. X 0  1  3  0  0   9  3  0  0  0  0    0  ; 21  15 ; SP <- SP + 1; READX
  86. X 0  0  0  0  0   0  0  0  0  0  3   24  ; 22  16 ; test IR1, IR0X
  87. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 23  17 ; nopX
  88. X 0  0  0  0  0   0  0  0  0  0  1   28  ; 24  18 ; IR10 00; goto 28 X
  89. X 0  0  0  0  0   0  0  0  0  0  1   29  ; 25  19 ; IR10 01; goto 29 X
  90. X 0  0  0  0  0   0  0  0  0  0  1   30  ; 26  1a ; IR10 10; goto 30 X
  91. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 27  1b ; IR10 11; goto 8; neverX
  92. X;X
  93. X; POP ACC (1100 0000) - pop accumulator off top of stackX
  94. X 0  0  9  0  0   1  1  1  0  0  1  211  ; 28  1c ; ACC <- MBR; goto 211 X
  95. X;X
  96. X; POP X (1100 0001) - pop index register off top of stackX
  97. X 0  0  9  0  0   1  6  0  0  0  1    8  ; 29  1d ; X <- MBR; goto 8 X
  98. X;X
  99. X; POP FLAGS (1100 0010) - pop flags off top of stackX
  100. X 0  0  9  0  0   1  5  0  0  0  1    8  ; 30  1e ; FLAGS <- MBR; goto 8 X
  101. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 31  1f ; nopX
  102. X;X
  103. X; push instructionsX
  104. X 0  0  3  0  0   2  3  0  0  0  0    0  ; 32  20 ; not SP X
  105. X 0  0  3  0  0   9  3  0  0  0  0    0  ; 33  21 ; SP <- SP + 1 X
  106. X 0  0  3  0  0   2  3  0  0  0  0    0  ; 34  22 ; not SP X
  107. X 0  0  3  0  0   1 10  0  0  0  3   36  ; 35  23 ; MAR <- SP; test IR0,IR1 X
  108. X 0  0  0  0  0   0  0  0  0  0  1   40  ; 36  24 ; IR10 00; goto 40 X
  109. X 0  0  0  0  0   0  0  0  0  0  1   42  ; 37  25 ; IR10 01; goto 42 X
  110. X 0  0  0  0  0   0  0  0  0  0  1   44  ; 38  26 ; IR10 10; goto 44 X
  111. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 39  27 ; IR10 11; goto 8; neverX
  112. X;X
  113. X; PUSH ACC (1101 0000) - push accumulator on stackX
  114. X 1  0  1  0  0   1  9  0  0  0  0    0  ; 40  28 ; MBR <- ACC; WRITEX
  115. X 1  0  0  0  0   0  0  0  0  0  1    8  ; 41  29 ; WRITE; goto 8X
  116. X;X
  117. X; PUSH X (1101 0001) - push index register on stackX
  118. X 1  0  6  0  0   1  9  0  0  0  0    0  ; 42  2a ; MBR <- X; WRITEX
  119. X 1  0  0  0  0   0  0  0  0  0  1    8  ; 43  2b ; WRITE; goto 8X
  120. X;X
  121. X; PUSH FLAGS (1101 0010) - push flags on stackX
  122. X 1  0  5  0  0   1  9  0  0  0  0    0  ; 44  2c ; MBR <- FLAGS; WRITEX
  123. X 1  0  0  0  0   0  0  0  0  0  1    8  ; 45  2d ; WRITE; goto 8X
  124. X;X
  125. X; RETN (1110 0000) - return from subroutineX
  126. X 0  1  3  0  0   1 10  0  0  0  0    0  ; 46  2e ; MAR <- SP; READX
  127. X 0  1  3  0  0   9  3  0  0  0  0    0  ; 47  2f ; SP <- SP + 1; READX
  128. X 0  0  9  0  0   1  2  0  0  0  1    8  ; 48  30 ; PC <- MBR; goto 8 X
  129. XX
  130. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 49  31 ; nopX
  131. X;X
  132. X; OpCodes that have IR7=1 and IR6=0X
  133. X 0  0  0  0  0   0  0  0  0  0  5   52  ; 50  32 ; test IR5, IR4X
  134. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 51  33 ; nopX
  135. X 0  0  0  0  0   0  0  0  0  0  1   59  ; 52  34 ; IR54 00; goto 59 X
  136. X 0  0  0  0  0   0  0  0  0  0  1   71  ; 53  35 ; IR54 01; goto 71X
  137. X 0  0  0  0  0   0  0  0  0  0  1   79  ; 54  36 ; IR54 10; goto 79X
  138. X 0  0  0  0  0   0  0  0  0  0  1   87  ; 55  37 ; IR54 11; goto 87X
  139. XX
  140. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 56  38 ; nopX
  141. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 57  39 ; nopX
  142. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 58  3a ; nopX
  143. X;X
  144. X; increment/decrement registersX
  145. X 0  0  0  0  0   0  0  0  0  0  3   60  ; 59  3b ; test IR0,IR1 X
  146. X 0  0  0  0  0   0  0  0  0  0  1   70  ; 60  3c ; IR10 00; goto 70 X
  147. X 0  0  0  0  0   0  0  0  0  0  1   69  ; 61  3d ; IR10 01; goto 69 X
  148. X 0  0  0  0  0   0  0  0  0  0  1   66  ; 62  3e ; IR10 10; goto 66 X
  149. X;X
  150. X; DECX (1000 0011) - decrement index registerX
  151. X 0  0  6  0  0   2  6  0  0  0  0    0  ; 63  3f ; not X X
  152. X 0  0  6  0  0   9  6  0  0  0  0    0  ; 64  40 ; X <- X + 1X
  153. X 0  0  6  0  0   2  6  0  0  0  1    8  ; 65  41 ; not X ; goto 8X
  154. X;X
  155. X; DECA (1000 0010) - decrement accumulatorX
  156. X 0  0  1  0  0   2  1  0  0  0  0    0  ; 66  42 ; not ACC X
  157. X 0  0  1  0  0   9  1  0  0  0  0    0  ; 67  43 ; ACC <- ACC + 1 X
  158. X 0  0  1  0  0   2  1  1  0  0  1    8  ; 68  44 ; not ACC; goto 8X
  159. X;X
  160. X; INCX (1000 0001) - increment index registerX
  161. X 0  0  6  0  0   9  6  0  0  0  1    8  ; 69  45 ; X <- X + 1; goto 8X
  162. X;X
  163. X; INCA (1000 0000) - increment accumulatorX
  164. X 0  0  1  0  0   9  1  1  0  0  1    8  ; 70  46 ; ACC <- ACC + 1; goto 8X
  165. X;X
  166. X; clearing registersX
  167. X 0  0  0  0  0   0  0  0  0  0  3   72  ; 71  47 ; test IR0,IR1 X
  168. X 0  0  0  0  0   0  0  0  0  0  1   76  ; 72  48 ; IR10 00; goto 76X
  169. X 0  0  0  0  0   0  0  0  0  0  1   78  ; 73  49 ; IR10 01; goto 78X
  170. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 74  4a ; IR10 10; goto 8; never X
  171. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 75  4b ; IR10 11; goto 8; never X
  172. X;X
  173. X; CLRA (1001 0000) - clear accumulatorX
  174. X 0  0 10  0  0   1  5  0  0  0  0    4  ; 76  4c ; FLAGS <- 00000100X
  175. X 0  0  1  0  0  15  1  0  0  0  1    8  ; 77  4d ; ACC <- 0; goto 8X
  176. X;X
  177. X; CLRX (1001 0000) - clear index registerX
  178. X 0  0  6  0  0  15  6  0  0  0  1    8  ; 78  4e ; X <- 0; goto 8X
  179. X;X
  180. X; ones/twos complementX
  181. X 0  0  0  0  0   0  0  0  0  0  3   80  ; 79  4f ; test IR0,IR1 X
  182. X 0  0  0  0  0   0  0  0  0  0  1   84  ; 80  50 ; IR10 00; goto 84X
  183. X 0  0  0  0  0   0  0  0  0  0  1   85  ; 81  51 ; IR10 01; goto 85X
  184. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 82  52 ; IR10 10; goto 8; never X
  185. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 83  53 ; IR10 11; goto 8; never X
  186. X;X
  187. X; NOT (1010 0000) - bitwise complement of accumulatorX
  188. X 0  0  1  0  0   2  1  1  0  0  1  211  ; 84  54 ; not ACC; goto 211X
  189. X;X
  190. X; NEG (1010 0001) - 2's complement negation of the accumulatorX
  191. X 0  0  1  0  0   2  1  0  0  0  0    0  ; 85  55 ; not ACCX
  192. X 0  0  1  0  0   9  1  1  0  0  1  218  ; 86  56 ; ACC <- ACC + 1; goto 218X
  193. X;X
  194. X; shiftingX
  195. X 0  0  0  0  0   0  0  0  0  0  4   88  ; 87  57 ; test IR3,IR2 X
  196. X 0  0  0  0  0   0  0  0  0  0  1   95  ; 88  58 ; IR32 00; goto 95X
  197. X 0  0  0  0  0   0  0  0  0  0  1  104  ; 89  59 ; IR32 01; goto 104X
  198. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 90  5a ; IR32 10; goto 8; never X
  199. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 91  5b ; IR32 11; goto 8; never X
  200. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 92  5c ; nopX
  201. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 93  5d ; nopX
  202. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 94  5e ; nopX
  203. X 0  0  0  0  0   0  0  0  0  0  3   96  ; 95  5f ; test IR0,IR1 X
  204. X 0  0  0  0  0   0  0  0  0  0  1  100  ; 96  60 ; IR10 00; goto 100X
  205. X 0  0  0  0  0   0  0  0  0  0  1  108  ; 97  61 ; IR10 01; goto 108X
  206. X 0  0  0  0  0   0  0  0  0  0  1  102  ; 98  62 ; IR10 10; goto 102 X
  207. X 0  0  0  0  0   0  0  0  0  0  1  111  ; 99  63 ; IR10 11; goto 111 X
  208. X;X
  209. X; SLL (1011 0000) - shift logical leftX
  210. X 0  0  0  2  0   0  0  0  0  0  0    0  ; 100 64 ; clear shifterX
  211. X 0  0  1  0  1   1  1  0  0  0  1  114  ; 101 65 ; lshift ACC; goto 114X
  212. X;X
  213. X; SRL (1011 0010) - shift logical rightX
  214. X 0  0  0  2  0   0  0  0  0  0  0    0  ; 102 66 ; clear shifterX
  215. X 0  0  1  0  2   1  1  0  0  0  1  114  ; 103 67 ; rshift ACC; goto 114X
  216. X;X
  217. X; SRA (1011 0100) - shift arithmetically rightX
  218. X 0  0 10  0  0   0  0  0  1  0  0  128  ; 104 68 ; hold <- mask(10000000)X
  219. X 0  0  1  0  1   4  0  0  0  0  0    0  ; 105 69 ; CC <- lshift(0x80&ACC)X
  220. X 0  0  1  0  2   1  1  0  0  0  1  114  ; 106 6a ; rshift ACC; goto 114X
  221. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 107 6b ; nopX
  222. X;X
  223. X; SLC (1011 0001) - shift circular leftX
  224. X 0  0 10  0  0   0  0  0  1  0  0  128  ; 108 6c ; hold <- mask(10000000)X
  225. X 0  0  1  0  1   4  0  0  0  0  0    0  ; 109 6d ; CC <- lshift(0x80&ACC)X
  226. X 0  0  1  0  1   1  1  0  0  0  1  114  ; 110 6e ; lshift ACC; goto 114X
  227. X;X
  228. X; SRC (1011 0011) - shift circular rightX
  229. X 0  0 10  0  0   0  0  0  1  0  0    1  ; 111 6f ; hold <- mask(00000001)X
  230. X 0  0  1  0  2   4  0  0  0  0  0    0  ; 112 70 ; CC <- rshift(0x01&ACC)X
  231. X 0  0  1  0  2   1  1  0  0  0  0    0  ; 113 71 ; rshift ACCX
  232. X;X
  233. X; send ACC thru ALU to get proper flags because shifter is after ALUX
  234. X 0  0  1  0  0   1  0  1  0  0  1  213  ; 114 72 ; ACC ; goto 213 X
  235. X;X
  236. X; OpCodes that have IR7=0X
  237. X 0  0  0  0  0   0  0  0  0  0  3  116  ; 115 73 ; test IR0,IR1 X
  238. X 0  0  0  0  0   0  0  0  0  0  1  120  ; 116 74 ; IR10 00; goto 120X
  239. X 0  0  0  0  0   0  0  0  0  0  1  126  ; 117 75 ; IR10 01; goto 126X
  240. X 0  0  0  0  0   0  0  0  0  0  1  133  ; 118 76 ; IR10 10; goto 133 X
  241. X;X
  242. X; Mode is Stack (11) - addr <- (SP) + operandX
  243. X 0  0  3  0  0   0  0  0  1  0  1  134  ; 119 77 ; hold <- SP; goto 134X
  244. X;X
  245. X; Mode is Direct (00) - addr <- operandX
  246. X 0  1  2  0  0   1 10  0  0  0  0    0  ; 120 78 ; MAR <- PC; READX
  247. X 0  1  2  0  0   9  2  0  0  0  0    0  ; 121 79 ; PC <- PC + 1; READX
  248. X 0  0  9  0  0   1  7  0  0  0  0    0  ; 122 7a ; B <- MBRX
  249. X 0  1  7  0  0   1 10  0  0  0  0    0  ; 123 7b ; MAR <- B; READX
  250. X 0  1  0  0  0   0  0  0  0  0  0    0  ; 124 7c ; READX
  251. X 0  0  0  0  0   0  0  0  0  0  1  139  ; 125 7d ; goto 139X
  252. X;X
  253. X; Mode is Indirect (01) - addr <- Memory[operand]X
  254. X 0  1  2  0  0   1 10  0  0  0  0    0  ; 126 7e ; MAR <- PC; READX
  255. X 0  1  2  0  0   9  2  0  0  0  0    0  ; 127 7f ; PC <- PC + 1; READX
  256. X 0  1  9  0  0   1 10  0  0  0  0    0  ; 128 80 ; MAR <- MBR; READX
  257. X 0  1  0  0  0   0  0  0  0  0  0    0  ; 129 81 ; READX
  258. X 0  0  9  0  0   1  7  0  0  0  0    0  ; 130 82 ; B <- MBRX
  259. X 0  1  7  0  0   1 10  0  0  0  0    0  ; 131 83 ; MAR <- B; READX
  260. X 0  1  0  0  0   0  0  0  0  0  1  139  ; 132 84 ; READ; goto 139X
  261. X;X
  262. X; Mode is Indexed (10) - addr <- (X) + operandX
  263. X 0  0  6  0  0   0  0  0  1  0  0    0  ; 133 85 ; hold <- XX
  264. X 0  1  2  0  0   1 10  0  0  0  0    0  ; 134 86 ; MAR <- PC; READX
  265. X 0  1  2  0  0   9  2  0  0  0  0    0  ; 135 87 ; PC <- PC + 1; READX
  266. X 0  0  9  0  0   7  7  0  0  0  0    0  ; 136 88 ; B <- MBR + holdX
  267. X 0  1  7  0  0   1 10  0  0  0  0    0  ; 137 89 ; MAR <- B; READX
  268. X 0  1  0  0  0   0  0  0  0  0  0    0  ; 138 8a ; READX
  269. X;X
  270. X; Mode is loaded into register B, keep on decoding instructionX
  271. X 0  0  0  0  0   0  0  0  0  0  6  140  ; 139 8b ; test IR7, IR6X
  272. X 0  0  0  0  0   0  0  0  0  0  1  170  ; 140 8c ; IR76 00; goto 170X
  273. X;X
  274. X; pc changersX
  275. X 0  0  5  0  0   0  0  0  1  0  0    0  ; 141 8d ; hold <- FLAGSX
  276. X 0  0 10  0  0   4  8  0  0  0  0    4  ; 142 8e ; C <- hold & 00000100X
  277. X 0  0  0  0  0   0  0  0  0  0  5  144  ; 143 8f ; test IR5, IR4X
  278. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 144 90 ; goto 8; neverX
  279. X 0  0  0  0  0   0  0  0  0  0  1  162  ; 145 91 ; goto 162X
  280. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 146 92 ; goto 8; neverX
  281. X;X
  282. X; branchingX
  283. X 0  0  0  0  0   0  0  0  0  0  4  148  ; 147 93 ; test IR3, IR2X
  284. X;X
  285. X; BR (0111 00aa) - branch alwaysX
  286. X 0  0  7  0  0   1  2  0  0  0  1    8  ; 148 94 ; PC <- B; goto 8 X
  287. X;X
  288. X 0  0  0  0  0   0  0  0  0  0  1  154  ; 149 95 ; IR32 01; goto 154X
  289. X 0  0  0  0  0   0  0  0  0  0  1  158  ; 150 96 ; IR32 10; goto 158X
  290. X;X
  291. X; BNEQ (0111 11aa) - branch if not zero (Z bit = 0)X
  292. X 0  0  8  0  0   1  0  0  0  2  2  152  ; 151 97 ; C; test ZBIT (inverse)X
  293. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 152 98 ; 1; goto 8X
  294. X 0  0  7  0  0   1  2  0  0  0  1    8  ; 153 99 ; 0; PC <- B; goto 8 X
  295. X;X
  296. X; BEQ (0111 01aa) - branch if zero (Z bit = 1)X
  297. X 0  0  8  0  0   1  0  0  0  2  2  156  ; 154 9a ; C; test ZBIT (inverse)X
  298. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 155 9b ; nopX
  299. X 0  0  7  0  0   1  2  0  0  0  1    8  ; 156 9c ; 1; PC <- B; goto 8 X
  300. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 157 9d ; 0; goto 8X
  301. X;X
  302. X; BLSS (0111 10aa) - branch if negative (N bit = 1) X
  303. X 0  0 10  0  0   4  8  0  0  0  0    8  ; 158 9e ; C <- hold & 00001000X
  304. X 0  0  8  0  0   1  0  0  0  2  2  160  ; 159 9f ; C ; test ZBITX
  305. X 0  0  7  0  0   1  2  0  0  0  1    8  ; 160 a0 ; N 1; PC <- B; goto 8 X
  306. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 161 a1 ; N 0; goto 8X
  307. X;X
  308. X; CALL (0101 00aa) - jump to subroutineX
  309. X 0  0  3  0  0   2  3  0  0  0  0    0  ; 162 a2 ; not SPX
  310. X 0  0  3  0  0   9  3  0  0  0  0    0  ; 163 a3 ; SP <- SP + 1X
  311. X 0  0  3  0  0   2  3  0  0  0  0    0  ; 164 a4 ; not SPX
  312. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 165 a5 ; nopX
  313. X 0  0  3  0  0   1 10  0  0  0  0    0  ; 166 a6 ; MAR <- SPX
  314. X 1  0  2  0  0   1  9  0  0  0  0    0  ; 167 a7 ; MBR <- PC; WRITEX
  315. X 1  0  7  0  0   1  2  0  0  0  0    0  ; 168 a8 ; PC <- B; WRITEX
  316. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 169 a9 ; goto 8X
  317. X;X
  318. X; OpCodes that have IR7=0 and IR6=0X
  319. X 0  0  0  0  0   0  0  0  0  0  5  172  ; 170 aa ; test IR5, IR4X
  320. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 171 ab ; nopX
  321. X 0  0  0  0  0   0  0  0  0  0  1  185  ; 172 ac ; IR54 00; goto 185X
  322. X 0  0  0  0  0   0  0  0  0  0  1  195  ; 173 ad ; IR54 01; goto 195X
  323. X 0  0  0  0  0   0  0  0  0  0  1  207  ; 174 ae ; IR54 10; goto 207X
  324. X;X
  325. X; storingX
  326. X 0  0  0  0  0   0  0  0  0  0  4  176  ; 175 af ; test IR3, IR2X
  327. X 0  0  0  0  0   0  0  0  0  0  1  181  ; 176 b0 ; IR32 00; goto 181X
  328. X;X
  329. X; STX (0011 01aa) - store index registerX
  330. X 0  0  7  0  0   1 10  0  0  0  0    0  ; 177 b1 ; MAR <- BX
  331. X 1  0  6  0  0   1  9  0  0  0  0    0  ; 178 b2 ; MBR <- X; WRITEX
  332. X 1  0  0  0  0   0  0  0  0  0  0    0  ; 179 b3 ; WRITEX
  333. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 180 b4 ; goto 8X
  334. X;X
  335. X; STA (0011 00aa) - store accumulatorX
  336. X 0  0  7  0  0   1 10  0  0  0  0    0  ; 181 b5 ; MAR <- BX
  337. X 1  0  1  0  0   1  9  0  0  0  0    0  ; 182 b6 ; MBR <- ACC; WRITEX
  338. X 1  0  0  0  0   0  0  0  0  0  0    0  ; 183 b7 ; WRITEX
  339. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 184 b8 ; goto 8X
  340. X;X
  341. X; math (add/subtract)X
  342. X 0  0  0  0  0   0  0  0  0  0  4  188  ; 185 b9 ; test IR3, IR2X
  343. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 186 ba ; nopX
  344. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 187 bb ; nopX
  345. X 0  0  0  0  0   0  0  0  0  0  1  193  ; 188 bc ; IR32 00; goto 193X
  346. X;X
  347. X; SUB (0000 01aa) - subtract from accumulatorX
  348. X 0  0  9  0  0   1  0  0  1  0  0    0  ; 189 bd ; hold <- MBRX
  349. X 0  0  1  0  0   2  1  0  0  0  0    0  ; 190 be ; not ACCX
  350. X 0  0  1  0  0   7  1  0  0  0  0    0  ; 191 bf ; ACC <- ACC + holdX
  351. X 0  0  1  0  0   2  1  1  0  0  1    8  ; 192 c0 ; not ACC; goto 8X
  352. X;X
  353. X; ADD (0000 00aa) - add to accumulatorX
  354. X 0  0  9  0  0   1  0  0  1  0  0    0  ; 193 c1 ; hold <- MBRX
  355. X 0  0  1  0  0   7  1  1  0  0  1    8  ; 194 c2 ; ACC <- ACC+hold; goto 8X
  356. X; X
  357. X; logicX
  358. X 0  0  0  0  0   0  0  0  0  0  4  196  ; 195 c3 ; test IR3, IR2X
  359. X 0  0  0  0  0   0  0  0  0  0  1  202  ; 196 c4 ; IR32 00; goto 202X
  360. X 0  0  0  0  0   0  0  0  0  0  1  200  ; 197 c5 ; IR32 01; goto 200X
  361. X;X
  362. X; AND (0001 10aa) - logical AND to accumulatorX
  363. X 0  0  9  0  0   1  0  0  1  0  0    0  ; 198 c6 ; hold <- MBRX
  364. X 0  0  1  0  0   4  1  1  0  0  1  211  ; 199 c7 ; ACC <- ACC&hold; goto211X
  365. X;X
  366. X; XOR (0001 01aa) - logical XOR to accumulatorX
  367. X 0  0  9  0  0   1  0  0  1  0  0    0  ; 200 c8 ; hold <- MBRX
  368. X 0  0  1  0  0   6  1  1  0  0  1  211  ; 201 c9 ; ACC <- ACC^hold; goto211X
  369. X;X
  370. X; OR (0001 00aa) - logical OR to accumulatorX
  371. X 0  0  9  0  0   1  0  0  1  0  0    0  ; 202 ca ; hold <- MBRX
  372. X 0  0  1  0  0   5  1  1  0  0  1  211  ; 203 cb ; ACC <- ACC|hold; goto211X
  373. XX
  374. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 204 cc ; nopX
  375. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 205 cd ; nopX
  376. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 206 ce ; nopX
  377. X;X
  378. X; loadingX
  379. X 0  0  0  0  0   0  0  0  0  0  4  208  ; 207 cf ; test IR3, IR2X
  380. X;X
  381. X; LDA (0010 00aa) - load accumulatorX
  382. X 0  0  9  0  0   1  1  1  0  0  1  211  ; 208 d0 ; ACC <- MBR; goto 211 X
  383. X;X
  384. X; LDX (0010 01aa) - load index registerX
  385. X 0  0  9  0  0   1  6  0  0  0  1    8  ; 209 d1 ; X <- MBR; goto 8X
  386. X;X
  387. X; LDS (0010 10aa) - load stack registerX
  388. X 0  0  9  0  0   1  3  0  0  0  1    8  ; 210 d2 ; SP <- MBR; goto 8X
  389. X;X
  390. X; set bits 'VC' to zero in flags registerX
  391. X 0  0 10  0  0   0  0  0  1  0  0  252  ; 211 d3 ; hold <- 11111100X
  392. X 0  0  5  0  0   4  5  0  0  0  1    8  ; 212 d4 ; FLAGS<-hold&FLGS; goto 8X
  393. X;X
  394. X; set bit 'V' to zero in flags registerX
  395. X 0  0  0  0  1  15  7  0  0  0  0    0  ; 213 d5 ; B <- CCX
  396. X 0  0  7  0  0   0  0  0  1  0  0    0  ; 214 d6 ; hold <- BX
  397. X 0  0  5  0  0   5  5  0  0  0  0    0  ; 215 d7 ; FLAGS <- hold | FLAGSX
  398. X 0  0 10  0  0   0  0  0  1  0  0  253  ; 216 d8 ; hold <- 11111101X
  399. X 0  0  5  0  0   4  5  0  0  0  1    8  ; 217 d9 ; FLAGS<-hold&FLGS; goto 8X
  400. X;X
  401. X; set bit 'C' to zero in flags registerX
  402. X 0  0 10  0  0   0  0  0  1  0  0  254  ; 218 da ; hold <- 11111110X
  403. X 0  0  5  0  0   4  5  0  0  0  1    8  ; 219 db ; FLAGS<-hold&FLGS; goto 8X
  404. XX
  405. X; That's All Folks!X
  406. Zaphod for prez
  407. cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > hfile
  408. XBEGINX
  409. XFORMATX
  410. X    write[1],X
  411. X    read[1],X
  412. X    asource[4],X
  413. X    cccntrl[2],X
  414. X    shftcntrl[2],X
  415. X    alufunc[4],X
  416. X    zdest[4],X
  417. X    ldflags[1],X
  418. X    ldhold[1],X
  419. X    test[2],X
  420. X    cond[3],X
  421. X    addrf[9];X
  422. XX
  423. XPARTSX
  424. X    pc[8], ac[8], sp[8], ir[8], flags[8],X
  425. X    rx[8], rb[8], rc[8], alu[8], mbr[8], mar[8], hold[8],X
  426. X    shifter[8], abus[8], zbus[8], *mpc[10], cc[1],X
  427. X    nbit[1], zbit[1], vbit[1], cbit[1];X
  428. XX
  429. XVARSX
  430. X    garbage[8], temp[8], temp2[8], temp3[8];X
  431. XX
  432. XMEMORYX
  433. X    cpu[512], mem[256][8];X
  434. XX
  435. XSUBCYCLEX
  436. X    subcycle = 2;X
  437. XX
  438. XINITX
  439. X    sp = 0xaa;X
  440. X    pc = 0xaa;X
  441. X    mpc = 0; X
  442. X    garbage = 0xaa;X
  443. X    hold = 0xaa;X
  444. XX
  445. XMICROENGINEX
  446. Xif ( subcycle == 1 ) {X
  447. XX
  448. X    /* Set value on ABUS */X
  449. XX
  450. X    abus = garbage;X
  451. XX
  452. X    temp3 = ( addrf & 0x0ff );X
  453. XX
  454. X    switch ( asource ) {X
  455. X        case 0: abus = garbage; break;X
  456. X        case 1: abus = ac; break;X
  457. X        case 2: abus = pc; break;X
  458. X        case 3: abus = sp; break;X
  459. X        case 4: abus = ir; break;X
  460. X        case 5: abus = flags; break;X
  461. X        case 6: abus = rx; break;X
  462. X        case 7: abus = rb; break;X
  463. X        case 8: abus = rc; break;X
  464. X        case 9: abus = mbr; break;X
  465. X        case 10: abus = temp3; break;X
  466. X    }X
  467. XX
  468. X    /* Set value in HOLD register */X
  469. XX
  470. X    if ( ldhold ) {X
  471. X        hold = abus;X
  472. X    }X
  473. XX
  474. X    /* Set ALU function */X
  475. X    X
  476. X    switch ( alufunc ) {X
  477. X        case 0:    alu = hold; break;X
  478. X        case 1:    alu = abus; break;X
  479. X        case 2:    alu = ( ~ abus ) - 1; break;X
  480. X        case 3:    alu = hold + abus + 1; break;X
  481. X        case 4:    alu = hold & abus; break;X
  482. X        case 5:    alu = hold | abus; break;X
  483. X        case 6:    alu = hold ^ abus; break;X
  484. X        case 7:    alu = hold + abus; break;X
  485. X        case 8:    alu = hold + 1; break;X
  486. X        case 9: alu = abus + 1; break;X
  487. X        case 10: alu = ( ~ hold ) - 1; break;X
  488. X        case 11: alu = abus & 1; break;X
  489. X        case 12: alu = abus - hold; break;X
  490. X        case 13: alu = hold & 1; break;X
  491. X        case 14: alu = -1; break;X
  492. X        case 15: alu = 0; break;X
  493. X    }X
  494. X}X
  495. XX
  496. Xif ( subcycle == 2 ) {X
  497. XX
  498. X    /* Set Condition Codes */X
  499. X    nbit = 0; zbit = 0; vbit = 0; cbit = 0;X
  500. X    temp = alu;X
  501. XX
  502. X    temp2 = temp & 0x80;X
  503. X    if ( temp2 != 0) nbit = 1;X
  504. XX
  505. X    temp2 = temp & 0xff;X
  506. X    if ( temp2 == 0 ) zbit = 1;X
  507. XX
  508. X    temp2 = temp & 0x1ff00;X
  509. X    if ( temp2 != 0 ) cbit = 1;X
  510. XX
  511. X    switch ( alufunc ) {X
  512. X        case 0:X
  513. X        case 1:X
  514. X        case 2: break;X
  515. X        case 3: alu = hold + abus + 1; break;X
  516. X        case 4:X
  517. X        case 5:X
  518. X        case 6: break;X
  519. X        case 7: if (((hold & 0x80) == 0) && ((abus & 0x80) == 0))X
  520. X                if (nbit != 0 ) vbit = 1;X
  521. X            if (((hold & 0x80) != 0) && ((abus & 0x80) != 0))X
  522. X                if (nbit != 1 ) vbit = 1;X
  523. X            break;X
  524. X        case 8:    if ((hold & 0x80 ) == 0 )X
  525. X                if ( nbit != 0 ) vbit = 1;X
  526. X            break;X
  527. X        case 9: if ((abus & 0x80 ) == 0)X
  528. X                if ( nbit != 0 ) vbit = 1;X
  529. X            break;X
  530. X        case 10:X
  531. X        case 11: break;X
  532. X        case 12: if (((hold & 0x80 ) != 0) && ((abus & 0x80) == 0))X
  533. X                if ( nbit != 0 ) vbit = 1;X
  534. X             if (((hold & 0x80 ) == 0) && ((abus & 0x80) != 0))X
  535. X                if ( nbit != 1 ) vbit = 1;X
  536. X             break;X
  537. X        case 13:X
  538. X        case 14:X
  539. X        case 15: break;X
  540. X    }X
  541. XX
  542. X    /* set CC bit for the shifter */X
  543. XX
  544. X    switch ( cccntrl ) {X
  545. X        case 0: break;X
  546. X        case 1: cc = 1; break;X
  547. X        case 2: cc = 0; break;X
  548. X        case 3: cc = cbit; break;X
  549. X    }X
  550. XX
  551. X    /* Load FLAGS from status of ALU */X
  552. XX
  553. X    if ( ldflags ) {X
  554. X        flags = cbit + ( 2 * vbit ) + ( 4 * zbit ) + ( 8 * nbit );X
  555. X    }X
  556. XX
  557. X    /* set output of shifter to zbus */X
  558. XX
  559. X    shifter = alu;X
  560. XX
  561. X    temp = cc;X
  562. XX
  563. X    switch ( shftcntrl ) {X
  564. X        case 1:    if ( shifter & 0x80 ) cc =1;X
  565. X            else cc = 0;X
  566. X            shifter = shifter << 1;X
  567. X            shifter = shifter + temp;X
  568. X            break;X
  569. X        case 2: cc = shifter & 1;X
  570. X            shifter = shifter >> 1;X
  571. X            if ( temp ) shifter = shifter | 0x80;X
  572. X            break;X
  573. X        default:X
  574. X            break;X
  575. X    }X
  576. XX
  577. X    zbus = shifter;X
  578. XX
  579. X    /* store zbus into any specified register */X
  580. XX
  581. X    if ( zdest != 0 ) X
  582. X        switch ( zdest ) {X
  583. X            case 0: garbage = zbus; break;X
  584. X            case 1: ac = zbus; break;X
  585. X            case 2: pc = zbus; break;X
  586. X            case 3: sp = zbus; break;X
  587. X            case 4: ir = zbus; break;X
  588. X            case 5: flags = zbus; break;X
  589. X            case 6: rx = zbus; break;X
  590. X            case 7: rb = zbus; break;X
  591. X            case 8: rc = zbus; break;X
  592. X            case 9: mbr = zbus; break;X
  593. X            case 10: mar = zbus; break;X
  594. X        }X
  595. XX
  596. X    /* Set MBR for reads */X
  597. XX
  598. X    if ( write ) {X
  599. X        if ( zdest <= 9 ) mem[mar] = mbr;X
  600. X        else mem[mar] = garbage;X
  601. X    }X
  602. X    if ( read ) {X
  603. X        if ( zdest <= 9 ) mbr = mem[mar];X
  604. X        else mbr = garbage;X
  605. X    }X
  606. XX
  607. X    /* determine select bit from the current ALU flag settings */X
  608. XX
  609. X    switch ( test ) {X
  610. X        case 0:    temp = cbit; break;X
  611. X        case 1:    temp = vbit; break;X
  612. X        case 2:    temp = zbit; break;X
  613. X        case 3:    temp = nbit; break;X
  614. X    }X
  615. XX
  616. X    /* Determine next value of MPC */X
  617. XX
  618. X    switch ( cond ) {X
  619. X        case 0: mpc = mpc + 1; break;X
  620. X        case 1: mpc = addrf; break;X
  621. X        case 2: mpc = ( addrf & 0x3fe ) + temp; break;X
  622. X        case 3: temp3 = ( ir & 0x03 );X
  623. X            mpc = (addrf & 0x1fc ) + temp3; break;X
  624. X        case 4: temp3 = ( ir & 0x0c ) >> 2;X
  625. X            mpc = ( addrf & 0x1fc ) + temp3; break;X
  626. X        case 5: temp3 = ( ir & 0x30 ) >> 4;X
  627. X            mpc = ( addrf & 0x1fc ) + temp3; break;X
  628. X        case 6: temp3 = ( ir & 0xc0 ) >> 6;X
  629. X            mpc = ( addrf & 0x1fc ) + temp3; break;X
  630. X        default: mpc = 9999; break;X
  631. X    }X
  632. X}X
  633. XX
  634. XENDX
  635. Zaphod for prez
  636. cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > license.gnu
  637. XX
  638. XX
  639. X                    GNU GENERAL PUBLIC LICENSEX
  640. X                       Version 2, June 1991X
  641. XX
  642. X Copyright (C) 1989, 1991 Free Software Foundation, Inc.X
  643. X                          675 Mass Ave, Cambridge, MA 02139, USAX
  644. X Everyone is permitted to copy and distribute verbatim copiesX
  645. X of this license document, but changing it is not allowed.X
  646. XX
  647. X                            PreambleX
  648. XX
  649. X  The licenses for most software are designed to take away yourX
  650. Xfreedom to share and change it.  By contrast, the GNU General PublicX
  651. XLicense is intended to guarantee your freedom to share and change freeX
  652. Xsoftware--to make sure the software is free for all its users.  ThisX
  653. XGeneral Public License applies to most of the Free SoftwareX
  654. XFoundation's software and to any other program whose authors commit toX
  655. Xusing it.  (Some other Free Software Foundation software is covered byX
  656. Xthe GNU Library General Public License instead.)  You can apply it toX
  657. Xyour programs, too.X
  658. XX
  659. X  When we speak of free software, we are referring to freedom, notX
  660. Xprice.  Our General Public Licenses are designed to make sure that youX
  661. Xhave the freedom to distribute copies of free software (and charge forX
  662. Xthis service if you wish), that you receive source code or can get itX
  663. Xif you want it, that you can change the software or use pieces of itX
  664. Xin new free programs; and that you know you can do these things.X
  665. XX
  666. X  To protect your rights, we need to make restrictions that forbidX
  667. Xanyone to deny you these rights or to ask you to surrender the rights.X
  668. XThese restrictions translate to certain responsibilities for you if youX
  669. Xdistribute copies of the software, or if you modify it.X
  670. XX
  671. X  For example, if you distribute copies of such a program, whetherX
  672. Xgratis or for a fee, you must give the recipients all the rights thatX
  673. Xyou have.  You must make sure that they, too, receive or can get theX
  674. Xsource code.  And you must show them these terms so they know theirX
  675. Xrights.X
  676. XX
  677. X  We protect your rights with two steps: (1) copyright the software, andX
  678. X(2) offer you this license which gives you legal permission to copy,X
  679. Xdistribute and/or modify the software.X
  680. XX
  681. X  Also, for each author's protection and ours, we want to make certainX
  682. Xthat everyone understands that there is no warranty for this freeX
  683. Xsoftware.  If the software is modified by someone else and passed on, weX
  684. Xwant its recipients to know that what they have is not the original, soX
  685. Xthat any problems introduced by others will not reflect on the originalX
  686. Xauthors' reputations.X
  687. XX
  688. X  Finally, any free program is threatened constantly by softwareX
  689. Xpatents.  We wish to avoid the danger that redistributors of a freeX
  690. Xprogram will individually obtain patent licenses, in effect making theX
  691. Xprogram proprietary.  To prevent this, we have made it clear that anyX
  692. Xpatent must be licensed for everyone's free use or not licensed at all.X
  693. XX
  694. X  The precise terms and conditions for copying, distribution andX
  695. Xmodification follow.X
  696. X X
  697. X                    GNU GENERAL PUBLIC LICENSEX
  698. X   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATIONX
  699. XX
  700. X  0. This License applies to any program or other work which containsX
  701. Xa notice placed by the copyright holder saying it may be distributedX
  702. Xunder the terms of this General Public License.  The "Program", below,X
  703. Xrefers to any such program or work, and a "work based on the Program"X
  704. Xmeans either the Program or any derivative work under copyright law:X
  705. Xthat is to say, a work containing the Program or a portion of it,X
  706. Xeither verbatim or with modifications and/or translated into anotherX
  707. Xlanguage.  (Hereinafter, translation is included without limitation inX
  708. Xthe term "modification".)  Each licensee is addressed as "you".X
  709. XX
  710. XActivities other than copying, distribution and modification are notX
  711. Xcovered by this License; they are outside its scope.  The act ofX
  712. Xrunning the Program is not restricted, and the output from the ProgramX
  713. Xis covered only if its contents constitute a work based on theX
  714. XProgram (independent of having been made by running the Program).X
  715. XWhether that is true depends on what the Program does.X
  716. XX
  717. X  1. You may copy and distribute verbatim copies of the Program'sX
  718. Xsource code as you receive it, in any medium, provided that youX
  719. Xconspicuously and appropriately publish on each copy an appropriateX
  720. Xcopyright notice and disclaimer of warranty; keep intact all theX
  721. Xnotices that refer to this License and to the absence of any warranty;X
  722. Xand give any other recipients of the Program a copy of this LicenseX
  723. Xalong with the Program.X
  724. XX
  725. XYou may charge a fee for the physical act of transferring a copy, andX
  726. Xyou may at your option offer warranty protection in exchange for a fee.X
  727. XX
  728. X  2. You may modify your copy or copies of the Program or any portionX
  729. Xof it, thus forming a work based on the Program, and copy andX
  730. Xdistribute such modifications or work under the terms of Section 1X
  731. Xabove, provided that you also meet all of these conditions:X
  732. XX
  733. X    a) You must cause the modified files to carry prominent noticesX
  734. X    stating that you changed the files and the date of any change.X
  735. XX
  736. X    b) You must cause any work that you distribute or publish, that inX
  737. X    whole or in part contains or is derived from the Program or anyX
  738. X    part thereof, to be licensed as a whole at no charge to all thirdX
  739. X    parties under the terms of this License.X
  740. XX
  741. X    c) If the modified program normally reads commands interactivelyX
  742. X    when run, you must cause it, when started running for suchX
  743. X    interactive use in the most ordinary way, to print or display anX
  744. X    announcement including an appropriate copyright notice and aX
  745. X    notice that there is no warranty (or else, saying that you provideX
  746. X    a warranty) and that users may redistribute the program underX
  747. X    these conditions, and telling the user how to view a copy of thisX
  748. X    License.  (Exception: if the Program itself is interactive butX
  749. X    does not normally print such an announcement, your work based onX
  750. X    the Program is not required to print an announcement.)X
  751. X X
  752. XThese requirements apply to the modified work as a whole.  IfX
  753. Xidentifiable sections of that work are not derived from the Program,X
  754. Xand can be reasonably considered independent and separate works inX
  755. Xthemselves, then this License, and its terms, do not apply to thoseX
  756. Xsections when you distribute them as separate works.  But when youX
  757. Xdistribute the same sections as part of a whole which is a work basedX
  758. Xon the Program, the distribution of the whole must be on the terms ofX
  759. Xthis License, whose permissions for other licensees extend to theX
  760. Xentire whole, and thus to each and every part regardless of who wrote it.X
  761. XX
  762. XThus, it is not the intent of this section to claim rights or contestX
  763. Xyour rights to work written entirely by you; rather, the intent is toX
  764. Xexercise the right to control the distribution of derivative orX
  765. Xcollective works based on the Program.X
  766. XX
  767. XIn addition, mere aggregation of another work not based on the ProgramX
  768. Xwith the Program (or with a work based on the Program) on a volume ofX
  769. Xa storage or distribution medium does not bring the other work underX
  770. Xthe scope of this License.X
  771. XX
  772. X  3. You may copy and distribute the Program (or a work based on it,X
  773. Xunder Section 2) in object code or executable form under the terms ofX
  774. XSections 1 and 2 above provided that you also do one of the following:X
  775. XX
  776. X    a) Accompany it with the complete corresponding machine-readableX
  777. X    source code, which must be distributed under the terms of SectionsX
  778. X    1 and 2 above on a medium customarily used for software interchange; or,X
  779. XX
  780. X    b) Accompany it with a written offer, valid for at least threeX
  781. X    years, to give any third party, for a charge no more than yourX
  782. X    cost of physically performing source distribution, a completeX
  783. X    machine-readable copy of the corresponding source code, to beX
  784. X    distributed under the terms of Sections 1 and 2 above on a mediumX
  785. X    customarily used for software interchange; or,X
  786. XX
  787. X    c) Accompany it with the information you received as to the offerX
  788. X    to distribute corresponding source code.  (This alternative isX
  789. X    allowed only for noncommercial distribution and only if youX
  790. X    received the program in object code or executable form with suchX
  791. X    an offer, in accord with Subsection b above.)X
  792. XX
  793. XThe source code for a work means the preferred form of the work forX
  794. Xmaking modifications to it.  For an executable work, complete sourceX
  795. Xcode means all the source code for all modules it contains, plus anyX
  796. Xassociated interface definition files, plus the scripts used toX
  797. Xcontrol compilation and installation of the executable.  However, as aX
  798. Xspecial exception, the source code distributed need not includeX
  799. Xanything that is normally distributed (in either source or binaryX
  800. Xform) with the major components (compiler, kernel, and so on) of theX
  801. Xoperating system on which the executable runs, unless that componentX
  802. Xitself accompanies the executable.X
  803. XX
  804. XIf distribution of executable or object code is made by offeringX
  805. Xaccess to copy from a designated place, then offering equivalentX
  806. Xaccess to copy the source code from the same place counts asX
  807. Xdistribution of the source code, even though third parties are notX
  808. Xcompelled to copy the source along with the object code.X
  809. X X
  810. X  4. You may not copy, modify, sublicense, or distribute the ProgramX
  811. Xexcept as expressly provided under this License.  Any attemptX
  812. Xotherwise to copy, modify, sublicense or distribute the Program isX
  813. Xvoid, and will automatically terminate your rights under this License.X
  814. XHowever, parties who have received copies, or rights, from you underX
  815. Xthis License will not have their licenses terminated so long as suchX
  816. Xparties remain in full compliance.X
  817. XX
  818. X  5. You are not required to accept this License, since you have notX
  819. Xsigned it.  However, nothing else grants you permission to modify orX
  820. Xdistribute the Program or its derivative works.  These actions areX
  821. Xprohibited by law if you do not accept this License.  Therefore, byX
  822. Xmodifying or distributing the Program (or any work based on theX
  823. XProgram), you indicate your acceptance of this License to do so, andX
  824. Xall its terms and conditions for copying, distributing or modifyingX
  825. Xthe Program or works based on it.X
  826. XX
  827. X  6. Each time you redistribute the Program (or any work based on theX
  828. XProgram), the recipient automatically receives a license from theX
  829. Xoriginal licensor to copy, distribute or modify the Program subject toX
  830. Xthese terms and conditions.  You may not impose any furtherX
  831. Xrestrictions on the recipients' exercise of the rights granted herein.X
  832. XYou are not responsible for enforcing compliance by third parties toX
  833. Xthis License.X
  834. XX
  835. X  7. If, as a consequence of a court judgment or allegation of patentX
  836. Xinfringement or for any other reason (not limited to patent issues),X
  837. Xconditions are imposed on you (whether by court order, agreement orX
  838. Xotherwise) that contradict the conditions of this License, they do notX
  839. Xexcuse you from the conditions of this License.  If you cannotX
  840. Xdistribute so as to satisfy simultaneously your obligations under thisX
  841. XLicense and any other pertinent obligations, then as a consequence youX
  842. Xmay not distribute the Program at all.  For example, if a patentX
  843. Xlicense would not permit royalty-free redistribution of the Program byX
  844. Xall those who receive copies directly or indirectly through you, thenX
  845. Xthe only way you could satisfy both it and this License would be toX
  846. Xrefrain entirely from distribution of the Program.X
  847. XX
  848. XIf any portion of this section is held invalid or unenforceable underX
  849. Xany particular circumstance, the balance of the section is intended toX
  850. Xapply and the section as a whole is intended to apply in otherX
  851. Xcircumstances.X
  852. XX
  853. XIt is not the purpose of this section to induce you to infringe anyX
  854. Xpatents or other property right claims or to contest validity of anyX
  855. Xsuch claims; this section has the sole purpose of protecting theX
  856. Xintegrity of the free software distribution system, which isX
  857. Ximplemented by public license practices.  Many people have madeX
  858. Xgenerous contributions to the wide range of software distributedX
  859. Xthrough that system in reliance on consistent application of thatX
  860. Xsystem; it is up to the author/donor to decide if he or she is willingX
  861. Xto distribute software through any other system and a licensee cannotX
  862. Ximpose that choice.X
  863. XX
  864. XThis section is intended to make thoroughly clear what is believed toX
  865. Xbe a consequence of the rest of this License.X
  866. X X
  867. X  8. If the distribution and/or use of the Program is restricted inX
  868. Xcertain countries either by patents or by copyrighted interfaces, theX
  869. Xoriginal copyright holder who places the Program under this LicenseX
  870. Xmay add an explicit geographical distribution limitation excludingX
  871. Xthose countries, so that distribution is permitted only in or amongX
  872. Xcountries not thus excluded.  In such case, this License incorporatesX
  873. Xthe limitation as if written in the body of this License.X
  874. XX
  875. X  9. The Free Software Foundation may publish revised and/or new versionsX
  876. Xof the General Public License from time to time.  Such new versions willX
  877. Xbe similar in spirit to the present version, but may differ in detail toX
  878. Xaddress new problems or concerns.X
  879. XX
  880. XEach version is given a distinguishing version number.  If the ProgramX
  881. Xspecifies a version number of this License which applies to it and "anyX
  882. Xlater version", you have the option of following the terms and conditionsX
  883. Xeither of that version or of any later version published by the FreeX
  884. XSoftware Foundation.  If the Program does not specify a version number ofX
  885. Xthis License, you may choose any version ever published by the Free SoftwareX
  886. XFoundation.X
  887. XX
  888. X  10. If you wish to incorporate parts of the Program into other freeX
  889. Xprograms whose distribution conditions are different, write to the authorX
  890. Xto ask for permission.  For software which is copyrighted by the FreeX
  891. XSoftware Foundation, write to the Free Software Foundation; we sometimesX
  892. Xmake exceptions for this.  Our decision will be guided by the two goalsX
  893. Xof preserving the free status of all derivatives of our free software andX
  894. Xof promoting the sharing and reuse of software generally.X
  895. XX
  896. X                            NO WARRANTYX
  897. XX
  898. X  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTYX
  899. XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHENX
  900. XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIESX
  901. XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSEDX
  902. XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OFX
  903. XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK ASX
  904. XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THEX
  905. XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,X
  906. XREPAIR OR CORRECTION.X
  907. XX
  908. X  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITINGX
  909. XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/ORX
  910. XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,X
  911. XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISINGX
  912. XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITEDX
  913. XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BYX
  914. XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHERX
  915. XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THEX
  916. XPOSSIBILITY OF SUCH DAMAGES.X
  917. XX
  918. X                     END OF TERMS AND CONDITIONSX
  919. X X
  920. X        Appendix: How to Apply These Terms to Your New ProgramsX
  921. XX
  922. X  If you develop a new program, and you want it to be of the greatestX
  923. Xpossible use to the public, the best way to achieve this is to make itX
  924. Xfree software which everyone can redistribute and change under these terms.X
  925. XX
  926. X  To do so, attach the following notices to the program.  It is safestX
  927. Xto attach them to the start of each source file to most effectivelyX
  928. Xconvey the exclusion of warranty; and each file should have at leastX
  929. Xthe "copyright" line and a pointer to where the full notice is found.X
  930. XX
  931. X    <one line to give the program's name and a brief idea of what it does.>X
  932. X    Copyright (C) 19yy  <name of author>X
  933. XX
  934. X    This program is free software; you can redistribute it and/or modifyX
  935. X    it under the terms of the GNU General Public License as published byX
  936. X    the Free Software Foundation; either version 2 of the License, orX
  937. X    (at your option) any later version.X
  938. XX
  939. X    This program is distributed in the hope that it will be useful,X
  940. X    but WITHOUT ANY WARRANTY; without even the implied warranty ofX
  941. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theX
  942. X    GNU General Public License for more details.X
  943. XX
  944. X    You should have received a copy of the GNU General Public LicenseX
  945. X    along with this program; if not, write to the Free SoftwareX
  946. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.X
  947. XX
  948. XAlso add information on how to contact you by electronic and paper mail.X
  949. XX
  950. XIf the program is interactive, make it output a short notice like thisX
  951. Xwhen it starts in an interactive mode:X
  952. XX
  953. X    Gnomovision version 69, Copyright (C) 19yy name of authorX
  954. X    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.X
  955. X    This is free software, and you are welcome to redistribute itX
  956. X    under certain conditions; type `show c' for details.X
  957. XX
  958. XThe hypothetical commands `show w' and `show c' should show the appropriateX
  959. Xparts of the General Public License.  Of course, the commands you use mayX
  960. Xbe called something other than `show w' and `show c'; they could even beX
  961. Xmouse-clicks or menu items--whatever suits your program.X
  962. XX
  963. XYou should also get your employer (if you work as a programmer) or yourX
  964. Xschool, if any, to sign a "copyright disclaimer" for the program, ifX
  965. Xnecessary.  Here is a sample; alter the names:X
  966. XX
  967. X  Yoyodyne, Inc., hereby disclaims all copyright interest in the programX
  968. X  `Gnomovision' (which makes passes at compilers) written by James Hacker.X
  969. XX
  970. X  <signature of Ty Coon>, 1 April 1989X
  971. X  Ty Coon, President of ViceX
  972. XX
  973. XThis General Public License does not permit incorporating your program intoX
  974. Xproprietary programs.  If your program is a subroutine library, you mayX
  975. Xconsider it more useful to permit linking proprietary applications with theX
  976. Xlibrary.  If this is what you want to do, use the GNU Library GeneralX
  977. XPublic License instead of this License.X
  978. Zaphod for prez
  979. cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > memory
  980. X; YAMPC test memoryX
  981. X; YAMPC distribution packageX
  982. X20 ; 0 load direct acc from 20 - all address in hexX
  983. X20 ; 1 address 20X
  984. X00 ; 2 add direct 21 to accX
  985. X21 ; 3 address 21X
  986. X80 ; 4 increment accX
  987. X04 ; 5 subtract direct 22 from accX
  988. X22 ; 6 address 22X
  989. X30 ; 7 store direct acc into 23X
  990. X23 ; 8X
  991. X90 ; 9 clear accX
  992. X80 ; a increment accX
  993. X82 ; b decrement accX
  994. X82 ; c decrement accX
  995. X30 ; d store in 24X
  996. X24 ; eX
  997. X91 ; f clear xX
  998. X83 ;10 dec xX
  999. X81 ;11 inc xX
  1000. X81 ;12 inc xX
  1001. X34 ;13 store x in 25X
  1002. X25 ;14X
  1003. Xf0 ;15 haltX
  1004. X00 ;16 nopX
  1005. X00 ;17 nopX
  1006. X00 ;18 nopX
  1007. X00 ;19 nopX
  1008. X00 ;1a nopX
  1009. X00 ;1b nopX
  1010. X00 ;1c nopX
  1011. X00 ;1d nopX
  1012. X00 ;1e nopX
  1013. X00 ;1f nopX
  1014. X44 ;20X
  1015. X21 ;21X
  1016. X15 ;22X
  1017. Xaa ;23 -- 51 load/add/sub/storX
  1018. Xaa ;24 -- ff inc/dec accX
  1019. Xaa ;25 -- 01 inc/dec xX
  1020. XX
  1021. XX
  1022. Zaphod for prez
  1023. cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > tmac.ine
  1024. X.\"X
  1025. X.\" TROFF MACRO DEFINTIONX
  1026. X.\" Patrick Palmer, January 31, 1992X
  1027. X.\"X
  1028. X.\" MACRO: Start typewriter fontX
  1029. X.de YSX
  1030. X.fp 2 CX
  1031. X.cs C 24X
  1032. X.nfX
  1033. X.ft CX
  1034. X..X
  1035. X.\" MACRO: End typewriter fontX
  1036. X.de YEX
  1037. X.ft PX
  1038. X.fiX
  1039. X.cs CX
  1040. X.fp 2 IX
  1041. X..X
  1042. X.\" MACRO: New PageX
  1043. X.de NPX
  1044. X.ev 1        \" change the environmentX
  1045. X'sp 0.5i    \" go down half wayX
  1046. X.ft R        \" set title font to RomanX
  1047. X.ps 10        \" set size to 10pX
  1048. X.po 0.5i    \" set page offsetX
  1049. X.lt 7i        \" set length to 7 inchesX
  1050. X.tl '''\\*(BS'X
  1051. X'bp        \" page breakX
  1052. X'sp 1iX
  1053. X.vs 3p        \" set vertical spacing to noneX
  1054. X.if o .tl '''\\*(TY    %'X
  1055. X.if e .tl '%    \\*(TZ'''X
  1056. X\l'7i'X
  1057. X.vsX
  1058. X.poX
  1059. X.psX
  1060. X.ev        \" restore the environmentX
  1061. X'sp 0.3iX
  1062. X..X
  1063. X.\" MACRO: Title at bottom page, right sideX
  1064. X.de PBX
  1065. X.ds BS \\$1X
  1066. X..X
  1067. X.\" MACRO: Title at top of page, right side, odd pageX
  1068. X.de POX
  1069. X.ds TY \\$1X
  1070. X..X
  1071. X.\" MACRO: Title at top of page, right side, even pageX
  1072. X.de PEX
  1073. X.ds TZ \\$1X
  1074. X..X
  1075. X.\" MACRO: New paragraphX
  1076. X.de PPX
  1077. X.spX
  1078. X..X
  1079. X.\" MACRO: Section PartX
  1080. X.de SPX
  1081. X.ne 1i        \" new page first if with 2 inches of bottomX
  1082. X.mkX
  1083. X.ll 1.75i    \" set line length to 1 3/4 inchesX
  1084. X.po 0.5iX
  1085. X.ps 12X
  1086. X\\$1X
  1087. X.brX
  1088. X.psX
  1089. X.llX
  1090. X.poX
  1091. X.rtX
  1092. X..X
  1093. X.\" MACRO: Section TitleX
  1094. X.de STX
  1095. X.SP "\fB\\$1\fP"X
  1096. X..X
  1097. X.\" MACRO: Section Part Right JustifyX
  1098. X.de SRX
  1099. X.ad r        \" right justifyX
  1100. X.SP "\\$1"X
  1101. X.ad l        \" left justifyX
  1102. X..X
  1103. X.\" MACRO: Update Start (mark in margin update changes)X
  1104. X.de USX
  1105. X.mc \s12\(br\s0X
  1106. X..X
  1107. X.\" MACRO: Update EndX
  1108. X.de UEX
  1109. X.mcX
  1110. X..X
  1111. X.\" MACRO: Full PageX
  1112. X.de FPX
  1113. X.ll 7iX
  1114. X.po 0.5iX
  1115. X..X
  1116. X.\ MACRO: Page FormattedX
  1117. X.de PFX
  1118. X.ll 5i        \" line length is 5 inchesX
  1119. X.po 2.5i    \" page offset set to 2 3/4 inchesX
  1120. X..X
  1121. X.\"X
  1122. X.\" DEFAULT DEFINITIONSX
  1123. X.PFX
  1124. X.ps 11X
  1125. X.wh -1i NPX
  1126. X.ad l        \" produce flush-left, ragged-right outputX
  1127. XX
  1128. XX
  1129. Zaphod for prez
  1130. cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > yampc.1
  1131. X.TH YAMPC 1X
  1132. X.SH NAMEX
  1133. XYAMPC \- Yet Another Micro Program CompilerX
  1134. X.SH SYNOPSISX
  1135. X.B yampcX
  1136. XfileX
  1137. X.B X
  1138. X.SH DESCRIPTIONX
  1139. X.I YampcX
  1140. Xis a compiler to convert the hardware description file of theX
  1141. Xdesired architecture into C.X
  1142. XOnce the architecture is compiled by X
  1143. X.I yampcX
  1144. Xand the C compiler, the microprogramming systemX
  1145. Xcan be used to simulate the particular hardware using X
  1146. Xmicrocode.X
  1147. X.I YampcX
  1148. Xis the first step in creating the microprogramming system.X
  1149. X.PPX
  1150. XMany CISC microprocessors use microcode interally so theX
  1151. Xdevelopment and the debugging of the CPU can be done quicklyX
  1152. Xand efficently.  X
  1153. XWith this in mind, this microprogramming system was developed X
  1154. Xto be used as a teaching aid and as a first phase developmentX
  1155. Xkit of microcode for a particular hardware.X
  1156. X.PPX
  1157. XThe argument toX
  1158. X.I yampcX
  1159. Xis the hardware description file to be compiled. X
  1160. XThe results of this program is to create a C source code fileX
  1161. Xwith the same file name plus a ".c" extention.X
  1162. X.SH EXAMPLEX
  1163. XTo compile the desired architecture into C.X
  1164. X.RS 4X
  1165. Xyampc hdfX
  1166. X.RE 1X
  1167. X.PPX
  1168. XTo create the executable to interpretX
  1169. Xthe microcode of the architecture.X
  1170. X.RS 4X
  1171. Xcc hdf.c -o hdf -lyampcX
  1172. X.RE 1X
  1173. X.SH SEE ALSOX
  1174. XTheX
  1175. X.I YAMPC Reference Manual,X
  1176. Xincluded as the fileX
  1177. X.B yampc.docX
  1178. Xin the X
  1179. X.I yampcX
  1180. Xsource distribution.X
  1181. X.SH DIAGNOSTICSX
  1182. XNested comments are not valid.X
  1183. X.SH BUGSX
  1184. XSome syntax errors cause a slew of more errors to appear X
  1185. Xeven though there isn't any others.X
  1186. XThis is due to the fact thatX
  1187. X.I yampcX
  1188. Xdoesn't try to analyze and fix the error.X
  1189. Zaphod for prez
  1190. cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > yampc.doc
  1191. X.\"X
  1192. X.\" YAMPC Microcode Development Kit DocumentX
  1193. X.\" Patrick Palmer, January 31, 1992X
  1194. X.\"X
  1195. X.\" Read in the pre-defined macro packageX
  1196. X.so tmac.ine    \" read in -mine macro definitionX
  1197. X.\"X
  1198. X.\" DOCUMENTX
  1199. X.\"X
  1200. X.ds Y Y\s-2AMPC\s+2X
  1201. X.ta 3.5iX
  1202. X.PB "Draft A"X
  1203. X.PO "\*Y Microcode Development Kit"X
  1204. X.PE "\*Y version 1.2"X
  1205. X.sp 3iX
  1206. X.ps 24X
  1207. X.vs 28X
  1208. X.FPX
  1209. X.ce 2X
  1210. XYAMPCX
  1211. XMicrocode Development KitX
  1212. X.brX
  1213. X.psX
  1214. X.vsX
  1215. X.sp 1iX
  1216. X.ce 2X
  1217. XPatrick PalmerX
  1218. XFebruary 28, 1992X
  1219. X.PFX
  1220. X.bpX
  1221. X.SP "Table of Contents"X
  1222. X.TSX
  1223. Xl.X
  1224. X1. IntroductionX
  1225. X2. Microcode DevelopmentX
  1226. X3. Hardware Description LanguageX
  1227. X4. Trial by ExampleX
  1228. X5. Technical GuideX
  1229. XA. Reserved WordsX
  1230. XB. TutorialX
  1231. XC. Miscellaneous NotesX
  1232. X.TEX
  1233. X.PPX
  1234. X.PPX
  1235. X.PPX
  1236. X.SP "Acknowledgements"X
  1237. XI wish to thank the following people for their assistanceX
  1238. Xin the completion of this project.X
  1239. X.PPX
  1240. X.TSX
  1241. Xcenter;X
  1242. Xl.X
  1243. XRayno Neimi, \fIRochester Institute of Technology\fPX
  1244. XMargaret Reek, \fIRochester Institute of Technology\fPX
  1245. X.TEX
  1246. X.PPX
  1247. XA lot of \*Y was derived from the AMISS project written X
  1248. Xby Robert Pesar, ex graduate student of Rochester Institute ofX
  1249. XTechnology.X
  1250. XSome of this documentation was adapted from the AMISS thesis and by noX
  1251. Xway means to infinge on that.X
  1252. X.PPX
  1253. X.PPX
  1254. X.PPX
  1255. X.SP "Distribution"X
  1256. XThis program is free software; you can redistribute it and/or modifyX
  1257. Xit under the terms of the GNU General Public License (version 2)X
  1258. Xas published by the Free Software Foundation.X
  1259. X.PPX
  1260. XThis program is distributed in the hope that it will be useful,X
  1261. Xbut WITHOUT ANY WARRANTY; without even the implied warranty ofX
  1262. XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theX
  1263. XGNU General Public License for more details.X
  1264. X.PPX
  1265. XYou should have received a copy of the GNU General Public LicenseX
  1266. Xalong with this program; if not, write to the Free SoftwareX
  1267. XFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.X
  1268. X.PPX
  1269. X\*Y Microcode Development KitX
  1270. X.brX
  1271. X\(co 1992 by Patrick PalmerX
  1272. X.PPX
  1273. X.PPX
  1274. X.PPX
  1275. X.SP "Source Availability"X
  1276. XThe current source for this project has been submitted to theX
  1277. X\fIalt.sources\fP usenet group and can be retrievedX
  1278. Xanonymous ftp from any of the known archive locations.X
  1279. X.PE "Introduction"X
  1280. X.bpX
  1281. X.ST "1. Introduction"X
  1282. XIn today's world, there is the need to develop microprocessorsX
  1283. Xquickly and easily with very little room for bugs.X
  1284. XA methodology that developed in microprocessor design was theX
  1285. Xincorporation of microcode.X
  1286. XMicrocode interprets the assembly language instruction set andX
  1287. Xmanipulate the hardware.X
  1288. XIn turn, this removes many of the hassles and low level hardwareX
  1289. Xneeded.X
  1290. X.PPX
  1291. XMicrocoding has been around for a while and has been addressedX
  1292. Xby many of the technical societies. X
  1293. XBoth the ACM and the IEEE has discussed and presented articlesX
  1294. Xabout microcode as a topic of study.X
  1295. XA microprogramming simulation system can be usefulX
  1296. Xaddition to the teachings of microprogramming principles.X
  1297. XSuch systems do exist and are available but many are limitedX
  1298. Xby their ability to represent only a single microarchitecture.X
  1299. XThe intent of this project is to overcome that barrier.X
  1300. X.PPX
  1301. X\*Y is inheritly adaptable for a variety of microcodingX
  1302. Xprojects.X
  1303. XThe system is quite flexiable because of it's ability to X
  1304. Xcompletely design the architecture and the instruction set.X
  1305. XThe interactive debugger helps in quickly  identifying X
  1306. Xbugs with the microcode without ever touching actualX
  1307. Xhardware.X
  1308. X.PPX
  1309. XA primary goal in developing \*Y was to identify those detailsX
  1310. Xcommon to the description of microarchitectures and toX
  1311. Xcombine those details into a Hardware Description Language (HDL).X
  1312. XRather than developing a new programming language, \*Y HDL is X
  1313. Xbased on the C programming language and an HDL program is X
  1314. Xtranslated into a C program.X
  1315. XA \*Y HDL program is divided into two parts.X
  1316. XIn the first part the specifications of the elements of theX
  1317. Xarchitecture and of the control memory format are identified.X
  1318. XIn the second part, the course of events within the processorX
  1319. Xgoverned by the contents of a control memory word areX
  1320. Xdescribed.X
  1321. X.PPX
  1322. XThis is not a complete system by any means.X
  1323. XThere doesn't exist the ability nor was its intention to beX
  1324. Xused in a production environment.X
  1325. XThe purpose of this project is solely educational for bothX
  1326. Xmyself and the people it will be used by.X
  1327. X.PPX
  1328. X.SP "Educational Purposes"X
  1329. XWith the above discussion in mind, \*Y was developed X
  1330. Xfor the purpose to teach students about microcode and X
  1331. Xthe underlying architecture of microprocessors.X
  1332. XMicrocode development and easily be integrated intoX
  1333. Xa Computer Architecture course so students can learnX
  1334. Xhands on.X
  1335. X.PPX
  1336. XThere are many texts available that discuss ComputerX
  1337. XArchitecture.X
  1338. XEach in their own way present a hypothetical X
  1339. Xmicroarchitecture and a microprogram written in a high X
  1340. Xlevel microprogramming language that is capable of implementingX
  1341. Xall or some part of an instruction set.X
  1342. XWith the flexability to design hardware, the professor now hasX
  1343. Xthe ability to create a project for the students that isX
  1344. Xmodeled after a course text book.X
  1345. X.PPX
  1346. X.SP "Example"X
  1347. XI am convinced that the best way to explain the use of this systemX
  1348. Xis by example.X
  1349. XChapter 4 is by far the largest chapter and it shows a completeX
  1350. XHDL and microcode.X
  1351. XThe example is simple by nature but it does implement most of theX
  1352. Xcapabilities of the system.X
  1353. XI figure that chapter will become the focal point for reference.X
  1354. X.PE "Microcode Development"X
  1355. X.bpX
  1356. X.ST "2. Microcode Development"X
  1357. XThe intention of this project is let the user beX
  1358. Xable to develop microcode for a designed microhardware set.X
  1359. XThe purpose of microcode is to be able to interpret theX
  1360. Xassembly language and manipulate the hardware.X
  1361. X.PPX
  1362. XFrom a hardware point, there are separate parts of theX
  1363. Xmicroarchitecture that the microcode will interact with.X
  1364. XThese may include registers, Arithmetic Logic Unit, or a shifterX
  1365. Xof some sort.X
  1366. XThe microcode control word has access to all of the individualX
  1367. Xunits and manipulates them based on possible instructions.X
  1368. X.PPX
  1369. XThe process just to read in the a single assembly languageX
  1370. Xinstruction and act on it can be a full process.X
  1371. XLets take a instruction from the example in chapter 4 and X
  1372. Xfollow it through.X
  1373. X.PPX
  1374. X.TSX
  1375. Xcenter;X
  1376. Xl.X
  1377. X1. Initialization of the processor.X
  1378. X2. Fetch an instruction from memory - CLRA.X
  1379. X3. Decode the instruction.X
  1380. X4. Set the flags register - Zero flag set.X
  1381. X5. Move zero into the accumulator.X
  1382. X6. Go back to the fetch cycle and fetch another ins.X
  1383. X.TEX
  1384. X.PPX
  1385. X.SP "File Format"X
  1386. XThe microcode file is a listing of all of the control words thatX
  1387. Xare used to manipulate the hardware.X
  1388. XThe entire control word needs to be on one contingious line.X
  1389. XEach of the elements of the control word need to be separated X
  1390. Xwith a white space.X
  1391. X.PPX
  1392. XThe fetch cycle default start at microcode address 8.X
  1393. XThis in most cases will be satisfactory but there is the abilityX
  1394. Xto change it.X
  1395. XThe '.fetch [#]' command can appear at the beginning of the fileX
  1396. Xbut to note, the number specifying the new fetch cycle must beX
  1397. Xin decimal.X
  1398. X.PPX
  1399. XThe default is all values in the microcode file is hexidecimal.X
  1400. XThis can be changed by using a '.decimal' for decimal notationX
  1401. Xand '.octal' for octal notation.X
  1402. XThe '.decimal' or '.octal' should appear at the top of the file.X
  1403. X.PPX
  1404. XIn chapter 4, there is a complete microcode file and it isX
  1405. Xvery useful in helping the beginner understand the file format.X
  1406. X.PPX
  1407. X.SP "Assembly Programs"X
  1408. XOnce the microcode has be created, it needs to be tested againstX
  1409. Xsome actual data.X
  1410. XSince the purpose of microcode is to interpret assembly instructions,X
  1411. Xan assembly language file is used.X
  1412. XThis assembly language file contains the values of the instructions.X
  1413. XFor example, using the chapter 4 example, the instruction CLRA isX
  1414. Xactually 0x90.X
  1415. XEach of the instructions should be placed into the 'memory' fileX
  1416. Xand can be included into the interpreter at the command line.X
  1417. XThe can be one or more instructions on a line but there is noX
  1418. Xneed for the '0x' infront of every value.X
  1419. X.PPX
  1420. XComments can appear anywhere in the file and are delimited byX
  1421. Xa ';' and a newline.X
  1422. XThere doesn't need to be an assembly instruction on every line in theX
  1423. Xfile.X
  1424. XAlso, the '.decimal' and '.octal' commands that are available in theX
  1425. Xmicrocode file are also available here.X
  1426. X.PPX
  1427. X.SP "Using the Interpreter"X
  1428. XUsing the processor interpreter is pretty simple to use.X
  1429. XThe processor needs to be created from the HDL file and thenX
  1430. Xcompiled.X
  1431. XFor the sake of example, lets say it was compiled into theX
  1432. Xname 'CPU'.X
  1433. XTo start executing the microcode, the 'CPU' command can be used alone.X
  1434. XThis assumes though that the microcode is containedX
  1435. Xin a file called 'cmemory' and the assemblyX
  1436. Xlanguage code is in a file 'memory'.X
  1437. XIf this isn't true, then the file names need to be specified on theX
  1438. Xcommand line.X
  1439. X.PPX
  1440. XOnce the 'CPU' program is executing, a version banner is displayed andX
  1441. Xexecution begins.X
  1442. XThe program will end when the assembly language program finishes.X
  1443. XWhen it does, a message will appear displaying the number of cyclesX
  1444. Xto took to complete.X
  1445. X.PPX
  1446. X.SP "Correction File"X
  1447. XOne of the most powerful features of \*Y is the ability to create X
  1448. Xa correction file.X
  1449. XThis correction file can be used by students to determine which X
  1450. Xinstructions are working properly or by a professor grading X
  1451. Xthe submitted student code.X
  1452. X.PPX
  1453. XTo build a correction file, there is the '-c' option at the commandX
  1454. Xlevel that is used to build the correction file.X
  1455. XSince there is the need to know the correction file name (it doesn'tX
  1456. Xdefault), all of the memory file name must be listed in the commandX
  1457. Xline.X
  1458. XHere is an example:X
  1459. X.PPX
  1460. X.ps 9X
  1461. X.in +1iX
  1462. X.YSX
  1463. X% cpu -cpc,sp,flags,ac cmemory memory correctX
  1464. X.YEX
  1465. X.inX
  1466. X.psX
  1467. X.PPX
  1468. XThe above command will create a correction file asssuming thatX
  1469. Xthe 'cmemory' and 'memory' files are correct and that the registersX
  1470. Xthat are listed are actually defined.X
  1471. XThis file is only a correction file for that one assembly languageX
  1472. Xprogram found in the 'memory' file.X
  1473. XGiven the example in Chapter 4, listed below is an outcome with theX
  1474. Xdistributed 'memory' file.X
  1475. X.PPX
  1476. X.in +1iX
  1477. X.YSX
  1478. X1 sp=ffX
  1479. X2 pc=2 ac=44X
  1480. X3 pc=4 ac=65X
  1481. X4 pc=5 ac=66X
  1482. X5 pc=7 ac=51X
  1483. X6 pc=9X
  1484. X7 pc=a flags=4 ac=0X
  1485. X8 pc=b flags=0 ac=1X
  1486. X9 pc=c flags=4 ac=0X
  1487. Xa pc=d flags=8 ac=ffX
  1488. Xb pc=fX
  1489. Xc pc=10X
  1490. Xd pc=11X
  1491. Xe pc=12X
  1492. Xf pc=13X
  1493. X10 pc=15X
  1494. X.YEX
  1495. X.inX
  1496. X.PPX
  1497. XThe first number represents the count of the fetch cycle.X
  1498. XEach time that the fetch cycle is reached, each of the registersX
  1499. Xis compared and the ones that are changed from the previousX
  1500. Xfetch cycle is written out.X
  1501. X.PPX
  1502. XWhen using the correction file to test out the microcode, the '-c'X
  1503. Xoption is not used.X
  1504. XThe correction file is just added to the end of the command line.X
  1505. XIn the process of executing the microcode, the correction fileX
  1506. Xis checked against the current value of the registers.X
  1507. XIf the two compared values differ, the message is printed to X
  1508. Xstandard output and the register is updated.X
  1509. XThe register is updated so the program can continue on its properX
  1510. Xdirection.X
  1511. X.PPX
  1512. X.SP "Debugging"X
  1513. XThe interactive debugger allows the user to manipulate the microcodeX
  1514. Xand memory at run time.X
  1515. XThis is very useful in tracking down bugs that may exist in theX
  1516. Xmicrocode.X
  1517. X.PPX
  1518. XTo enter the debugger, the '-d' option is used in the command line.X
  1519. XThe system will then initialize itself and prompt the user forX
  1520. Xcommands.X
  1521. XCommand reference for the interactive debugger is availableX
  1522. Xin Appendix B.X
  1523. X.PE "Hardware Description Language"X
  1524. X.bpX
  1525. X.ST "3. Hardware Description Language"X
  1526. XThe Hardware Desciption Language (HDL) is the low levelX
  1527. Xprocessor code.X
  1528. XThis gives the ability to design the microarchitectureX
  1529. Xand customize it to personal taste.X
  1530. XThis is really the heart and advantage of the system.X
  1531. XThis is part that separates this project from the others.X
  1532. X.PPX
  1533. X.SP "Language Structure"X
  1534. XThe HDL language is a comparable to a sectionalized C.X
  1535. XMeaning that the actual code is similar to C but thereX
  1536. Xare sections for each part of the language.X
  1537. XListed below is each section (in proper order) and theirX
  1538. Xmeaning.X
  1539. X.PPX
  1540. X.TSX
  1541. Xcenter box tab(/);X
  1542. Xcw(1i) c, l | l.X
  1543. XSection/MeaningX
  1544. X=X
  1545. XFORMAT/This is the area that defines theX
  1546. X/actual control word.  Each part ofX
  1547. X/the control word is defined withX
  1548. X/the appropriate number of bits wide.X
  1549. X_X
  1550. XPARTS/This is where all of the registersX
  1551. X/and internal variables that can beX
  1552. X/accesses by the microcode. EachX
  1553. X/register is defined with the numberX
  1554. X/of desired bits.X
  1555. X_X
  1556. XVARS/Local variables that are definedX
  1557. X/are placed into this section.  Again,X
  1558. X/the desired number of bits is used.X
  1559. X_X
  1560. XMEMORY/This is where the control wordX
  1561. X/and main memory is defined.  TheX
  1562. X/size of each plus the actual mainX
  1563. X/memory word size is also defined.X
  1564. X_X
  1565. XSUBCYCLE/This section is used toX
  1566. X/define the number of subcycles inX
  1567. X/a particular cycle.X
  1568. X_X
  1569. XINTERRUPT/This section contains allX
  1570. X/of the defined interrupts uponX
  1571. X/boot of the processor.X
  1572. X_X
  1573. XINIT/This section contains all of theX
  1574. X/code that is needed for theX
  1575. X/initialization of the processor.X
  1576. X/Usually this would be setting theX
  1577. X/registers to a known state.X
  1578. X_X
  1579. XMICROENGINE/This is all of the code X
  1580. X/that is executed each cycle of theX
  1581. X/processor.  It does all of theX
  1582. X/actual manipulating of the micro-X
  1583. X/hardware.X
  1584. X.TEX
  1585. X.PPX
  1586. XThe entire program must be enclosed in the keywords 'BEGIN'X
  1587. Xand 'END'.X
  1588. X.PPX
  1589. XComments can appear anywhere in the codeX
  1590. Xand use standard C language style.X
  1591. XAll comments are delimited as the following.X
  1592. X.PPX
  1593. X.in +1iX
  1594. X.YSX
  1595. X/* ... Comment ... */X
  1596. X.YEX
  1597. X.inX
  1598. X.PPX
  1599. X.SP "Variable Definitions"X
  1600. XVariables are being defined in the FORMAT, PARTS and VARSX
  1601. Xsection of the language.X
  1602. XEach variable is listed with a brackets and numbers appearingX
  1603. Xright afters for bit definitions.X
  1604. XBelow is a listing of some variables defined in a FORMATX
  1605. Xsection.X
  1606. X.PPX
  1607. X.in +1iX
  1608. X.YSX
  1609. XFORMATX
  1610. X    write[1],X
  1611. X    read[1],X
  1612. X    asource[4],X
  1613. X    cccntrl[2],X
  1614. X    shftcntrl[2],X
  1615. X    alufunc[4],X
  1616. X    zdest[4],X
  1617. X    ldflags[1],X
  1618. X    ldhold[1],X
  1619. X    test[2],X
  1620. X    cond[3],X
  1621. X    addrf[9];X
  1622. X.YEX
  1623. X.inX
  1624. X.PPX
  1625. XThere is one difference though in the PARTS section.X
  1626. XA '*' is placed before the variable that will be theX
  1627. XMicro Program Counter (MPC).X
  1628. XThis must be defined or the program will not be able toX
  1629. Xwork properly.X
  1630. XThe MPC is the only way to move around in the microcode.X
  1631. X.PPX
  1632. X.SP "Memory Definitions"X
  1633. XDefining memory is set in that there is only one methodologyX
  1634. Xto do it.X
  1635. XThe best way is by example and then explain.X
  1636. X.PPX
  1637. X.in +1iX
  1638. X.YSX
  1639. XMEMORYX
  1640. X     cpu[512], mem[256][8];X
  1641. X.YEX
  1642. X.inX
  1643. X.PPX
  1644. XFirst the cpu control words are defined as being up to 512 of them.X
  1645. XThe size of the control word is determined from the FORMAT section.X
  1646. XThe actual main memory is defined as 256 bytes, 8 bits each byte.X
  1647. X.PPX
  1648. X.SP "Constructs"X
  1649. XThe Hardware Description language supports a subset commandsX
  1650. Xavailable from the C language.X
  1651. XThe ones supports should be enough for anything theX
  1652. Xprogrammer needs to accomplish.X
  1653. X.PPX
  1654. XWherever numerical input is expected, you can type an X
  1655. Xarithmetic expression.X
  1656. XAn expression involves parenthese and arithmetic operatorsX
  1657. Xand logical operators shown the table below:X
  1658. X.PPX
  1659. X.TSX
  1660. Xcenter box tab(#);X
  1661. Xc c, c l.X
  1662. X\fIArithmetic Operator#Meaning\fPX
  1663. X_X
  1664. X+#AdditionX
  1665. X-#SubtractionX
  1666. X/#DivisionX
  1667. X*#MultiplicationX
  1668. X%#ModuloX
  1669. X<<#Shift leftX
  1670. X>>#Shift rightX
  1671. X&#Bitwise andX
  1672. X|#Bitwise orX
  1673. X^#Exclusive orX
  1674. X~#Binary NotX
  1675. X_X
  1676. X.T&X
  1677. Xc c, c l.X
  1678. X\fILogical Operator#Meaning\fPX
  1679. X_X
  1680. X<#Less thanX
  1681. X>#Greater thanX
  1682. X<\&=#Less than or equal toX
  1683. X>\&=#Greater than or equal toX
  1684. X\&= or \&=\&=#Equal toX
  1685. X&&#andX
  1686. X||#orX
  1687. X.TEX
  1688. X.PPX
  1689. XListed below is a syntax summary of the availableX
  1690. Xlanguage constructs.X
  1691. X.PPX
  1692. X.in +1iX
  1693. X\fIcompound-statement:X
  1694. X.brX
  1695. X        declaration-list statement-listX
  1696. X.PPX
  1697. Xdeclaration-list:X
  1698. X.brX
  1699. X        declarationX
  1700. X.brX
  1701. X        declaration declaration-listX
  1702. X.PPX
  1703. Xstatement-list:X
  1704. X.brX
  1705. X        statementX
  1706. X.brX
  1707. X        statement statement-listX
  1708. X.PPX
  1709. Xstatement:X
  1710. X.brX
  1711. X        compound-statementX
  1712. X.brX
  1713. X        expression ;X
  1714. X.brX
  1715. X        \fPif (\fI expression \fP)\fI statementX
  1716. X.brX
  1717. X        \fPif (\fI expression \fP)\fI statement \fPelse\fI statementX
  1718. X.brX
  1719. X        \fPswitch (\fI expression \fP)\fI statementX
  1720. X.brX
  1721. X        \fPcase\fI constant-expression\fP:\fI statementX
  1722. X.brX
  1723. X        \fPdefault:\fI statementX
  1724. X.brX
  1725. X        \fPbreak;X
  1726. X.brX
  1727. X        Ireturn;X
  1728. X.brX
  1729. X        ;X
  1730. X.inX
  1731. X.PPX
  1732. X.SP "Initialization"X
  1733. XInitialization of the processor is only done at X
  1734. Xprocessor bootup and if the system is reset inX
  1735. Xthe interactive debugger.X
  1736. XThis section can contain any of the language X
  1737. Xconstructs but it is usually left for setting ofX
  1738. Xregisters.X
  1739. X.PPX
  1740. X.SP "Microcode Engine"X
  1741. XThe microcode engine is executed every subcycleX
  1742. Xor every cycle.X
  1743. XThe actual code inside the engine can use any ofX
  1744. Xthe language constructs available.X
  1745. XThe programmer will find that a lot of this section becomesX
  1746. Xbig switch statements for moving a value from/to a register.X
  1747. X.PPX
  1748. XExamine the HDL file found in chapter 4 for a complete example.X
  1749. XThat program uses all of the available constructs toX
  1750. Xbuild the microengine.X
  1751. X.PPX
  1752. X.SP "Pre-defined Variables"X
  1753. XCurrently there is only one predefined variable.X
  1754. XThe keyword 'subcycle' is used so at differentX
  1755. Xsubcycles different operations can occur.X
  1756. XAt this time, there is no support for debuggingX
  1757. Xon the subcycle level but it is on the FutureX
  1758. XEnhansement list in Appendix C.X
  1759. XThere is entire support within the system forX
  1760. Xsubcycles.X
  1761. X.PPX
  1762. X.SP "Compiling"X
  1763. XOnce the HDL language has been written, it needs to be submitted X
  1764. Xto the \*Y compiler.X
  1765. XThe compiler compiles the HDL source code into C source code.X
  1766. XThe C source output is then compiled and linked with theX
  1767. Xaccompanied library.X
  1768. XAfter these steps have been completed, the microcode interpreterX
  1769. Xfor the specified hardware will now be available to usage.X
  1770. XListed below is the explict steps needed to create thisX
  1771. Xinterpreter.X
  1772. X.PPX
  1773. X.in +1iX
  1774. X.YSX
  1775. X% yampc HardwareFileX
  1776. X% cc HardwareFile.c -o cpu libyampc.aX
  1777. X.YEX
  1778. X.inX
  1779. X.PPX
  1780. XAny errors returned from the compiler are quite self-explanatoryX
  1781. Xand useful.X
  1782. XThe system has a tendency though to display many more errorsX
  1783. Xthan necessary once it has come across one.X
  1784. XI suggest to fix the first one and try once again toX
  1785. Xrecompile.X
  1786. X.PE "Trial by Example"X
  1787. X.bpX
  1788. X.ST "4. Trial by Example"X
  1789. XThe best way to understand the usage of this project is byX
  1790. Xexample.X
  1791. XIn the section, a Hardware Description Language and associatedX
  1792. Xmicrocode will be demonstrated.X
  1793. XThe HDL has actually be used in a class at Rochester Institute ofX
  1794. XTechnology.X
  1795. XFor a first step, there needs to be an explanation of the X
  1796. Xdesired hardware.X
  1797. X.PPX
  1798. X.SP "Machine Description"X
  1799. XThe target machine is very simple.X
  1800. XThe following user-visible registers are 8-bits wide:X
  1801. X.PPX
  1802. X.TSX
  1803. Xcenter tab (/);X
  1804. Xc c, l l.X
  1805. XRegister/PurposeX
  1806. X_X
  1807. XPC/program counterX
  1808. XSP/stack pointerX
  1809. XX/index registerX
  1810. XFlags/flags registerX
  1811. XACC/arithmetic accumulatorX
  1812. X.TEX
  1813. X.PPX
  1814. XThis the entire "reach" of this target von Veuman machine is only 256X
  1815. Xlocations of one byte (8-bits per byte) each.X
  1816. XThe data path is eight bits.X
  1817. X.PPX
  1818. XThe bits in a byte are numbered from 7 for high-order bit to 0 for X
  1819. Xlow-order bit.X
  1820. XThe bits in the flags register have the following interpretation:X
  1821. X.PPX
  1822. X.TSX
  1823. Xcenter tab (/);X
  1824. Xc c, c l.X
  1825. XBit Position/DescriptionX
  1826. X_X
  1827. X7/Not UsedX
  1828. X6/Not UsedX
  1829. X5/Not UsedX
  1830. X4/Not UsedX
  1831. X3/"N" for negative resultX
  1832. X2/"Z" for zero resultX
  1833. X1/"V" for overflow resultX
  1834. X0/"C" for carry outX
  1835. X.TEX
  1836. X.PPX
  1837. XThe values of N, Z, V, and C are determined by the current inputs toX
  1838. Xthe ALU.X
  1839. XTo save these status bits for later operations, they need to be storedX
  1840. Xin the flags register.X
  1841. X.PPX
  1842. X.SP "Machine Instruction Set"X
  1843. XThe machine has short and long instructions.X
  1844. XShort instructions are one byte long while long instructions are twoX
  1845. Xbytes long.X
  1846. XThe first bit is always 1 for short instructions and 0 for long X
  1847. Xinstructions.X
  1848. XThe short instructions are zero operand instructions.X
  1849. XThe long instructions are one operand instructions with an implied X
  1850. Xregister, the accumulator.X
  1851. XThe machine follows the accumulator register model.X
  1852. X.bpX
  1853. XThe condition code setting for each instruction are the following:X
  1854. X"0" indicates bit cleared, "1" indicates bit set, "x" indicatesX
  1855. Xbit may chage, and "-" indicates no change.X
  1856. X.PPX
  1857. X.ne 3iX
  1858. X.ps 7X
  1859. X.vs 9X
  1860. X.TSX
  1861. Xcenter tab (/);X
  1862. Xc s s s, c c c c, l l l l.X
  1863. X\fBShort Instructions\fPX
  1864. XOp Code/Mnemonic/Description/NZVCX
  1865. X_X
  1866. X1000 0000/INCA/increment accumulator/xxxxX
  1867. X1000 0001/INCX/increment index register/----X
  1868. X1000 0010/DECA/decrement accumulator/xxxxX
  1869. X1000 0011/DECX/decrement index register/----X
  1870. X///X
  1871. X1001 0000/CLRA/clear accumulator/0100X
  1872. X1001 0001/CLRX/clear index register/----X
  1873. X///X
  1874. X1010 0000/NOT/bitwise complement of accumulator/xx00X
  1875. X1010 0001/NEG/2's complement negation of accumulator/xxx0X
  1876. X///X
  1877. X1011 0000/SLL/shift left logical/xx0xX
  1878. X1011 0001/SLC/shift left circular/xx0xX
  1879. X///X
  1880. X1011 0010/SRL/shift right logical/xx0xX
  1881. X1011 0011/SRC/shift right circular/xx0xX
  1882. X1011 0100/SRA/shift right arithmetic/xx0xX
  1883. X///X
  1884. X1100 0000/POP ACC/pop accumulator off top of stack/xx00X
  1885. X1100 0001/POP X/pop index register off top of stack/----X
  1886. X1100 0010/POP FLAGS/pop flags off top of stack/----X
  1887. X///X
  1888. X1101 0000/PUSH ACC/push accumulator on stack/----X
  1889. X1101 0001/PUSH X/push index register on stack/----X
  1890. X1101 0010/PUSH FLAGS/push flags on stack/----X
  1891. X///X
  1892. X1110 0000/RETN/return from subroutine/----X
  1893. X///X
  1894. X1111 0000/HALT/halt execution/----X
  1895. X.TEX
  1896. X.ps 11X
  1897. X.vs 13X
  1898. X.PPX
  1899. XThe two low-order bits (indicated by "aa") for a long instructionX
  1900. Xindicate the addressing mode.X
  1901. X.PPX
  1902. X.ne 2iX
  1903. X.ps 7X
  1904. X.vs 9X
  1905. X.TSX
  1906. Xcenter tab (/);X
  1907. Xc s s s, c c c c, l l l l.X
  1908. X\fBLong Instructions\fPX
  1909. XOp Code/Mnemonic/Description/NZVCX
  1910. X_X
  1911. X0000 00aa/ADD/add to accumulator/xxxxX
  1912. X0000 01aa/SUB/suctract from accumulator/xxxxX
  1913. X///X
  1914. X0001 00aa/OR/logical OR to accumulator/xx00X
  1915. X0001 01aa/XOR/logical XOR to accumulator/xx00X
  1916. X0001 10aa/AND/logical AND to accumulator/xx00X
  1917. X///X
  1918. X0010 00aa/LDA/load accumulator/xx00X
  1919. X0010 01aa/LDX/load index register/----X
  1920. X0010 10aa/LDS/load stack register/----X
  1921. X///X
  1922. X0011 00aa/STA/store accumulator/----X
  1923. X0011 01aa/STX/store index register/----X
  1924. X///X
  1925. X0101 00aa/CALL/jump to subroutine/----X
  1926. X///X
  1927. X0111 00aa/BR/branch always/----X
  1928. X0111 01aa/BEQ/branch if zero (Z bit = 1)/----X
  1929. X0111 10aa/BLSS/branch if negative (N bit = 1)/----X
  1930. X0111 11aa/BNEQ/branch if not zero (Z bit = 0)/----X
  1931. X.TEX
  1932. X.ps 11X
  1933. X.vs 13X
  1934. X.bpX
  1935. XThe machine has four address mode for long instructions.X
  1936. XThe second instruction holds an 8-bit operand.X
  1937. XThe addressing mode combines with the operand to yield a memoryX
  1938. Xaddress \fBaddr\fP as described below:X
  1939. X.PPX
  1940. X.TSX
  1941. Xcenter tab(/);X
  1942. Xc c c, c l l.X
  1943. XMode Bits/Mode/DescriptionX
  1944. X_X
  1945. X00/Direct/addr\(<-operandX
  1946. X01/Indirect/addr\(<-Memory[operand]X
  1947. X10/Indexed/addr\(<-(X) + operandX
  1948. X11/Stack/addr\(<-(SP) + operandX
  1949. X.T&X
  1950. Xc.X
  1951. Xwhere operand is stored in next byteX
  1952. X.TEX
  1953. X.PPX
  1954. X.SP "MicroInstruction Format"X
  1955. XThe following table describes the format of the control word X
  1956. Xfor the microcode.X
  1957. X.PPX
  1958. X.TSX
  1959. Xcenter expand tab (/);X
  1960. Xc c c c, c c l l l.X
  1961. XBit/Field/Name/OperationX
  1962. X=X
  1963. X0/A/WRITE/0 - no operationX
  1964. X///1 - WriteX
  1965. X_X
  1966. X1/B/READ/0 - no operationX
  1967. X///1 - ReadX
  1968. X_X
  1969. X2/C/ASOURCE/0000 - noneX
  1970. X3///0001 - ACCX
  1971. X4///0010 - PCX
  1972. X5///0011 - PCX
  1973. X///0100 - IRX
  1974. X///0101 - FLAGSX
  1975. X///0110 - XX
  1976. X///0111 - BX
  1977. X///1000 - CX
  1978. X///1001 - MBRX
  1979. X///1010 - low-order 8-bits from/Address FieldX
  1980. X///1011 - 1111 - unusedX
  1981. X_X
  1982. X6/D/CCCTRL/00 - Leave CC aloneX
  1983. X7///01 - Set CCX
  1984. X///10 - Clear CCX
  1985. X///11 - CC := carry out of ALUX
  1986. X_X
  1987. X8/E/SHFTCTRL/00 - No shiftX
  1988. X9///01 - Shift leftX
  1989. X///10 - Shift rightX
  1990. X///11 - unusedX
  1991. X_X
  1992. X10/F/ALUCTRL/0000 - X/1000 - X + 1X
  1993. X11///0001 - Y/1001 - Y + 1X
  1994. X12///0010 - ~ Y/1010 - ~ XX
  1995. X13///0011 - X + Y + 1/1011 - Y & 1X
  1996. X///0100 - X & Y/1100 - Y + ~ X + 1X
  1997. X///0101 - X | Y/1101 - X & 1X
  1998. X///0110 - X ^ Y/1110 - -1 (all 1s)X
  1999. X///0111 - X + Y/1111 - 0 (all 0s)X
  2000. X_X
  2001. X.TEX
  2002. X.bpX
  2003. X.TSX
  2004. Xcenter expand tab (/);X
  2005. Xc c c c, c c l l.X
  2006. XBit/Field/Name/OperationX
  2007. X=X
  2008. X14/G/ZDEST/0000 - noneX
  2009. X15///0001 - ACCX
  2010. X16///0010 - PCX
  2011. X17///0011 - SPX
  2012. X///0100 - IRX
  2013. X///0101 - FLAGSX
  2014. X///0110 - XX
  2015. X///0111 - BX
  2016. X///1000 - CX
  2017. X///1001 - MBRX
  2018. X///1010 - MARX
  2019. X///1011 - 1111 - unusedX
  2020. X_X
  2021. X18/H/LOADFLGS/0 - do not change FLAGS registerX
  2022. X///1 - load FLAGS register from N,Z,V,C-BITX
  2023. X_X
  2024. X19/I/LOADHOLD/0 - do not change HOLD registerX
  2025. X///1 - Load HOLD register from ABUSX
  2026. X_X
  2027. X20/J/TEST/00 - Select C-BIT from ALUX
  2028. X21///01 - Select V-BIT from ALUX
  2029. X///10 - Select Z-BIT from ALUX
  2030. X///11 - Select N-BIT from ALUX
  2031. X_X
  2032. X22/K/COND/Determines type of next addressX
  2033. X23///(see next section)X
  2034. X24///X
  2035. X_X
  2036. X25/L/ADDRF/Next microinstruction address fieldX
  2037. X26///(see next section)X
  2038. X27///X
  2039. X28///X
  2040. X29///X
  2041. X30///X
  2042. X31///X
  2043. X32///X
  2044. X33///X
  2045. X_X
  2046. X.TEX
  2047. X.PPX
  2048. X.SP "Microcode Program Counter"X
  2049. XThe control store is 512 x 34 bits.X
  2050. XThe MPC is 9 bits wide and the MIR is 36 bits wide.X
  2051. XThe next value of the MicroProgram Counter (MPC) is determined by theX
  2052. Xvalue of the ADDRF, COND, and TEST fields in the following manner.X
  2053. X.PPX
  2054. X.TSX
  2055. Xcenter box tab (/);X
  2056. Xc | c, c | l.X
  2057. XCOND/MPCX
  2058. X=X
  2059. X000/MPC + 1X
  2060. X_X
  2061. X001/ADDRFX
  2062. X_X
  2063. X010/25 26 27 28 29 30 31 32 TEST-BIT (2-way branch)X
  2064. X_X
  2065. X011/25 26 27 28 29 30 31 IR1 IR0 (4-way branch)X
  2066. X_X
  2067. X100/25 26 27 28 29 30 31 IR3 IR2 (4-way branch)X
  2068. X_X
  2069. X101/25 26 27 28 29 30 31 IR5 IR4 (4-way branch)X
  2070. X_X
  2071. X110/25 26 27 28 29 30 31 IR7 IR6 (4-way branch)X
  2072. X_X
  2073. X111/not usedX
  2074. X.TEX
  2075. X.PPX
  2076. X.SP "Memory Timing"X
  2077. XAll memory accesses take at least 2 machine cycles.X
  2078. XTo write to memory, the WRITE fields must be 1 in the microinstructionX
  2079. Xwhich completes the loading of the MAR and the MBR registers.X
  2080. XThe next microinstruction must also have the WRITE field set to 1.X
  2081. XThe READ fields must be 0.X
  2082. X.PPX
  2083. XTo read from memory, the data is not available for one completeX
  2084. Xmachine cycle after the MAR register hsa been loaded with the address.X
  2085. XThe READ field must be 1 in both microinstructions and the WRITEX
  2086. Xfields set to 0.X
  2087. X.PPX
  2088. X.SP "Hardware Description Language"X
  2089. XListed below is the source for the Hardware Description Language for theX
  2090. Xabove described machine.X
  2091. X.PPX
  2092. X.FPX
  2093. X.in +1iX
  2094. X.ps 9X
  2095. X.vs 11X
  2096. X.YSX
  2097. XX
  2098. XBEGINX
  2099. XFORMATX
  2100. X    write[1],X
  2101. X    read[1],X
  2102. X    asource[4],X
  2103. X    cccntrl[2],X
  2104. X    shftcntrl[2],X
  2105. X    alufunc[4],X
  2106. X    zdest[4],X
  2107. X    ldflags[1],X
  2108. X    ldhold[1],X
  2109. X    test[2],X
  2110. X    cond[3],X
  2111. X    addrf[9];X
  2112. XX
  2113. XPARTSX
  2114. X    pc[8], ac[8], sp[8], ir[8], flags[8],X
  2115. X    rx[8], rb[8], rc[8], alu[8], mbr[8], mar[8], hold[8],X
  2116. X    shifter[8], abus[8], zbus[8], *mpc[10], cc[1],X
  2117. X    nbit[1], zbit[1], vbit[1], cbit[1];X
  2118. XX
  2119. XVARSX
  2120. X    garbage[8], temp[8], temp2[8], temp3[8];X
  2121. XX
  2122. XMEMORYX
  2123. X    cpu[512], mem[256][8];X
  2124. XX
  2125. XSUBCYCLEX
  2126. X    subcycle = 2;X
  2127. XX
  2128. XINITX
  2129. X    sp = 0xaa;X
  2130. X    pc = 0xaa;X
  2131. X    mpc = 0; X
  2132. X    garbage = 0xaa;X
  2133. X    hold = 0xaa;X
  2134. XX
  2135. XMICROENGINEX
  2136. Xif ( subcycle == 1 ) {X
  2137. XX
  2138. X    /* Set value on ABUS */X
  2139. XX
  2140. X    abus = garbage;X
  2141. XX
  2142. X    temp3 = ( addrf & 0x0ff );X
  2143. XX
  2144. X    switch ( asource ) {X
  2145. X        case 0:  abus = garbage;  break;X
  2146. X        case 1:  abus = ac;       break;X
  2147. X        case 2:  abus = pc;       break;X
  2148. X        case 3:  abus = sp;       break;X
  2149. X        case 4:  abus = ir;       break;X
  2150. X        case 5:  abus = flags;    break;X
  2151. X        case 6:  abus = rx;       break;X
  2152. X        case 7:  abus = rb;       break;X
  2153. X        case 8:  abus = rc;       break;X
  2154. X        case 9:  abus = mbr;      break;X
  2155. X        case 10: abus = temp3;    break;X
  2156. X    }X
  2157. XX
  2158. X    /* Set value in HOLD register */X
  2159. XX
  2160. X    if ( ldhold ) {X
  2161. X        hold = abus;X
  2162. X    }X
  2163. XX
  2164. X    /* Set ALU function */X
  2165. X    X
  2166. X    switch ( alufunc ) {X
  2167. X        case 0:    alu = hold;              break;X
  2168. X        case 1:    alu = abus;              break;X
  2169. X        case 2:    alu = ( ~ abus ) - 1;    break;X
  2170. X        case 3:    alu = hold + abus + 1;   break;X
  2171. X        case 4:    alu = hold & abus;       break;X
  2172. X        case 5:    alu = hold | abus;       break;X
  2173. X        case 6:    alu = hold ^ abus;       break;X
  2174. X        case 7:    alu = hold + abus;       break;X
  2175. X        case 8:    alu = hold + 1;          break;X
  2176. X        case 9:    alu = abus + 1;          break;X
  2177. X        case 10:   alu = ( ~ hold ) - 1;    break;X
  2178. X        case 11:   alu = abus & 1;          break;X
  2179. X        case 12:   alu = abus - hold;       break;X
  2180. X        case 13:   alu = hold & 1;          break;X
  2181. X        case 14:   alu = -1;                break;X
  2182. X        case 15:   alu = 0;                 break;X
  2183. X    }X
  2184. X}X
  2185. XX
  2186. Xif ( subcycle == 2 ) {X
  2187. XX
  2188. X    /* Set Condition Codes */X
  2189. X    nbit = 0; zbit = 0; vbit = 0; cbit = 0;X
  2190. X    temp = alu;X
  2191. XX
  2192. X    temp2 = temp & 0x80;X
  2193. X    if ( temp2 != 0) nbit = 1;X
  2194. XX
  2195. X    temp2 = temp & 0xff;X
  2196. X    if ( temp2 == 0 ) zbit = 1;X
  2197. XX
  2198. X    temp2 = temp & 0x1ff00;X
  2199. X    if ( temp2 != 0 ) cbit = 1;X
  2200. XX
  2201. X    switch ( alufunc ) {X
  2202. X        case 0:X
  2203. X        case 1:X
  2204. X        case 2: break;X
  2205. X        case 3: alu = hold + abus + 1; break;X
  2206. X        case 4:X
  2207. X        case 5:X
  2208. X        case 6: break;X
  2209. X        case 7: if (((hold & 0x80) == 0) && ((abus & 0x80) == 0))X
  2210. X                if (nbit != 0 ) vbit = 1;X
  2211. X            if (((hold & 0x80) != 0) && ((abus & 0x80) != 0))X
  2212. X                if (nbit != 1 ) vbit = 1;X
  2213. X            break;X
  2214. X        case 8:    if ((hold & 0x80 ) == 0 )X
  2215. X                if ( nbit != 0 ) vbit = 1;X
  2216. X            break;X
  2217. X        case 9: if ((abus & 0x80 ) == 0)X
  2218. X                if ( nbit != 0 ) vbit = 1;X
  2219. X            break;X
  2220. X        case 10:X
  2221. X        case 11: break;X
  2222. X        case 12: if (((hold & 0x80 ) != 0) && ((abus & 0x80) == 0))X
  2223. X                if ( nbit != 0 ) vbit = 1;X
  2224. X             if (((hold & 0x80 ) == 0) && ((abus & 0x80) != 0))X
  2225. X                if ( nbit != 1 ) vbit = 1;X
  2226. X             break;X
  2227. X        case 13:X
  2228. X        case 14:X
  2229. X        case 15: break;X
  2230. X    }X
  2231. XX
  2232. X    /* set CC bit for the shifter */X
  2233. XX
  2234. X    switch ( cccntrl ) {X
  2235. X        case 0:            break;X
  2236. X        case 1: cc = 1;    break;X
  2237. X        case 2: cc = 0;    break;X
  2238. X        case 3: cc = cbit; break;X
  2239. X    }X
  2240. XX
  2241. X    /* Load FLAGS from status of ALU */X
  2242. XX
  2243. X    if ( ldflags ) {X
  2244. X        flags = cbit + ( 2 * vbit ) + ( 4 * zbit ) + ( 8 * nbit );X
  2245. X    }X
  2246. XX
  2247. X    /* set output of shifter to zbus */X
  2248. XX
  2249. X    shifter = alu;X
  2250. XX
  2251. X    temp = cc;X
  2252. XX
  2253. X    switch ( shftcntrl ) {X
  2254. X        case 1:X
  2255. X            if ( shifter & 0x80 ) cc = 1;X
  2256. X            else cc = 0;X
  2257. X            shifter = shifter << 1;X
  2258. X            shifter = shifter + temp;X
  2259. X            break;X
  2260. XX
  2261. X        case 2: X
  2262. X            cc = shifter & 1;X
  2263. X            shifter = shifter >> 1;X
  2264. X            if ( temp ) shifter = shifter | 0x80;X
  2265. X            break;X
  2266. XX
  2267. X        default:X
  2268. X            break;X
  2269. X    }X
  2270. XX
  2271. X    zbus = shifter;X
  2272. XX
  2273. X    /* store zbus into any specified register */X
  2274. XX
  2275. X    if ( zdest != 0 ) X
  2276. X        switch ( zdest ) {X
  2277. X            case 0:  garbage = zbus;  break;X
  2278. X            case 1:  ac = zbus;       break;X
  2279. X            case 2:  pc = zbus;       break;X
  2280. X            case 3:  sp = zbus;       break;X
  2281. X            case 4:  ir = zbus;       break;X
  2282. X            case 5:  flags = zbus;    break;X
  2283. X            case 6:  rx = zbus;       break;X
  2284. X            case 7:  rb = zbus;       break;X
  2285. X            case 8:  rc = zbus;       break;X
  2286. X            case 9:  mbr = zbus;      break;X
  2287. X            case 10: mar = zbus;      break;X
  2288. X        }X
  2289. XX
  2290. X    /* Set MBR for reads */X
  2291. XX
  2292. X    if ( write ) {X
  2293. X        if ( zdest <= 9 ) mem[mar] = mbr;X
  2294. X        else mem[mar] = garbage;X
  2295. X    }X
  2296. X    if ( read ) {X
  2297. X        if ( zdest <= 9 ) mbr = mem[mar];X
  2298. X        else mbr = garbage;X
  2299. X    }X
  2300. XX
  2301. X    /* determine select bit from the current ALU flag settings */X
  2302. XX
  2303. X    switch ( test ) {X
  2304. X        case 0:    temp = cbit; break;X
  2305. X        case 1:    temp = vbit; break;X
  2306. X        case 2:    temp = zbit; break;X
  2307. X        case 3:    temp = nbit; break;X
  2308. X    }X
  2309. XX
  2310. X    /* Determine next value of MPC */X
  2311. XX
  2312. X    switch ( cond ) {X
  2313. X        case 0: mpc = mpc + 1; break;X
  2314. X        case 1: mpc = addrf; break;X
  2315. X        case 2: mpc = ( addrf & 0x3fe ) + temp; break;X
  2316. X        case 3: temp3 = ( ir & 0x03 );X
  2317. X            mpc = (addrf & 0x1fc ) + temp3; break;X
  2318. X        case 4: temp3 = ( ir & 0x0c ) >> 2;X
  2319. X            mpc = ( addrf & 0x1fc ) + temp3; break;X
  2320. X        case 5: temp3 = ( ir & 0x30 ) >> 4;X
  2321. X            mpc = ( addrf & 0x1fc ) + temp3; break;X
  2322. X        case 6: temp3 = ( ir & 0xc0 ) >> 6;X
  2323. X            mpc = ( addrf & 0x1fc ) + temp3; break;X
  2324. X        default: mpc = 9999; break;X
  2325. X    }X
  2326. X}X
  2327. XX
  2328. XENDX
  2329. X.YEX
  2330. X.vsX
  2331. X.psX
  2332. X.inX
  2333. X.PFX
  2334. X.PPX
  2335. X.SP "Microcode"X
  2336. XListed below is an example of microcode that implements the designedX
  2337. Xhardware.X
  2338. XThe actual microcode is not necessarily the fastest possible implementationX
  2339. Xbut it is straight forward and easy to understand.X
  2340. X.PPX
  2341. X.FPX
  2342. X.in +1iX
  2343. X.ps 8X
  2344. X.vs 10X
  2345. X.YSX
  2346. X; Data contained is in decimalX
  2347. X .decimalX
  2348. XX
  2349. X;X
  2350. X;WRITE -  Write MAR into memoryX
  2351. X;|  READ - Read MAR address into MBRX
  2352. X;|  |  ASOURCE - Source for ABUSX
  2353. X;|  |  |  CCCNTRL - CC controlX
  2354. X;|  |  |  |  SHFTCTRL - shift controlX
  2355. X;|  |  |  |  |   ALUCTRL - Function from ALUX
  2356. X;|  |  |  |  |   |  ZDEST - Destination on ZBUSX
  2357. X;|  |  |  |  |   |  |  LOADFLAGS - Load FLAGS from ALUX
  2358. X;|  |  |  |  |   |  |  |  LOADHOLD - Load HOLD from ABUSX
  2359. X;|  |  |  |  |   |  |  |  |  TEST - Select bit from ALU status bitsX
  2360. X;|  |  |  |  |   |  |  |  |  |  COND - Type of next addressX
  2361. X;|  |  |  |  |   |  |  |  |  |  |    ADDRF - Address for micro jumpX
  2362. X;|  |  |  |  |   |  |  |  |  |  |    |    Decimal AddressX
  2363. X;|  |  |  |  |   |  |  |  |  |  |    |    |   Hex AddressX
  2364. X;|  |  |  |  |   |  |  |  |  |  |    |    |   |    CommentX
  2365. X;|  |  |  |  |   |  |  |  |  |  |    |    |   |    | X
  2366. X;|  |  |  |  |   |  |  |  |  |  |    |    |   |    |X
  2367. X;|  |  |  |  |   |  |  |  |  |  |    |    |   |    |X
  2368. X;|  |  |  |  |   |  |  |  |  |  |    |    |   |    |X
  2369. X;|  |  |  |  |   |  |  |  |  |  |    |    |   |    |X
  2370. X;|  |  |  |  |   |  |  |  |  |  |    |    |   |    |X
  2371. X;|  |  |  |  |   |  |  |  |  |  |    |    |   |    |X
  2372. X;A  B  C  D  E   F  G  H  I  J  K    L    Dec Hex  RemX
  2373. X;******** Initialize PC to 0 ****************************************X
  2374. X 0  0  0  0  0  15  2  0  0  0  0    0  ; 0   00 ; PC    <- 0X
  2375. X 0  0  0  0  0  15  5  0  0  0  0    0  ; 1   01 ; FLAGS <- 0X
  2376. X 0  0  0  0  0  15  1  0  0  0  0    0  ; 2   02 ; AC    <- 0X
  2377. X 0  0  0  0  0  14  3  0  0  0  0    0  ; 3   03 ; SP    <- 0xFFX
  2378. X 0  0  0  0  0  15  6  0  0  0  0    0  ; 4   04 ; X     <- 0X
  2379. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 5   05 ; goto fetchX
  2380. XX
  2381. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 6   06 ; nopX
  2382. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 7   07 ; nopX
  2383. XX
  2384. X;******** Fetch Next Instruction ***********************************X
  2385. X 0  1  2  0  0   1 10  0  0  0  0    0  ; 8   08 ; MAR <- PC; READX
  2386. X 0  1  2  0  0   9  2  0  0  0  0    0  ; 9   09 ; PC <- PC + 1; READX
  2387. X 0  0  9  0  0   1  4  0  0  0  6   12  ; 10  0a ; IR <- MBR;X
  2388. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 11  0b ; nopX
  2389. X;                                                ; start instruction decodeX
  2390. X;                                                ; goto 12 + IR7 * 2 + IR6X
  2391. X 0  0  0  0  0   0  0  0  0  0  1  115  ; 12  0c ; IR76 00; goto 115X
  2392. X 0  0  0  0  0   0  0  0  0  0  1  115  ; 13  0d ; IR76 01; goto 115X
  2393. X 0  0  0  0  0   0  0  0  0  0  1   50  ; 14  0e ; IR76 10; goto 50X
  2394. X;X
  2395. X; OpCodes that have IR7=1 and IR6=1X
  2396. X 0  0  0  0  0   0  0  0  0  0  5   16  ; 15  0f ; test IR5, IR4X
  2397. X 0  0  0  0  0   0  0  0  0  0  1   20  ; 16  10 ; IR54 00; goto 20 X
  2398. X 0  0  0  0  0   0  0  0  0  0  1   32  ; 17  11 ; IR54 01; goto 32X
  2399. X 0  0  0  0  0   0  0  0  0  0  1   46  ; 18  12 ; IR54 10; goto 46X
  2400. X;X
  2401. X; HALT (1111 0000) - halt executionX
  2402. X 999 999 999 999 999 999 999 999 999 999 999 999 ; 19  13 ; DIE!!X
  2403. X;X
  2404. X; pop instructions  X
  2405. X 0  1  3  0  0   1 10  0  0  0  0    0  ; 20  14 ; MAR <- SP; READX
  2406. X 0  1  3  0  0   9  3  0  0  0  0    0  ; 21  15 ; SP <- SP + 1; READX
  2407. X 0  0  0  0  0   0  0  0  0  0  3   24  ; 22  16 ; test IR1, IR0X
  2408. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 23  17 ; nopX
  2409. X 0  0  0  0  0   0  0  0  0  0  1   28  ; 24  18 ; IR10 00; goto 28 X
  2410. X 0  0  0  0  0   0  0  0  0  0  1   29  ; 25  19 ; IR10 01; goto 29 X
  2411. X 0  0  0  0  0   0  0  0  0  0  1   30  ; 26  1a ; IR10 10; goto 30 X
  2412. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 27  1b ; IR10 11; goto 8; neverX
  2413. X;X
  2414. X; POP ACC (1100 0000) - pop accumulator off top of stackX
  2415. X 0  0  9  0  0   1  1  1  0  0  1  211  ; 28  1c ; ACC <- MBR; goto 211 X
  2416. X;X
  2417. X; POP X (1100 0001) - pop index register off top of stackX
  2418. X 0  0  9  0  0   1  6  0  0  0  1    8  ; 29  1d ; X <- MBR; goto 8 X
  2419. X;X
  2420. X; POP FLAGS (1100 0010) - pop flags off top of stackX
  2421. X 0  0  9  0  0   1  5  0  0  0  1    8  ; 30  1e ; FLAGS <- MBR; goto 8 X
  2422. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 31  1f ; nopX
  2423. X;X
  2424. X; push instructionsX
  2425. X 0  0  3  0  0   2  3  0  0  0  0    0  ; 32  20 ; not SP X
  2426. X 0  0  3  0  0   9  3  0  0  0  0    0  ; 33  21 ; SP <- SP + 1 X
  2427. X 0  0  3  0  0   2  3  0  0  0  0    0  ; 34  22 ; not SP X
  2428. X 0  0  3  0  0   1 10  0  0  0  3   36  ; 35  23 ; MAR <- SP; test IR0,IR1 X
  2429. X 0  0  0  0  0   0  0  0  0  0  1   40  ; 36  24 ; IR10 00; goto 40 X
  2430. X 0  0  0  0  0   0  0  0  0  0  1   42  ; 37  25 ; IR10 01; goto 42 X
  2431. X 0  0  0  0  0   0  0  0  0  0  1   44  ; 38  26 ; IR10 10; goto 44 X
  2432. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 39  27 ; IR10 11; goto 8; neverX
  2433. X;X
  2434. X; PUSH ACC (1101 0000) - push accumulator on stackX
  2435. X 1  0  1  0  0   1  9  0  0  0  0    0  ; 40  28 ; MBR <- ACC; WRITEX
  2436. X 1  0  0  0  0   0  0  0  0  0  1    8  ; 41  29 ; WRITE; goto 8X
  2437. X;X
  2438. X; PUSH X (1101 0001) - push index register on stackX
  2439. X 1  0  6  0  0   1  9  0  0  0  0    0  ; 42  2a ; MBR <- X; WRITEX
  2440. X 1  0  0  0  0   0  0  0  0  0  1    8  ; 43  2b ; WRITE; goto 8X
  2441. X;X
  2442. X; PUSH FLAGS (1101 0010) - push flags on stackX
  2443. X 1  0  5  0  0   1  9  0  0  0  0    0  ; 44  2c ; MBR <- FLAGS; WRITEX
  2444. X 1  0  0  0  0   0  0  0  0  0  1    8  ; 45  2d ; WRITE; goto 8X
  2445. X;X
  2446. X; RETN (1110 0000) - return from subroutineX
  2447. X 0  1  3  0  0   1 10  0  0  0  0    0  ; 46  2e ; MAR <- SP; READX
  2448. X 0  1  3  0  0   9  3  0  0  0  0    0  ; 47  2f ; SP <- SP + 1; READX
  2449. X 0  0  9  0  0   1  2  0  0  0  1    8  ; 48  30 ; PC <- MBR; goto 8 X
  2450. XX
  2451. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 49  31 ; nopX
  2452. X;X
  2453. X; OpCodes that have IR7=1 and IR6=0X
  2454. X 0  0  0  0  0   0  0  0  0  0  5   52  ; 50  32 ; test IR5, IR4X
  2455. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 51  33 ; nopX
  2456. X 0  0  0  0  0   0  0  0  0  0  1   59  ; 52  34 ; IR54 00; goto 59 X
  2457. X 0  0  0  0  0   0  0  0  0  0  1   71  ; 53  35 ; IR54 01; goto 71X
  2458. X 0  0  0  0  0   0  0  0  0  0  1   79  ; 54  36 ; IR54 10; goto 79X
  2459. X 0  0  0  0  0   0  0  0  0  0  1   87  ; 55  37 ; IR54 11; goto 87X
  2460. XX
  2461. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 56  38 ; nopX
  2462. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 57  39 ; nopX
  2463. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 58  3a ; nopX
  2464. X;X
  2465. X; increment/decrement registersX
  2466. X 0  0  0  0  0   0  0  0  0  0  3   60  ; 59  3b ; test IR0,IR1 X
  2467. X 0  0  0  0  0   0  0  0  0  0  1   70  ; 60  3c ; IR10 00; goto 70 X
  2468. X 0  0  0  0  0   0  0  0  0  0  1   69  ; 61  3d ; IR10 01; goto 69 X
  2469. X 0  0  0  0  0   0  0  0  0  0  1   66  ; 62  3e ; IR10 10; goto 66 X
  2470. X;X
  2471. X; DECX (1000 0011) - decrement index registerX
  2472. X 0  0  6  0  0   2  6  0  0  0  0    0  ; 63  3f ; not X X
  2473. X 0  0  6  0  0   9  6  0  0  0  0    0  ; 64  40 ; X <- X + 1X
  2474. X 0  0  6  0  0   2  6  0  0  0  1    8  ; 65  41 ; not X ; goto 8X
  2475. X;X
  2476. X; DECA (1000 0010) - decrement accumulatorX
  2477. X 0  0  1  0  0   2  1  0  0  0  0    0  ; 66  42 ; not ACC X
  2478. X 0  0  1  0  0   9  1  0  0  0  0    0  ; 67  43 ; ACC <- ACC + 1 X
  2479. X 0  0  1  0  0   2  1  1  0  0  1    8  ; 68  44 ; not ACC; goto 8X
  2480. X;X
  2481. X; INCX (1000 0001) - increment index registerX
  2482. X 0  0  6  0  0   9  6  0  0  0  1    8  ; 69  45 ; X <- X + 1; goto 8X
  2483. X;X
  2484. X; INCA (1000 0000) - increment accumulatorX
  2485. X 0  0  1  0  0   9  1  1  0  0  1    8  ; 70  46 ; ACC <- ACC + 1; goto 8X
  2486. X;X
  2487. X; clearing registersX
  2488. X 0  0  0  0  0   0  0  0  0  0  3   72  ; 71  47 ; test IR0,IR1 X
  2489. X 0  0  0  0  0   0  0  0  0  0  1   76  ; 72  48 ; IR10 00; goto 76X
  2490. X 0  0  0  0  0   0  0  0  0  0  1   78  ; 73  49 ; IR10 01; goto 78X
  2491. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 74  4a ; IR10 10; goto 8; never X
  2492. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 75  4b ; IR10 11; goto 8; never X
  2493. X;X
  2494. X; CLRA (1001 0000) - clear accumulatorX
  2495. X 0  0 10  0  0   1  5  0  0  0  0    4  ; 76  4c ; FLAGS <- 00000100X
  2496. X 0  0  1  0  0  15  1  0  0  0  1    8  ; 77  4d ; ACC <- 0; goto 8X
  2497. X;X
  2498. X; CLRX (1001 0000) - clear index registerX
  2499. X 0  0  6  0  0  15  6  0  0  0  1    8  ; 78  4e ; X <- 0; goto 8X
  2500. X;X
  2501. X; ones/twos complementX
  2502. X 0  0  0  0  0   0  0  0  0  0  3   80  ; 79  4f ; test IR0,IR1 X
  2503. X 0  0  0  0  0   0  0  0  0  0  1   84  ; 80  50 ; IR10 00; goto 84X
  2504. X 0  0  0  0  0   0  0  0  0  0  1   85  ; 81  51 ; IR10 01; goto 85X
  2505. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 82  52 ; IR10 10; goto 8; never X
  2506. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 83  53 ; IR10 11; goto 8; never X
  2507. X;X
  2508. X; NOT (1010 0000) - bitwise complement of accumulatorX
  2509. X 0  0  1  0  0   2  1  1  0  0  1  211  ; 84  54 ; not ACC; goto 211X
  2510. X;X
  2511. X; NEG (1010 0001) - 2's complement negation of the accumulatorX
  2512. X 0  0  1  0  0   2  1  0  0  0  0    0  ; 85  55 ; not ACCX
  2513. X 0  0  1  0  0   9  1  1  0  0  1  218  ; 86  56 ; ACC <- ACC + 1; goto 218X
  2514. X;X
  2515. X; shiftingX
  2516. X 0  0  0  0  0   0  0  0  0  0  4   88  ; 87  57 ; test IR3,IR2 X
  2517. X 0  0  0  0  0   0  0  0  0  0  1   95  ; 88  58 ; IR32 00; goto 95X
  2518. X 0  0  0  0  0   0  0  0  0  0  1  104  ; 89  59 ; IR32 01; goto 104X
  2519. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 90  5a ; IR32 10; goto 8; never X
  2520. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 91  5b ; IR32 11; goto 8; never X
  2521. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 92  5c ; nopX
  2522. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 93  5d ; nopX
  2523. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 94  5e ; nopX
  2524. X 0  0  0  0  0   0  0  0  0  0  3   96  ; 95  5f ; test IR0,IR1 X
  2525. X 0  0  0  0  0   0  0  0  0  0  1  100  ; 96  60 ; IR10 00; goto 100X
  2526. X 0  0  0  0  0   0  0  0  0  0  1  108  ; 97  61 ; IR10 01; goto 108X
  2527. X 0  0  0  0  0   0  0  0  0  0  1  102  ; 98  62 ; IR10 10; goto 102 X
  2528. X 0  0  0  0  0   0  0  0  0  0  1  111  ; 99  63 ; IR10 11; goto 111 X
  2529. X;X
  2530. X; SLL (1011 0000) - shift logical leftX
  2531. X 0  0  0  2  0   0  0  0  0  0  0    0  ; 100 64 ; clear shifterX
  2532. X 0  0  1  0  1   1  1  0  0  0  1  114  ; 101 65 ; lshift ACC; goto 114X
  2533. X;X
  2534. X; SRL (1011 0010) - shift logical rightX
  2535. X 0  0  0  2  0   0  0  0  0  0  0    0  ; 102 66 ; clear shifterX
  2536. X 0  0  1  0  2   1  1  0  0  0  1  114  ; 103 67 ; rshift ACC; goto 114X
  2537. X;X
  2538. X; SRA (1011 0100) - shift arithmetically rightX
  2539. X 0  0 10  0  0   0  0  0  1  0  0  128  ; 104 68 ; hold <- mask(10000000)X
  2540. X 0  0  1  0  1   4  0  0  0  0  0    0  ; 105 69 ; CC <- lshift(0x80&ACC)X
  2541. X 0  0  1  0  2   1  1  0  0  0  1  114  ; 106 6a ; rshift ACC; goto 114X
  2542. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 107 6b ; nopX
  2543. X;X
  2544. X; SLC (1011 0001) - shift circular leftX
  2545. X 0  0 10  0  0   0  0  0  1  0  0  128  ; 108 6c ; hold <- mask(10000000)X
  2546. X 0  0  1  0  1   4  0  0  0  0  0    0  ; 109 6d ; CC <- lshift(0x80&ACC)X
  2547. X 0  0  1  0  1   1  1  0  0  0  1  114  ; 110 6e ; lshift ACC; goto 114X
  2548. X;X
  2549. X; SRC (1011 0011) - shift circular rightX
  2550. X 0  0 10  0  0   0  0  0  1  0  0    1  ; 111 6f ; hold <- mask(00000001)X
  2551. X 0  0  1  0  2   4  0  0  0  0  0    0  ; 112 70 ; CC <- rshift(0x01&ACC)X
  2552. X 0  0  1  0  2   1  1  0  0  0  0    0  ; 113 71 ; rshift ACCX
  2553. X;X
  2554. X; send ACC thru ALU to get proper flags because shifter is after ALUX
  2555. X 0  0  1  0  0   1  0  1  0  0  1  213  ; 114 72 ; ACC ; goto 213 X
  2556. X;X
  2557. X; OpCodes that have IR7=0X
  2558. X 0  0  0  0  0   0  0  0  0  0  3  116  ; 115 73 ; test IR0,IR1 X
  2559. X 0  0  0  0  0   0  0  0  0  0  1  120  ; 116 74 ; IR10 00; goto 120X
  2560. X 0  0  0  0  0   0  0  0  0  0  1  126  ; 117 75 ; IR10 01; goto 126X
  2561. X 0  0  0  0  0   0  0  0  0  0  1  133  ; 118 76 ; IR10 10; goto 133 X
  2562. X;X
  2563. X; Mode is Stack (11) - addr <- (SP) + operandX
  2564. X 0  0  3  0  0   0  0  0  1  0  1  134  ; 119 77 ; hold <- SP; goto 134X
  2565. X;X
  2566. X; Mode is Direct (00) - addr <- operandX
  2567. X 0  1  2  0  0   1 10  0  0  0  0    0  ; 120 78 ; MAR <- PC; READX
  2568. X 0  1  2  0  0   9  2  0  0  0  0    0  ; 121 79 ; PC <- PC + 1; READX
  2569. X 0  0  9  0  0   1  7  0  0  0  0    0  ; 122 7a ; B <- MBRX
  2570. X 0  1  7  0  0   1 10  0  0  0  0    0  ; 123 7b ; MAR <- B; READX
  2571. X 0  1  0  0  0   0  0  0  0  0  0    0  ; 124 7c ; READX
  2572. X 0  0  0  0  0   0  0  0  0  0  1  139  ; 125 7d ; goto 139X
  2573. X;X
  2574. X; Mode is Indirect (01) - addr <- Memory[operand]X
  2575. X 0  1  2  0  0   1 10  0  0  0  0    0  ; 126 7e ; MAR <- PC; READX
  2576. X 0  1  2  0  0   9  2  0  0  0  0    0  ; 127 7f ; PC <- PC + 1; READX
  2577. X 0  1  9  0  0   1 10  0  0  0  0    0  ; 128 80 ; MAR <- MBR; READX
  2578. X 0  1  0  0  0   0  0  0  0  0  0    0  ; 129 81 ; READX
  2579. X 0  0  9  0  0   1  7  0  0  0  0    0  ; 130 82 ; B <- MBRX
  2580. X 0  1  7  0  0   1 10  0  0  0  0    0  ; 131 83 ; MAR <- B; READX
  2581. X 0  1  0  0  0   0  0  0  0  0  1  139  ; 132 84 ; READ; goto 139X
  2582. X;X
  2583. X; Mode is Indexed (10) - addr <- (X) + operandX
  2584. X 0  0  6  0  0   0  0  0  1  0  0    0  ; 133 85 ; hold <- XX
  2585. X 0  1  2  0  0   1 10  0  0  0  0    0  ; 134 86 ; MAR <- PC; READX
  2586. X 0  1  2  0  0   9  2  0  0  0  0    0  ; 135 87 ; PC <- PC + 1; READX
  2587. X 0  0  9  0  0   7  7  0  0  0  0    0  ; 136 88 ; B <- MBR + holdX
  2588. X 0  1  7  0  0   1 10  0  0  0  0    0  ; 137 89 ; MAR <- B; READX
  2589. X 0  1  0  0  0   0  0  0  0  0  0    0  ; 138 8a ; READX
  2590. X;X
  2591. X; Mode is loaded into register B, keep on decoding instructionX
  2592. X 0  0  0  0  0   0  0  0  0  0  6  140  ; 139 8b ; test IR7, IR6X
  2593. X 0  0  0  0  0   0  0  0  0  0  1  170  ; 140 8c ; IR76 00; goto 170X
  2594. X;X
  2595. X; pc changersX
  2596. X 0  0  5  0  0   0  0  0  1  0  0    0  ; 141 8d ; hold <- FLAGSX
  2597. X 0  0 10  0  0   4  8  0  0  0  0    4  ; 142 8e ; C <- hold & 00000100X
  2598. X 0  0  0  0  0   0  0  0  0  0  5  144  ; 143 8f ; test IR5, IR4X
  2599. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 144 90 ; goto 8; neverX
  2600. X 0  0  0  0  0   0  0  0  0  0  1  162  ; 145 91 ; goto 162X
  2601. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 146 92 ; goto 8; neverX
  2602. X;X
  2603. X; branchingX
  2604. X 0  0  0  0  0   0  0  0  0  0  4  148  ; 147 93 ; test IR3, IR2X
  2605. X;X
  2606. X; BR (0111 00aa) - branch alwaysX
  2607. X 0  0  7  0  0   1  2  0  0  0  1    8  ; 148 94 ; PC <- B; goto 8 X
  2608. X;X
  2609. X 0  0  0  0  0   0  0  0  0  0  1  154  ; 149 95 ; IR32 01; goto 154X
  2610. X 0  0  0  0  0   0  0  0  0  0  1  158  ; 150 96 ; IR32 10; goto 158X
  2611. X;X
  2612. X; BNEQ (0111 11aa) - branch if not zero (Z bit = 0)X
  2613. X 0  0  8  0  0   1  0  0  0  2  2  152  ; 151 97 ; C; test ZBIT (inverse)X
  2614. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 152 98 ; 1; goto 8X
  2615. X 0  0  7  0  0   1  2  0  0  0  1    8  ; 153 99 ; 0; PC <- B; goto 8 X
  2616. X;X
  2617. X; BEQ (0111 01aa) - branch if zero (Z bit = 1)X
  2618. X 0  0  8  0  0   1  0  0  0  2  2  156  ; 154 9a ; C; test ZBIT (inverse)X
  2619. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 155 9b ; nopX
  2620. X 0  0  7  0  0   1  2  0  0  0  1    8  ; 156 9c ; 1; PC <- B; goto 8 X
  2621. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 157 9d ; 0; goto 8X
  2622. X;X
  2623. X; BLSS (0111 10aa) - branch if negative (N bit = 1) X
  2624. X 0  0 10  0  0   4  8  0  0  0  0    8  ; 158 9e ; C <- hold & 00001000X
  2625. X 0  0  8  0  0   1  0  0  0  2  2  160  ; 159 9f ; C ; test ZBITX
  2626. X 0  0  7  0  0   1  2  0  0  0  1    8  ; 160 a0 ; N 1; PC <- B; goto 8 X
  2627. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 161 a1 ; N 0; goto 8X
  2628. X;X
  2629. X; CALL (0101 00aa) - jump to subroutineX
  2630. X 0  0  3  0  0   2  3  0  0  0  0    0  ; 162 a2 ; not SPX
  2631. X 0  0  3  0  0   9  3  0  0  0  0    0  ; 163 a3 ; SP <- SP + 1X
  2632. X 0  0  3  0  0   2  3  0  0  0  0    0  ; 164 a4 ; not SPX
  2633. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 165 a5 ; nopX
  2634. X 0  0  3  0  0   1 10  0  0  0  0    0  ; 166 a6 ; MAR <- SPX
  2635. X 1  0  2  0  0   1  9  0  0  0  0    0  ; 167 a7 ; MBR <- PC; WRITEX
  2636. X 1  0  7  0  0   1  2  0  0  0  0    0  ; 168 a8 ; PC <- B; WRITEX
  2637. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 169 a9 ; goto 8X
  2638. X;X
  2639. X; OpCodes that have IR7=0 and IR6=0X
  2640. X 0  0  0  0  0   0  0  0  0  0  5  172  ; 170 aa ; test IR5, IR4X
  2641. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 171 ab ; nopX
  2642. X 0  0  0  0  0   0  0  0  0  0  1  185  ; 172 ac ; IR54 00; goto 185X
  2643. X 0  0  0  0  0   0  0  0  0  0  1  195  ; 173 ad ; IR54 01; goto 195X
  2644. X 0  0  0  0  0   0  0  0  0  0  1  207  ; 174 ae ; IR54 10; goto 207X
  2645. X;X
  2646. X; storingX
  2647. X 0  0  0  0  0   0  0  0  0  0  4  176  ; 175 af ; test IR3, IR2X
  2648. X 0  0  0  0  0   0  0  0  0  0  1  181  ; 176 b0 ; IR32 00; goto 181X
  2649. X;X
  2650. X; STX (0011 01aa) - store index registerX
  2651. X 0  0  7  0  0   1 10  0  0  0  0    0  ; 177 b1 ; MAR <- BX
  2652. X 1  0  6  0  0   1  9  0  0  0  0    0  ; 178 b2 ; MBR <- X; WRITEX
  2653. X 1  0  0  0  0   0  0  0  0  0  0    0  ; 179 b3 ; WRITEX
  2654. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 180 b4 ; goto 8X
  2655. X;X
  2656. X; STA (0011 00aa) - store accumulatorX
  2657. X 0  0  7  0  0   1 10  0  0  0  0    0  ; 181 b5 ; MAR <- BX
  2658. X 1  0  1  0  0   1  9  0  0  0  0    0  ; 182 b6 ; MBR <- ACC; WRITEX
  2659. X 1  0  0  0  0   0  0  0  0  0  0    0  ; 183 b7 ; WRITEX
  2660. X 0  0  0  0  0   0  0  0  0  0  1    8  ; 184 b8 ; goto 8X
  2661. X;X
  2662. X; math (add/subtract)X
  2663. X 0  0  0  0  0   0  0  0  0  0  4  188  ; 185 b9 ; test IR3, IR2X
  2664. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 186 ba ; nopX
  2665. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 187 bb ; nopX
  2666. X 0  0  0  0  0   0  0  0  0  0  1  193  ; 188 bc ; IR32 00; goto 193X
  2667. X;X
  2668. X; SUB (0000 01aa) - subtract from accumulatorX
  2669. X 0  0  9  0  0   1  0  0  1  0  0    0  ; 189 bd ; hold <- MBRX
  2670. X 0  0  1  0  0   2  1  0  0  0  0    0  ; 190 be ; not ACCX
  2671. X 0  0  1  0  0   7  1  0  0  0  0    0  ; 191 bf ; ACC <- ACC + holdX
  2672. X 0  0  1  0  0   2  1  1  0  0  1    8  ; 192 c0 ; not ACC; goto 8X
  2673. X;X
  2674. X; ADD (0000 00aa) - add to accumulatorX
  2675. X 0  0  9  0  0   1  0  0  1  0  0    0  ; 193 c1 ; hold <- MBRX
  2676. X 0  0  1  0  0   7  1  1  0  0  1    8  ; 194 c2 ; ACC <- ACC+hold; goto 8X
  2677. X; X
  2678. X; logicX
  2679. X 0  0  0  0  0   0  0  0  0  0  4  196  ; 195 c3 ; test IR3, IR2X
  2680. X 0  0  0  0  0   0  0  0  0  0  1  202  ; 196 c4 ; IR32 00; goto 202X
  2681. X 0  0  0  0  0   0  0  0  0  0  1  200  ; 197 c5 ; IR32 01; goto 200X
  2682. X;X
  2683. X; AND (0001 10aa) - logical AND to accumulatorX
  2684. X 0  0  9  0  0   1  0  0  1  0  0    0  ; 198 c6 ; hold <- MBRX
  2685. X 0  0  1  0  0   4  1  1  0  0  1  211  ; 199 c7 ; ACC <- ACC&hold; goto211X
  2686. X;X
  2687. X; XOR (0001 01aa) - logical XOR to accumulatorX
  2688. X 0  0  9  0  0   1  0  0  1  0  0    0  ; 200 c8 ; hold <- MBRX
  2689. X 0  0  1  0  0   6  1  1  0  0  1  211  ; 201 c9 ; ACC <- ACC^hold; goto211X
  2690. X;X
  2691. X; OR (0001 00aa) - logical OR to accumulatorX
  2692. X 0  0  9  0  0   1  0  0  1  0  0    0  ; 202 ca ; hold <- MBRX
  2693. X 0  0  1  0  0   5  1  1  0  0  1  211  ; 203 cb ; ACC <- ACC|hold; goto211X
  2694. XX
  2695. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 204 cc ; nopX
  2696. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 205 cd ; nopX
  2697. X 0  0  0  0  0   0  0  0  0  0  0    0  ; 206 ce ; nopX
  2698. X;X
  2699. X; loadingX
  2700. X 0  0  0  0  0   0  0  0  0  0  4  208  ; 207 cf ; test IR3, IR2X
  2701. X;X
  2702. X; LDA (0010 00aa) - load accumulatorX
  2703. X 0  0  9  0  0   1  1  1  0  0  1  211  ; 208 d0 ; ACC <- MBR; goto 211 X
  2704. X;X
  2705. X; LDX (0010 01aa) - load index registerX
  2706. X 0  0  9  0  0   1  6  0  0  0  1    8  ; 209 d1 ; X <- MBR; goto 8X
  2707. X;X
  2708. X; LDS (0010 10aa) - load stack registerX
  2709. X 0  0  9  0  0   1  3  0  0  0  1    8  ; 210 d2 ; SP <- MBR; goto 8X
  2710. X;X
  2711. X; set bits 'VC' to zero in flags registerX
  2712. X 0  0 10  0  0   0  0  0  1  0  0  252  ; 211 d3 ; hold <- 11111100X
  2713. X 0  0  5  0  0   4  5  0  0  0  1    8  ; 212 d4 ; FLAGS<-hold&FLGS; goto 8X
  2714. X;X
  2715. X; set bit 'V' to zero in flags registerX
  2716. X 0  0  0  0  1  15  7  0  0  0  0    0  ; 213 d5 ; B <- CCX
  2717. X 0  0  7  0  0   0  0  0  1  0  0    0  ; 214 d6 ; hold <- BX
  2718. X 0  0  5  0  0   5  5  0  0  0  0    0  ; 215 d7 ; FLAGS <- hold | FLAGSX
  2719. X 0  0 10  0  0   0  0  0  1  0  0  253  ; 216 d8 ; hold <- 11111101X
  2720. X 0  0  5  0  0   4  5  0  0  0  1    8  ; 217 d9 ; FLAGS<-hold&FLGS; goto 8X
  2721. X;X
  2722. X; set bit 'C' to zero in flags registerX
  2723. X 0  0 10  0  0   0  0  0  1  0  0  254  ; 218 da ; hold <- 11111110X
  2724. X 0  0  5  0  0   4  5  0  0  0  1    8  ; 219 db ; FLAGS<-hold&FLGS; goto 8X
  2725. XX
  2726. X; That's All Folks!X
  2727. X.YEX
  2728. X.vsX
  2729. X.psX
  2730. X.inX
  2731. X.PFX
  2732. X.PE "Technical Guide"X
  2733. X.bpX
  2734. X.ST "5. Technical Guide"X
  2735. XThis final chapter is used for the understanding of the actualX
  2736. Xsource code. X
  2737. XA lot of times it is nice to be able to look at the source codeX
  2738. Xquickly and gather the needed information.X
  2739. XThere are projects that are available that are difficult to understandX
  2740. Xwithout going into an in depth search.X
  2741. XThis chapter will try to overcome that.X
  2742. X.PPX
  2743. X.SP "Source Modules"X
  2744. XHere is a list of the source modules that is currently beingX
  2745. Xdistributed and the purpose of each.X
  2746. X.PPX
  2747. X.TSX
  2748. Xcenter box tab (/);X
  2749. Xc c, l l.X
  2750. XModule/PurposeX
  2751. X_X
  2752. Xbrkpts.c/Breakpoint codeX
  2753. Xcorrect.c/Correction File codeX
  2754. Xdebug.c/Debugging CodeX
  2755. Xmain.c/Main interpreter codeX
  2756. Xmemory.c/CPU and main memory codeX
  2757. Xmisc.c/Common functionsX
  2758. Xstack.c/Stack functionsX
  2759. Xy_misc.c/Misc functions for compilerX
  2760. Xyampc.c/Initial spawn of HDL compileX
  2761. Xdebug.h/Debugger function definitionsX
  2762. Xmain.h/Main header file for interpreterX
  2763. Xmisc.h/Common header fileX
  2764. Xyampc.h/Main header file for compilerX
  2765. Xlex.l/lexical analyzerX
  2766. Xlalr.y/YACC file used in parsing HDLX
  2767. XMakefile/object creationX
  2768. Xhfile/Example of HDL programX
  2769. Xcmemory/Example of microcode programX
  2770. Xmemory/Example of assembly language programX
  2771. Xyampc.1/Man page for YAMPCX
  2772. Xyampc.doc/DocumentationX
  2773. Xtmac.ine/Troff macro package for docsX
  2774. Xlicense.gnu/Version 2 of GNU Public LicenseX
  2775. X.TEX
  2776. X.PPX
  2777. X.SP "Compiler"X
  2778. XThe \*Y compiler uses YACC and Lex explicitly to do all of theX
  2779. Xwork.X
  2780. XThere isn't anything that is actually time dependent and X
  2781. Xmaintaining Lex and YACC is much easier.X
  2782. XThis also makes it much easier to add because Lex and YACCX
  2783. Xare known well enough and it would be easier than examiningX
  2784. XC source code.X
  2785. X.PPX
  2786. X.SP "Lex & YACC"X
  2787. XWhen working with Lex and YACC, it was made sure that thereX
  2788. Xwas nothing used that couldn't be used by different versionsX
  2789. Xother than the standard AT&T.X
  2790. XThis was particularly done so this project could be compiledX
  2791. Xusing Flex and Bison.X
  2792. XFlex and Bison are distributed by the Free Software Foundation.X
  2793. X.PPX
  2794. X.SP "Library"X
  2795. XThe library contains all of the code for the operation of theX
  2796. Xprocessor.X
  2797. XCertain machines when creating the library don't actuallyX
  2798. Xplace a table of contents into it.X
  2799. XThis may need to be done using the 'ranlib' or the 'ar -ts'X
  2800. Xcommands.X
  2801. X.PPX
  2802. X.SP "Stack"X
  2803. XAll expression math done in the HDL is using stack commands.X
  2804. XThe expression is broken up and placed onto the stack inX
  2805. XReverse Polish Notation (RPN).X
  2806. XThe reasoning is that it was a easy way to maintain completeX
  2807. Xcontrol over all math operations.X
  2808. XOtherwise it would be machine dependent and that would beX
  2809. Xpointless.X
  2810. X.PPX
  2811. XAnother consideration is that is was desired the ability toX
  2812. Xsupport many different word sized machines.X
  2813. XIf the processor intends on creating a 10 bit word machine,X
  2814. X\*Y is able to support it completely.X
  2815. X\*Y takes in account that the machine is 10 bit and all X
  2816. Xmath operations are done in 10 bit math.X
  2817. X.PPX
  2818. XAll math operations are in control.X
  2819. XIf a math operation is being done on a 5 bit word and a 6 bitX
  2820. Xword and placed into a 7 bit word.X
  2821. XThe operation on the 5 bit and 6 bit will be done in 6 bit andX
  2822. Xmoved into the 7 bit word.X
  2823. X.PPX
  2824. X.SP "Interrupts"X
  2825. XInterrupts will probably be the least used function of theX
  2826. Xproduct.X
  2827. XIt was placed in as an after though because it was interestingX
  2828. Xfor myself during development time.X
  2829. XIn a normal class scenario, there would be no needX
  2830. Xfor the interrupt support.X
  2831. XA student wouldn't really get that much more out of the X
  2832. Xclass project if interrupts were used.X
  2833. X.PPX
  2834. XInterrupts can occur every X period of time which can be setX
  2835. Xup by the HDL programmer or at run time.X
  2836. XWhen it is time for the interrupt to occur, the microengineX
  2837. Xis called with the subcycle set to the maximum plus one.X
  2838. XThe microengine code can then determine that the inputX
  2839. Xis an interrupt and continue processing on that.X
  2840. XThe keyword 'Ireturn' is available for the programmer to returnX
  2841. Xfrom the microengine.X
  2842. XThis can be useful if the interrupt code is in the beginning ofX
  2843. Xthe engine and there is other code that shouldn't be executed.X
  2844. X.PPX
  2845. X.SP "Adding Commands"X
  2846. XAdding commands is pretty simple.X
  2847. XThere is a file called 'debug.h' which lists all of theX
  2848. Xcurrent commands available while in the interactive debugger.X
  2849. XIn that file, a structure is declared.X
  2850. X.PPX
  2851. X.ps 8X
  2852. X.in +.5iX
  2853. X.YSX
  2854. X/* structure containing the debug routines */X
  2855. Xstruct debug_cmds {X
  2856. X   char *word;       /* the word spelling */X
  2857. X   int matchnum;     /* number of characters neededX
  2858. X                      * to match */X
  2859. X   char *usage;      /* usage message if used improperly */X
  2860. X   char *help;       /* help message */X
  2861. X   int (*func) ( );  /* function pointer */X
  2862. XX
  2863. X};X
  2864. X.YEX
  2865. X.inX
  2866. X.psX
  2867. X.PPX
  2868. XEach function that is to be added needs to be placed into thisX
  2869. Xstructure.X
  2870. XWhen creating the function, take in account that it is expectedX
  2871. Xto do certain things.X
  2872. XThe single argument to the function is the command entry value.X
  2873. XThis is useful for when the command is misused.X
  2874. XAlso, there is a finite number of possible returns that should beX
  2875. Xused.X
  2876. XListed below are the possible return values.X
  2877. X.PPX
  2878. X.TSX
  2879. Xcenter tab(/);X
  2880. Xlw(1i) l, l l.X
  2881. XReturn/MeaningX
  2882. X_X
  2883. XP_CONT/Continue processing debugger commandsX
  2884. XP_GOON/Start executing code until some event occursX
  2885. XP_LEAVE/Leave the interactive debuggerX
  2886. X.TEX
  2887. X.PPX
  2888. X.SP "System Limitations"X
  2889. XOne of the limitations is that the desired architecture can not X
  2890. Xbe larger than 32 bits. X
  2891. XThis is cause all references to all variables is done longs.X
  2892. XWhen compiling a HDL program, \*Y will notify the user if inX
  2893. Xsuch an event does occur.X
  2894. X.PE "Appendix"X
  2895. X.bpX
  2896. X.ST "A. Reserved Words"X
  2897. XHere is a list of all of the reserved words used by the HardwareX
  2898. XDescription Language.X
  2899. X.PPX
  2900. X.PPX
  2901. X.TSX
  2902. Xcenter;X
  2903. Xl.X
  2904. XBEGINX
  2905. XENDX
  2906. XFORMATX
  2907. XINITX
  2908. XINTERRUPTX
  2909. XMEMORYX
  2910. XMICROENGINEX
  2911. XPARTSX
  2912. XSUBCYCLEX
  2913. XVARSX
  2914. XbreakX
  2915. XcaseX
  2916. XcpuX
  2917. XdefaultX
  2918. XelseX
  2919. XIreturnX
  2920. XifX
  2921. XinterruptX
  2922. XmemX
  2923. XsubcycleX
  2924. XswitchX
  2925. X.TEX
  2926. X.bpX
  2927. X.ST "B. Debugger Command Summary"X
  2928. XThis section contains a synopsis of the commands available in the X
  2929. Xdebugger option of \*Y.X
  2930. X.PPX
  2931. X.SP "Breakpoint"X
  2932. XBreakpoints allow the user to stop at a microcode instructionX
  2933. Xand return to the debugger.X
  2934. XThis allows the user to examine the operation of the microcode toX
  2935. Xsee if it is performing properly.X
  2936. XBreakpoints are set to a particular microcode address and theX
  2937. Xdebugger will notify the user when the breakpoint has been reached.X
  2938. XThere can be up to 10 breakpoints set.X
  2939. X.PPX
  2940. X.TSX
  2941. Xcenter tab (/);X
  2942. Xlw(2i) lw(2i), l l.X
  2943. X\fISyntax/Examples\fPX
  2944. Xbreakpoint [mpc]/breakpoint 8X
  2945. Xb [mpc]/b 250X
  2946. X.TEX
  2947. X.PPX
  2948. X.PPX
  2949. X.SP "Calculator"X
  2950. XThe calculator command allows the user to do simple arithmeticX
  2951. Xoperations in Reverse Polish Notation (RPN).X
  2952. XRegisters and hexidecimal numbers can be used in the expression.X
  2953. X.PPX
  2954. X.TSX
  2955. Xcenter tab (/);X
  2956. Xlw(2i) lw(2i), l l.X
  2957. X\fISyntax/Examples\fPX
  2958. Xcalculator [expression]/calculator 7 6 +X
  2959. X/c 9 6 4 * /X
  2960. X/c 9 pc + mpc =X
  2961. X/ (note: this actually changes mpc)X
  2962. X.TEX
  2963. X.PPX
  2964. X.PPX
  2965. X.SP "Delete"X
  2966. XThe delete command allows the user to remove a breakpoint fromX
  2967. Xthe list.X
  2968. XThe only argument is the mpc address of the breakpoint set.X
  2969. X.PPX
  2970. X.TSX
  2971. Xcenter tab (/);X
  2972. Xlw(2i) lw(2i), l l.X
  2973. X\fISyntax/Examples\fPX
  2974. Xdelete [mpc]/delete 8X
  2975. Xde [mpc]/de 8X
  2976. X.TEX
  2977. X.PPX
  2978. X.PPX
  2979. X.SP "Display"X
  2980. XDisplay shows the contents of the registers, cpu or main memory.X
  2981. XTo display the registers, "display regs" would suffice.X
  2982. XWhen displaying memory of some sort, it is necessary to specifyX
  2983. Xa range of locations.X
  2984. XThis range can be a single or multiple locations.X
  2985. X.PPX
  2986. X.TSX
  2987. Xcenter tab (/);X
  2988. Xlw(2i) lw(2i), l l.X
  2989. X\fISyntax/Examples\fPX
  2990. Xdisplay regs/display regsX
  2991. X/d regsX
  2992. Xdisplay mem [integer]/display mem 65X
  2993. Xdisplay mem [integer] - [integer]/display mem 65 - 80X
  2994. Xdisplay cpu [integer]/display cpu 65X
  2995. Xdisplay cpu [integer] - [integer]/display cpu 65 - 80X
  2996. X.TEX
  2997. X.bpX
  2998. X.SP "Exit, Quit"X
  2999. XThese sinonmous commands give the ability to the user to leaveX
  3000. Xthe program.X
  3001. X.PPX
  3002. X.TSX
  3003. Xcenter tab (/);X
  3004. Xlw(2i) lw(2i), l l.X
  3005. X\fISyntax/Examples\fPX
  3006. Xexit/exitX
  3007. X/eX
  3008. Xquit/quitX
  3009. X/qX
  3010. X.TEX
  3011. X.PPX
  3012. X.PPX
  3013. X.SP "Help"X
  3014. XThe debugger command set is quickly available on line by usingX
  3015. Xthe help command.X
  3016. XHelp will give a quick reference to all of the commands that theX
  3017. Xuser can use with their appropriate syntax.X
  3018. X.PPX
  3019. X.PPX
  3020. X.SP "Interrupts"X
  3021. XThe interrupt command allows the user to list, set or X
  3022. Xunset interrupts.X
  3023. XThe interrupt command can take up to two arguments.X
  3024. XIf there are no arguments, all interrupts vectors are displayed.X
  3025. XWith one argument, the interrupt vector is removed from the  list.X
  3026. XIf there are two arguments, the interrupt becomes active every X
  3027. XX number of cycles where X is the second argument.X
  3028. X.PPX
  3029. X.TSX
  3030. Xcenter tab (/);X
  3031. Xlw(2i) lw(2i), l l.X
  3032. X\fISyntax/Examples\fPX
  3033. Xinterrupt/iX
  3034. Xinterrupt <#>/i 6X
  3035. Xinterrupt <#> <#>/i 6 50X
  3036. X.TEX
  3037. X.PPX
  3038. X.SP "List"X
  3039. XList all breakpoints set.X
  3040. XThis command doesn't take any arguments.X
  3041. X.PPX
  3042. X.TSX
  3043. Xcenter tab (/);X
  3044. Xlw(2i) lw(2i), l l.X
  3045. X\fISyntax/Examples\fPX
  3046. Xlist/listX
  3047. X/lX
  3048. X.TEX
  3049. X.PPX
  3050. X.SP "Reset"X
  3051. XReset sets all the elements of the processor to their originalX
  3052. Xvalues, ie. the values at the start of the simulation.X
  3053. X.PPX
  3054. X.TSX
  3055. Xcenter tab (/);X
  3056. Xlw(2i) lw(2i), l l.X
  3057. X\fISyntax/Examples\fPX
  3058. Xreset/resetX
  3059. X/reX
  3060. X.TEX
  3061. X.PPX
  3062. X.SP "Run"X
  3063. XRun causes the debugger to initiate a simulation of the processor.X
  3064. XRun with no arguments runs the processor until the processor isX
  3065. Xhalted by breakpoint or finishing.X
  3066. XIf there is an argument, the processor will execute that number ofX
  3067. Xcycles before returning to the debugging prompt.X
  3068. X.PPX
  3069. X.TSX
  3070. Xcenter tab (/);X
  3071. Xlw(2i) lw(2i), l l.X
  3072. X\fISyntax/Examples\fPX
  3073. Xrun/runX
  3074. X/rX
  3075. Xrun <#>/run 10X
  3076. X.TEX
  3077. X.PPX
  3078. X.SP "Set"X
  3079. XA valid part of the architecture is set to some value, number.X
  3080. XThe number is in hexidecimal notation.X
  3081. XThe set command is possible of setting either a register orX
  3082. Xthe main memory.X
  3083. X.PPX
  3084. X.TSX
  3085. Xcenter tab (/);X
  3086. Xlw(2i) lw(2i), l l.X
  3087. X\fISyntax/Examples\fPX
  3088. Xset [regs|mem] [#] <#>/set regs mpc 20X
  3089. X/set mem 16 40X
  3090. X.TEX
  3091. X.PPX
  3092. X.SP "Trace"X
  3093. XTrace sets the output of the simulated running of the processorX
  3094. Xaccording to:X
  3095. X.in +1iX
  3096. X.PPX
  3097. Xtrace off - no outputX
  3098. X.PPX
  3099. Xtrace on - output consists of a heading containing the control fieldX
  3100. Xname and values for the current contents of the microinstructionX
  3101. Xregister; each part of the architecture is listed with its X
  3102. Xcontents in hexidecimal.X
  3103. X.PPX
  3104. Xtrace header - output is identical to the trace on except the contentsX
  3105. Xof the architecture parts are not displayed.X
  3106. X.inX
  3107. X.PPX
  3108. X.SP "Version"X
  3109. XThe version command displays to the user the current version of the X
  3110. X\*Y software package.X
  3111. X.bpX
  3112. X.ST "C. Miscellaneous Notes"X
  3113. XThis project is currently being used in the undergraduate courseX
  3114. Xat Rochester Institute of Technology.X
  3115. X.PPX
  3116. X.PPX
  3117. X.SP "Future Developments"X
  3118. XThere are some changes that can be made that might make this projectX
  3119. Xwork better.X
  3120. X.PPX
  3121. XIt may be nice to have window support (X ?) for this so the dubuggerX
  3122. Xcould be icon driven.X
  3123. XAlso, a map showing the execution path visually would be really nice.X
  3124. X.PPX
  3125. XThere is internal support for subcycles but there currently isn't theX
  3126. Xability to debug by subcycle.X
  3127. XIn the future, this could be a nice addition.X
  3128. X.PPX
  3129. XThe correction file is sufficient but instead of correcting by X
  3130. Xfetch cycle, correct via the memory address.X
  3131. XThis would allow more freedom with the microcode.X
  3132. X.PPX
  3133. X.PPX
  3134. X.SP "Hacker Ethics"X
  3135. X"Hackers", by Steven Levy.X
  3136. X.PPX
  3137. XAccess to computers - and anything which might teach you somethingX
  3138. Xabout the way the world workds - should be unlimited and total.X
  3139. XAlways yield to the Hands On Imperative!X
  3140. X.PPX
  3141. XAll Information should be free.X
  3142. X.PPX
  3143. XMistrust Authority - Promote Decentralization.X
  3144. X.PPX
  3145. XHacker's should be judged by their hacking, not bogusX
  3146. Xcriteria such as degrees, age, race or position.X
  3147. X.PPX
  3148. XYou can create art and beauty on a computer.X
  3149. X.PPX
  3150. X.PPX
  3151. X.SP "YAMPC"X
  3152. XAs a side note, \*Y stands for:X
  3153. X.PPX
  3154. X.in +1iX
  3155. XYet Another Micro Program CompilerX
  3156. X.inX
  3157. Zaphod for prez
  3158. exit 0
  3159.