home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / intercal.zip / doc / chip.spec next >
Text File  |  1996-06-12  |  14KB  |  608 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.           The Intercal Machine Machine Language Specification File
  28.                        (c) 1990 Christian Brunschen,
  29.                          a. k. a. d89cb@efd.lth.se
  30.  
  31. This file contains the specifications for the Machine / Assembly Language
  32. used by the Intercal Machine Microprocesor, which closely follows the
  33. definition of the Intercal Compiler Language as defined by Woods/Lyon
  34. in 1972. It also contains ideas as to the actual implementation,
  35. hard- or softwarewise, of the Processor Instruction Set in an actual
  36. environment.
  37.  
  38. It should be noted that the Intercal Machine Microprocessor is the first
  39. actual RISC processor (RISC being, of course, the acronym for
  40. Ridiculous Instruction Set Computer).
  41.  
  42. Overview of processor capabilities / requirements
  43.  
  44. Schematic overview of processor I/O busses:
  45.  
  46.                      +----------------\   /--------------+
  47.                 _|               \_/                  |_
  48.     D     +--- |_| D0                          A04 |_| ---+
  49.         a     |     _|                                 |_    |
  50.     t     |    |_| D1                          A05 |_|    |
  51.     a     |     _|                                 |_    |
  52.           |    |_| D2                          A06 |_|    |
  53.     b     |     _|                                 |_    |
  54.     u     |    |_| D3                          A07 |_|    |
  55.     s  ---+     _|                                 |_    |
  56.           |    |_| D4                          A08 |_|    |
  57.     8     |     _|                                 |_    |    A
  58.           |    |_| D5                          A09 |_|    |    d
  59.     b     |     _|                                 |_    |    d
  60.     i     |    |_| D6                          A10 |_|    |    r
  61.     t     |     _|                                 |_    |    e
  62.     s     +--- |_| D7                          A11 |_|    |    s
  63.                 _|                                 |_    |    s
  64.                    |_| DACK                          A12 |_|    |
  65.                     _|                                   |_     |
  66.                |_| GND                         A13 |_|    |
  67.             _| _____                           |_    |    b
  68.                |_| RESET                       A14 |_|    +--- u
  69.             _|     ____                        |_    |    s
  70.            |_| MEM/WRLD                    A15 |_|    |
  71.             _|   _                             |_    |    2
  72.            |_| R/W                         A16 |_|    |    4
  73.             _|                                 |_    |
  74.            |_| CLK                         A17 |_|    |    b
  75.             _|                                   |_    |    i
  76.                |_| VCC                         A18 |_|    |    t
  77.                 _|                                 |_    |    s
  78.                |_| ERROR                       A19 |_|    |
  79.                 _|                                 |_    |
  80.           +--- |_| A00                         A20 |_|    |
  81.           |     _|                                 |_    |
  82.           |    |_| A01                         A21 |_|    |
  83.           |     _|                                 |_    |
  84.           |    |_| A02                         A22 |_|    |
  85.           |     _|                                 |_    |
  86.           |    |_| A03                         A23 |_|    |
  87.           |      |                                   |    |
  88.           |      +-----------------------------------+    |
  89.           |                                                 |
  90.           |                                                 |
  91.           +-------------------------------------------------+
  92.  
  93. The only signals that might require some explanation are probably
  94.   _
  95. R/W :    When this signal is low, The processor is reading data from the databus.
  96.     When it is high, the processor is driving the the databus.
  97. _____
  98. RESET :    When this signal goes low, the processor is reset, and starts reading
  99.     incoming data from the databus, one byte each clock cycle, until the
  100.     line goes high again, at which time the processor will resume execution
  101.     of the program at memory location (Hex) 000000 (24 bits, remeber ?)
  102.     ____
  103. MEM/WRLD :                                                                   _
  104.     Indicates the `target' or `source' (depending on the status of the R/W
  105.     line) of the data bus, sort of like an additional address bit. If this
  106.     line is low, the processor is communicating with the outside world. If
  107.     it is high, the processor is talking to its memory.
  108.  
  109. DACK :    Data ACKnowledge. Used when the processor communicates with the
  110.     outside world. Two cases:
  111.     a) Processor Talking
  112.        After the processor put the data on the databus, it will wait
  113.        until the DACK has been raised, and then dropped again. Then
  114.        it will put the next byte of data (if any) on the bus, or
  115.        proceed to the next instruction.
  116.     b) Processor listening
  117.        The same procedure as above, but in the other direction :
  118.        After the processor has read one byte of data, it quickly raises &
  119.        drops the line, and then expects the next data item to be present.
  120.  
  121. ERROR :    Indicates the fact that an error condition has occurred somewhere
  122.     in the program. The error number is present on the data bus.
  123.     After the error number has ben read, the address of the next statement
  124.     to be executed, had the eror not occurred, can be read in three
  125.     consecutive bytes from the databus.
  126.  
  127. Processor Memory Management
  128.  
  129. Since the Intercal Language provides quite a few interesting ways to manipulate
  130. arrays, stash and retrieve data, etc, all of which operations require
  131. manipulations of memory, and it was the intention of this implementation to
  132. provide an instruction set which immediately makes the average Intercal
  133. programmer feel right at home, quite a few very complex instructions have been
  134. provided.
  135.  
  136. Intercal Machine Language Reference Part
  137.  
  138. Summary of instructions:
  139.  
  140. ABG            ABstain from Gerund
  141. ABL            ABstain from Label
  142. ALA            ALlocate Aray
  143. BAA            Begin Array Allocation
  144. BIA            Begin Indexing Array
  145. BIN            BINary operator
  146. CAL            CALculate
  147. DLD            Data LoaD
  148. EAA            End Array Allocation
  149. FRG            FoRGet
  150. IDA            InDex Array
  151. IGN            IGNore
  152. INS            INitiate Statement
  153. NEX            NEXt
  154. OST            Open STorage
  155. PCT            PerCenTage qualifier
  156. POP            POP
  157. PPA            PoP Array pointers
  158. PSA            PuSh Array pointers
  159. PSH            PuSH
  160. RDO            ReaD Out
  161. REG            Reinstate Gerund
  162. REL            Reinstate Label
  163. RMB            ReMemBer
  164. RSM            ReSuMe
  165. RTV            ReTrieVe
  166. STS            STaSh
  167. UNO            UNary Operator
  168. WRI            WRite In
  169.  
  170. General Format:
  171.  
  172.  i i i i i p p s  <optional arguments>
  173.  
  174. where
  175.  
  176.  i = instruction field
  177.  p = private field
  178.  s = size field
  179.  
  180. ABstain from Label
  181.  
  182. ABL Label
  183.  
  184.   0 1 1 1 1 0 0 0
  185.  
  186. Sets the abstain bit of instruction at Label
  187.  
  188. ABstain from Gerund
  189.  
  190. ABG mnm
  191.  
  192.   0 1 1 1 1 1 0 0
  193.  
  194. Sets the abstain bit of all statements whosde main instruction is mnm
  195.  
  196. Allocate Array
  197.  
  198.  
  199. ALA #num
  200. ALA .var
  201. ALA :var
  202. ALA ,
  203. ALA ;
  204. ALA RES
  205.  
  206.  
  207.   0 0 0 1 1 p p s
  208.  
  209. where p p specifies the source,
  210.  0 0 : immediate data <16 bits>
  211.  0 1 : Variable <variable specifier, 16 bits>
  212.  1 0 : Array, as pointed to by the Read Array Pointer
  213.  1 1 : the contents of the RES register
  214.  
  215. Takes the ALA argument, multiplies it with the current contents of the
  216. Temproary Register, and puts the result in the Temporary Register.
  217.  
  218. Begin Allocating Array
  219.  
  220. BAA ,var
  221. BAA ;var
  222.  
  223.  
  224.   0 0 0 1 0 0 0 s
  225.   array specifier, 16 bits
  226.   jump offset, 16 bits
  227.  
  228. Deallocates the memory block currently allocated to array `var', 
  229. opens the Arrray Entry for array `var' for writing, and puts a pointer
  230. to the Array Entry in the Wite Array Data pointer register. If the array
  231. is being ignored, none of these things actually happen -- instead, the
  232. jump offset is added to the program counter.
  233.  
  234. Begin Indexing Array
  235.  
  236. BIA R ,var
  237. BIA W ,var
  238. BIA R ;var
  239. BIA W ;var
  240.  
  241.  
  242.   0 0 1 0 1 0 t s
  243.   array specifier, 16 bits
  244.  
  245. where t = type, 0 = Read or 1 = Write
  246.  
  247. Sets the Read Array Data pointer to the address of the first array element,
  248. and the Read Array Dimension pointer to the first Dimension entry in the
  249. Array Table, thus preparing for further indexing.
  250.  
  251. BINary operator
  252.  
  253. BIN ~        Select
  254. BIN c/        Interleave,
  255. BIN $        aka Mingle
  256.  
  257.   0 1 1 0 0 t 0 0
  258.  
  259. where t is the operation specifier:
  260.   0 : Select
  261.   1 : Interleave / Mingle
  262.  
  263. The operation is performed on the OP1 and OP2 registers, and the result is
  264. placed in the RES register.
  265.  
  266. CALculate
  267.  
  268. CAL .
  269. CAL :
  270. CAL ,
  271. CAL ;
  272.  
  273.  
  274.   0 1 0 1 0 0 0 s
  275.  
  276. Puts the contents of the RES register in the memory location pointed to by
  277. the Write Array Data pointer
  278.  
  279. Data LoaD
  280.  
  281. DLD t #num
  282. DLD t .var
  283. DLD t :var
  284. DLD t ,
  285. DLD t ;
  286. DLD t RES
  287.  
  288.  
  289.   0 1 0 0 t p p s
  290.  
  291. where t = target register, 0 = OP1 or 1 = OP2
  292.       p p = source :
  293.  0 0 : Immediate data <16 bits>
  294.  0 1 : Variable <specifier, 16 bits>
  295.  1 0 : Array item (as indexed by the Read Array Data pointer)
  296.  1 1 : RES register
  297.  
  298. Loads the target register with the contents of the source
  299.  
  300. End Allocating Array
  301.  
  302. EAA
  303.  
  304.  
  305.   0 0 1 0 0 0 0 0
  306.  
  307. Allocates a chunk of memory to the size of
  308.  
  309. FoRGet
  310.  
  311. FRG #num
  312. FRG .var
  313. FRG :var
  314. FRG ,
  315. FRG ;
  316. FRG RES
  317.  
  318.  
  319.   1 0 0 0 0 p p s
  320.  
  321. where p p = source :
  322.  0 0 : Immediate <16 bits>
  323.  0 1 : variable <specifier, 16 bits>
  324.  1 0 : array (as indexed by the Read Array Data pointer)
  325.  1 1 : RES register
  326.  
  327. Pops source number of addresses from the stack, discarding them.
  328.  
  329. InDex Array
  330. IDA R #num
  331. IDA W #num
  332. IDA R .var
  333. IDA W .var
  334. IDA R :var
  335. IDA W :var
  336. IDA R RES
  337. IDA W RES
  338.  
  339.  
  340.   0 0 1 1 t p p s
  341.  
  342. where t = type, 0 = Read or 1 = Write
  343.       p p = source :
  344.  0 0 : Immediate Data <16 bits>
  345.  0 1 : variable <specifier, 16 bits>
  346.  1 0 : ILLEGAL
  347.  1 1 : RES register
  348.  
  349. Takes the Array Dimension (i.e, what the Array Dimension Pointer points to),
  350. adds (#num or RES) instances of it to the Array Data Pointer, and adds 2 to the
  351. Array Dimension Pointer.
  352.  
  353. IGNore
  354.  
  355. IGN .var
  356. IGN :var
  357. IGN ,var
  358. IGN ;var
  359.  
  360.   1 0 1 0 1 0 0 s
  361.   variable specifier, 16 bits
  362.  
  363. Sets the ignore flag of the variable specified
  364.  
  365. INitiate Statement
  366.  
  367. INS mnm Label
  368.  
  369. where `mnm' is one of the following 3-character mnemonics:
  370.  
  371. ABS             ABStain
  372. REI             REInstate
  373. CAL             CALculate
  374. NEX             NEXt
  375. FRG             FoRGet
  376. RES             RESume
  377. STS             STaSh
  378. RTV             ReTrieVe
  379. IGN             IGNore
  380. RMB             ReMemBer
  381. WRI             WRite In
  382. RDO             ReaD Out
  383.  
  384.  
  385.   1 1 1 p p p p p
  386.   2 bytes :
  387.   a o o o o o o o   o o o o o o o o
  388.  
  389. where p p p p p = major instruction opcode
  390.  
  391. where a is the abstain bit of the instruction : set if this instruction
  392. is to be abstained from. The remaining 15 bits are the jump offset, which will
  393. be added to the program counter should the instruction be abstained from.
  394. It is presumed that no statement will result in code exceeding 32.767 bytes.
  395.  
  396. NEXt
  397.  
  398. NEX Label
  399.  
  400.   0 1 1 0 1 0 0 0
  401.   Target Address, 24 bits
  402.  
  403. Pushes the address of the next instruction on the return stack and puts the
  404. Target addres in the Program counter
  405.  
  406. Open STorage
  407.  
  408. OST .var Label
  409. OST :var Label
  410. OST ,var Label
  411. OST ;var Label
  412.  
  413.  
  414.   0 0 0 0 1 0 0 s
  415.   variable/array specifier, 16 bits
  416.   jump offset, 8 bits
  417.  
  418.  
  419. Trys to open the specified variable for writing.
  420. If it being ignored (i.e, its ignore flag is set) the jump offset is
  421. added to the program counter.
  422. If it is an array, the Write Array Data pointer is set to the address
  423. of the first element of the array, and the Write Array Dimension pointer
  424. to the first dimension entry in the Array Table.
  425. If it is a Variable, the Write Array Data pointer is set to the address
  426. of the Variable.
  427.  
  428. PerCenTage qualifier
  429.  
  430. PCT #num Label
  431.  
  432.  
  433.   0 0 0 0 0 0 0 0
  434.   0 c c c c c c c
  435.   Jump offset, 16 bits
  436.  
  437. where c c c c c c c is a 7 bit binary number between 0 and 100
  438.  
  439. Gets a random number in the range 0 .. 99, compares it to the percent chance
  440. and acts on the result:
  441. - if the random number is less than the percent chance, nothing is done
  442. - if it is equal or greater, the jump offset is added to the program counter
  443.  
  444. POP
  445.  
  446. POP
  447.  
  448.  
  449.   1 1 0 0 0 0 1 0
  450.  
  451. Gets the top item on the stack and puts it in the RES register -- 32 bits
  452.  
  453. PoP Array pointers
  454.  
  455. PPA
  456.  
  457.   1 1 0 0 1 0 1 0
  458.  
  459. Retrieves the contents of the Read Array Data pointer from the stack
  460.  
  461. PuSh Array pointers
  462.  
  463. PSA
  464.  
  465.  
  466.   1 1 0 0 1 0 0 0
  467.  
  468. Pushes the contents of the Read Array Data pointer to an internal stack
  469.  
  470. PuSH
  471.  
  472. PSH
  473.  
  474.  
  475.   1 1 0 0 0 0 0 0
  476.  
  477. Pushes the RES register to the stack -- 32 bits
  478.  
  479. ReaD Out
  480.  
  481. RDO #num
  482. RDO .var
  483. RDO :var
  484. RDO ,
  485. RDO ;
  486. RDO RES
  487.  
  488.  
  489.   1 0 1 1 1 p p s
  490.  
  491. where p p = source:
  492.  0 0 : Immediate <16 bits>
  493.  0 1 : Variable <specifier, 16 bits>
  494.  1 0 : Array (as pointed to by the Read Array Data pointer)
  495.  1 1 : RES register
  496.  
  497. Writes 2 or 4 bytes (16 or 32 bits) on the data bus
  498.  
  499. REinstate Gerund
  500.  
  501. REG mnm
  502.  
  503.   0 1 1 1 0 1 0 0
  504.   operation specifier, 8 bits
  505.  
  506. In this form, the hole program will be searched to find instructions of the
  507. specified type, and their abstain bits will be reset.
  508.  
  509. REinstate Label
  510.  
  511. REL Label
  512.  
  513.   0 1 1 1 0 0 0 0
  514.   Label, 24 bits
  515.  
  516. In this form, the instruction at the address of Label will have its abstain
  517. bit set/reset.
  518.  
  519. ReMemBer
  520.  
  521. RMB .var
  522. RMB :var
  523. RMB ,var
  524. RMB ;var
  525.  
  526.   1 0 1 0 0 0 0 s
  527.   variable specifier, 16 bits
  528.  
  529. Clears the specified variable's ignore flag
  530.  
  531. ReSuMe
  532.  
  533. RSM #num
  534. RSM .var
  535. RSM :var
  536. RSM ,
  537. RSM ;
  538. RSM RES
  539.  
  540.   1 0 0 0 1 p p s
  541.  
  542. where p p = source :
  543.  0 0 : Immediate <16 bits>
  544.  0 1 : variable <specifier, 16 bits>
  545.  1 0 : array (as indexed by the Read Array Data pointer)
  546.  1 1 : RES register
  547.  
  548. Pops source number of addresses from the stack.
  549. If there are less than `source' items on the stack, the procesor is halted
  550. and an error signaled
  551. If no error occurs, the last popped address is NOT discarded, but instead
  552. placed in the Program counter.
  553.  
  554. ReTrieVe
  555.  
  556. RTV .var
  557. RTV :var
  558. RTV ,var
  559. RTV ;var
  560.  
  561.   1 0 0 1 1 0 0 s
  562.   Variable/Array Specifier, 16 bits
  563.  
  564. Retrieves the latest stashed instance of the variable or array specified
  565.  
  566. STaSh
  567.  
  568. STS .var
  569. STS :var
  570. STS ,var
  571. STS ;var
  572.  
  573.   1 0 0 1 0 0 0 s
  574.   Variable/Array specifier, 16 bits
  575.  
  576. Stashes the variable or array specified
  577.  
  578. UNary Operator
  579.  
  580. UNO &        AND
  581. UNO V        OR
  582. UNO V-        XOR
  583. UNO ?        XOR
  584.  
  585.   0 1 0 1 1 t t s
  586.  
  587. where t is the operation specifier:
  588.   00 : AND
  589.   01 : OR
  590.   10 : XOR
  591.   11 : Illegal
  592.  
  593. The specified operation is performed on the RESult register, leaving it there.
  594.  
  595. WRite In
  596.  
  597. WRI .
  598. WRI :
  599. WRI ,
  600. WRI ;
  601.  
  602.  
  603.   1 0 1 1 0 0 0 s
  604.  
  605. Reads 2 or 4 bytes (16 or 32 bits) from the data bus and puts them in
  606. the variable pointed to by the Write Array Data pointer
  607.  
  608.