home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / intercal.zip / doc / intercal.mm < prev    next >
Text File  |  1996-06-23  |  110KB  |  2,821 lines

  1. .\" Note: This is both a current manual and an archeological exhibit.
  2. .\" All revisions must be properly conditioned on the c string so that
  3. .\" it's still possible to format the INTERCAL-72 manual.
  4. .\"
  5. .\"    This document is free; you can redistribute it and/or modify
  6. .\"    it under the terms of the GNU General Public License as published by
  7. .\"    the Free Software Foundation; either version 2 of the License, or
  8. .\"    (at your option) any later version.
  9. .\"
  10. .\"    This document is distributed in the hope that it will be amusing,
  11. .\"    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. .\"    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. .\"    GNU General Public License for more details.
  14. .\"
  15. .\"    You should have received a copy of the GNU General Public License
  16. .\"    along with this document; if not, write to the Free Software
  17. .\"    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. .ND
  19. .ds vb V\v'-0.2'\h'-0.6'\-\v'0.2'
  20. .if n .ds es \o"O|"
  21. .if t .ds es \(es
  22. .if n .ds ct \o"c/"
  23. .if t .ds ct \(ct
  24. .if n .ds no \o"-'"
  25. .if t .ds no \(no
  26. .if n .ds ov -
  27. .if t .ds ov \(rn
  28. .INITR intercal.refs
  29. .TL
  30. THE INTERCAL PROGRAMMING LANGUAGE
  31. .br
  32. .if '\*c'y' REVISED REFERENCE MANUAL
  33. .if '!\*c'n' REFERENCE MANUAL
  34.  
  35. .AU "Donald R. Woods"
  36. .AF ""
  37. .AU "and"
  38. .AF ""
  39. .AU "James M. Lyon"
  40. .AF ""
  41. .if '\*c'y' \{\
  42. .AU ""
  43. .AU "C-INTERCAL revisions:"
  44. .AU "Louis Howell"
  45. .AF ""
  46. .AU "and"
  47. .AF ""
  48. .AU "Eric S. Raymond" \}
  49. .AF ""
  50. .AST ""
  51. .AS 2
  52. .ce 2
  53. \fICopyright (C) 1973 by Donald R. Woods
  54. and James M. Lyon\fR
  55. .if '\*c'y' \{\
  56. .ce 2
  57. \fICopyright (C) 1996 by Eric S. Raymond
  58. Redistribution encouraged under GPL\}
  59. .sp
  60. .ce 1
  61. (This version distributed with C-INTERCAL 0.15)
  62. .AE
  63. .MT 4
  64. .nr % 0
  65. .nr Hs 5
  66. .nr Ej 1
  67. .bp
  68. .H 1 "INTRODUCTION"
  69. .P
  70. The names you are about to ignore are true. However, the story has been changed
  71. significantly. Any resemblance of the programming language portrayed here
  72. to other programming languages, living or dead, is purely coincidental.
  73. .H 2 "Origin and Purpose"
  74. .P
  75. The INTERCAL programming language was designed the morning of May 26, 1972
  76. by Donald R. Woods and James M. Lyon, at Princeton University. Exactly when
  77. in the morning will become apparent in the course of this manual. 
  78. .ie '\*c'y' \{\
  79. .P
  80. Eighteen years later (give or take a few months) Eric S. Raymond perpetrated
  81. a UNIX-hosted INTERCAL compiler as a weekend hack.  The C-INTERCAL
  82. implementation has since been maintained and extended by an international
  83. community of technomasochists, including Louis Howell, Steve Swales,
  84. Michael Ernst, and Brian Raiter.
  85. .P
  86. (There was evidently an Atari implementation sometime between these
  87. two; notes on it got appended to the INTERCAL-72 manual.  The culprits
  88. have sensibly declined to identify themselves.)
  89. .P
  90. INTERCAL \}
  91. .el It
  92. was inspired by one ambition: to have a compiler language which has nothing at 
  93. all in common with any other major language. By 'major' was meant anything
  94. with which the authors were at all familiar, e.g., FORTRAN, BASIC, COBOL,
  95. ALGOL, SNOBOL, SPITBOL, FOCAL, SOLVE, TEACH, APL, LISP, and PL/I. For the
  96. most part, INTERCAL has remained true to this goal, sharing only the basic
  97. elements such as variables, arrays, and the ability to do I/O, and eschewing 
  98. all conventional operations other than the assignment statement (FORTRAN
  99. "=").
  100. .H 2 "Acronym"
  101. .P
  102. The full name of the compiler is "Compiler Language With No Pronounceable
  103. Acronym", which is, for obvious reasons, abbreviated "INTERCAL".
  104. .H 2 "Acknowledgments"
  105. .P
  106. The authors are deeply indebted to Eric M. Van and Daniel J. Warmenhoven,
  107. without whose unwitting assistance this manual would still have been
  108. possible.
  109. .H 1 "FUNDAMENTAL CONCEPTS"
  110. .P
  111. In this section an attempt is made to describe how and why INTERCAL may be
  112. used; i.e., what it is like and what it is good for.
  113. .H 2 "Sample Program"
  114. .SETR example1
  115. .P
  116. Shown below is a relatively simple INTERCAL program which will read in 32-bit
  117. unsigned integers, treat them as signed, 2's-complement numbers, and print out 
  118. their absolute values. The program exits if the absolute value is zero. Note
  119. in particular the inversion routine (statements 6 through 14), which could
  120. be greatly simplified if the subroutine library (see section
  121. .GETHN sublib
  122. ) were used.
  123. .P
  124. A more detailed analysis of a program is made in section 
  125. .GETHN proghints
  126.  of this manual.
  127. .DS L
  128. .cs R 24
  129.         DO (5) NEXT
  130.     (5) DO FORGET #1
  131.         PLEASE WRITE IN :1
  132.         DO .1 <- '\*(vb":1~'#32768\*(ct#0'"\*(ct#1'~#3
  133.         DO (1) NEXT
  134.         DO :1 <- "'\*(vb":1~'#65535\*(ct#0'"\*(ct#65535'
  135.                 ~'#0\*(ct#65535'"\*(ct"'\*(vb":1~'#0\*(ct#65535'"
  136.                 \*(ct#65535'~'#0\*(ct#65535'"
  137.         DO :2 <- #1
  138.         PLEASE DO (4) NEXT
  139.     (4) DO FORGET #1
  140.         DO .1 <- "\*(vb':1~:2'\*(ct#1"~#3
  141.         DO :1 <- "'\*(vb":1~'#65535\*(ct#0'"\*(ct":2~'#65535
  142.                 \*(ct#0'"'~'#0\*(ct#65535'"\*(ct"'\*(vb":1~'#0
  143.                 \*(ct#65535'"\*(ct":2~'#65535\*(ct#0'"'~'#0\*(ct#65535'"
  144.         DO (1) NEXT
  145.         DO :2 <- ":2~'#0\*(ct#65535'"
  146.                 \*(ct"'":2~'#65535\*(ct#0'"\*(ct#0'~'#32767\*(ct#1'"
  147.         DO (4) NEXT
  148.     (2) DO RESUME .1
  149.     (1) PLEASE DO (2) NEXT
  150.         PLEASE FORGET #1
  151.         DO READ OUT :1
  152.         PLEASE DO .1 <- '\*(vb"':1~:1'~#1"\*(ct#1'~#3
  153.         DO (3) NEXT
  154.         PLEASE DO (5) NEXT
  155.     (3) DO (2) NEXT
  156.         PLEASE GIVE UP
  157. .cs R
  158. .DE
  159. .H 2 "Uses for INTERCAL"
  160. .P
  161. INTERCAL's main advantage over other programming languages is its strict
  162. simplicity. It has few capabilities, and thus there are few restrictions to
  163. be kept in mind. Since it is an exceedingly easy language to learn, one
  164. might expect it would be a good language for initiating novice programmers.
  165. Perhaps surprising, than, is the fact that it would be more likely to
  166. initiate a novice into a search for another line of work. As it turns out,
  167. INTERCAL is more useful (which isn't saying much) as a challenge to
  168. professional programmers.  Those who doubt this need only refer back to the
  169. sample program in section
  170. .GETHN example1
  171. \&. This 22-statement program took somewhere
  172. from 15 to 30 minutes to write, whereas the same objectives can be achieved
  173. by single-statement programs in either SNOBOL;
  174. .DS L
  175.         PLEASE INPUT POS(0) ('-' ! '')
  176.         + (SPAN('0123456789') $ OUTPUT)
  177.         + *NE(OUTPUT) :S(PLEASE)F(END)
  178. .DE
  179. or APL;
  180. .DS L
  181.         [1] \(->0\(!=\(sq\(<-\(or\(sq
  182. .DE
  183. Admittedly, neither of these is likely to appear more intelligible to
  184. anyone unfamiliar with the languages involved, but they took roughly 60
  185. seconds and 15 seconds, respectively, to write. Such is the overwhelming
  186. power of INTERCAL!
  187. .P
  188. The other major importance of INTERCAL lies in its seemingly inexhaustible
  189. capacity for amazing one's fellow programmers, confounding programming shop
  190. managers, winning friends, and influencing people. It is a well-known and
  191. oft-demonstrated fact that a person whose work is incomprehensible is held
  192. in high esteem. For example, if one were to state that the simplest way to
  193. store a value of 65536 in a 32-bit INTERCAL variable is:
  194. .DS L
  195.         DO :1 <- #0\*(ct#256
  196. .DE
  197. any sensible programmer would say that that was absurd. Since this is
  198. indeed the simplest method, the programmer would be made to look foolish in
  199. front of his boss, who would of course happened to turn up, as bosses are
  200. wont to do. The effect would be no less devastating for the programmer
  201. having been correct.
  202. .H 1 "DESCRIPTION"
  203. .P
  204. The examples of INTERCAL programming which have appeared in the preceding
  205. sections of this manual have probably seemed highly esoteric to the reader
  206. unfamiliar with the language. With the aim of making them more so, we
  207. present here a description of INTERCAL.
  208. .H 2 "Variables"
  209. .P
  210. INTERCAL allows only 2 different types of variables, the
  211. .B "16-bit integer"
  212. and the
  213. .B "32-bit integer."
  214. These are represented by a spot (.) or two-spot
  215. (:), respectively, followed by any number between 1 and 65535, inclusive.
  216. These variables may contain only non-negative numbers; thus they have the
  217. respective ranges of values: 0 to 65535 and 0 to 4294967295. Note: .123 and
  218. :123 are two distinct variables. On the other hand, .1 and .0001 are
  219. identical.  Furthermore, the latter may NOT be written as 1E-3.
  220. .H 2 "Constants"
  221. .P
  222. .B Constants
  223. are 16-bit values only and may range from 0 to 65535. They are
  224. prefixed by a mesh (#). Caution! Under no circumstances confuse the mesh
  225. with the interleave operator, except under confusing circumstances!
  226. .H 2 "Arrays"
  227. .P
  228. .B Arrays
  229. are represented by a tail (,) for 16-bit values, or a hybrid (;) for
  230. 32-bit values, followed by a number between 1 and 65535, inclusive. The
  231. number is suffixed by the word SUB, followed by the subscripts, separated
  232. optionally by spaces. Subscripts may be any expressions, including those
  233. involving subscripted variables. This occasionally leads to ambiguous
  234. constructions, which are resolved as discussed in section 
  235. .GETHN precedence
  236. \&.  Definition
  237. of array dimensions will be discussed later in greater detail, since
  238. discussing it in less detail would be difficult. As before, ,123 and ;123
  239. are distinct.  In summary, .123, :123, #123, ,123, and :123 are all
  240. distinct.
  241. .H 2 "Operators"
  242. .P
  243. INTERCAL recognizes 5 operators -- 2 binary and 3 unary. Please be kind to 
  244. our operators: they may not be very intelligent, but they're all we've got.
  245. In a sense, all 5 operators are binary, as they are all bit-oriented, but
  246. it is not our purpose here to quibble about bits of trivia.
  247. .H 3 "Binary Operators"
  248. .P
  249. The binary operators are \fBinterleave\fR (also called \fBmingle\fR)
  250. and \fBselect\fR, which
  251. are represented by a change (\*(ct) and a sqiggle [sic] (~), respectively.
  252. .if '\*c'y' \{\
  253. (In C-INTERCAL'S ASCII environment, EBCDIC \*(ct is replaced by a big
  254. money ($).) \}
  255. .P
  256. The interleave operator takes two 16-bit values and produces a 32-bit result
  257. by alternating the bits of the operands. Thus, #65535\*(ct#0 has the 32-bit
  258. binary form 101010....10 or 2863311530 decimal, while #0\*(ct#65535 = 
  259. 0101....01 binary = 1431655765 decimal, and #255\*(ct#255 is equivalent to
  260. #65535.
  261. .P
  262. The select operator takes from the first operand whichever bits correspond
  263. to 1's in the second operand, and packs these bits to the right in the result.
  264. Both operands are automatically padded on the left with zeros to 32 bits
  265. before the selection takes place, so the variable types are unrestricted.
  266. If more than 16 bits are selected, the result is a 32-bit value, otherwise
  267. it is a 16-bit value. For example, #179~#201 (binary value 10110011~11001001)
  268. selects from the first argument the 8th, 7th, 4th, and 1st from last bits,
  269. namely, 1001, which = 9. But #201~#179 selects from binary 11001001 the 8th,
  270. 6th, 5th, 2nd, and 1st from last bits, giving 10001 = 17. #179~#179 has the
  271. value 31, while #201~#201 has the value 15.
  272. .if '\*c'y' \{\
  273. .H 4 "Return type of SELECT"
  274. .P
  275. INTERCAL-72 defined the return type of a SELECT operation
  276. to depend on the number of bits SELECTed.  The C-INTERCAL compiler
  277. takes the easier route of defining the return type to be that of
  278. the right operand, independent of its actual value.  This form has
  279. the advantage that all types can be determined at compile time.
  280. Putting in run time type checking would add significant overhead and
  281. complication, to effect a very minor change in language semantics.
  282. .P
  283. The only time this distinction makes any difference is when a unary
  284. operator is applied to the SELECT result.  This happens extremely
  285. rarely in practice, the only known instance being the 32-bit
  286. greater-than test in the standard library, where an XOR operator is
  287. applied to the result of SELECTing a number against itself.  The
  288. INTERCAL-72 authors first SELECT the result against #65535\*(ct#65535 to
  289. insure that XOR sees a 32-bit value.  With the current compiler this
  290. extra step is unnecessary, but harmless.
  291. .P
  292. The cautious programmer should write code that does not depend on
  293. the compiler version being used.  We therefore suggest the following
  294. guideline for determining the SELECT return type:
  295. .P
  296. A SELECT operation with a 16-bit right operand returns a 16-bit
  297. value.  The return type of a SELECT operation with a 32-bit right
  298. operand is undefined, but is guaranteed to be an acceptable input
  299. to a MINGLE operation so long as 16 or fewer bits are actually
  300. selected.  Correct code should not depend on whether the return
  301. type is 16 or 32 bits.\}
  302. .P
  303. Perhaps a simpler way of understanding the operation of the select operator
  304. would be to examine the logic diagram on the following page (Figure 1), which
  305. performs the select operation upon two 8-bit values, A and B. The gates used
  306. are Warmenhovian logic gates, which means the outputs have four possible
  307. values: low, high, undefined (value of an uninitialized flip-flop), and
  308. oscillating (output of a NOR gate with one input low and the other input
  309. connected to the output). These values are represented symbolically
  310. by '0', '1', '?', and '\*(es'.
  311. Note in particular that, while NOT-0 is 1 and NOT-1
  312. is 0 as in two-valued logic, NOT-? is ? and NOT-\*(es is \*(es. The functions 
  313. of the various gates are listed in Table 1.
  314. .if n \{\
  315. .P
  316. [Warning: The following picture will be garbled or missing.
  317. Get a better output device.] 
  318. .sp 1 \}
  319. .PS
  320. # The CIRCUITOUS DIAGRAM, Figure 1 of the INTERCAL manual.
  321. #
  322. # Transcribed to PIC by Eric S. Raymond from the paper original.
  323. # The transcription to topologically correct but not geometrically perfect.
  324. #
  325. # I discovered late in the process that the gate spacing to gate width
  326. # ratio should be 6/5, not 5/5. The only place the difference shows is
  327. # in the zigzag part of the adventitious lead below gate 37, which is
  328. # a bit narrower in this version than in the paper original.
  329. #
  330. # Minor liberties have been taken with the sizes of some features at the 
  331. # left and right sides to fit the diagram on a letter-sized page.  The
  332. # A/B input leads should really be a whole boxwidth wide, and the bus line
  333. # rectangle was slightly wider and further right in the paper original.
  334. # Also, there are only 15 "New York" terminals rather than 16, and in the
  335. # original the bus terminal label texts were rotated 90 degrees clockwise.
  336. #
  337. # The whole diagram can be scaled horizontally or vertically by changing
  338. # the boxwid and boxht variables.  At default scale the values boxwid =
  339. # 0.60 boxht = 0.525 reproduce the paper version most exactly; they get
  340. # the gate grid and leads nearly perfect.
  341. #
  342. scale=6/5       # This is how we scale the whole thing to fit on 8.5x11
  343. boxwid = 0.60
  344. boxht = 0.525
  345. linewid = boxwid
  346. lineht = boxht
  347. movewid = boxwid
  348. moveht = boxht
  349.  
  350. # Offset of top and bottom pins from gate midline
  351. define pinoffset {(2/3)}
  352.  
  353. define warmengate { 
  354. # Draw a Warmenhovian gate box
  355.         [
  356.                 box invis;
  357.                 line from last box .sw \
  358.                         to last box .nw \
  359.                         to 1/2 <last box .ne, last box .n> \
  360.                         to 1/2 <last box .e, last box .ne> \
  361.                         to 1/2 <last box .e, last box .se> \
  362.                         to 1/2 <last box .se, last box .s> \
  363.                         to last box .sw;
  364.                 IN: last box .w;
  365.                 UP: pinoffset <last box .w, last box .nw>
  366.                 DN: pinoffset <last box .w, last box .sw>
  367.                 OUT: last box .e;
  368.                 "$1" at last box .center;
  369.         ]
  370. }
  371.  
  372. [ # Beginning of diagram object
  373.  
  374. # Draw the gate array
  375. copy thru % move to (($1-1) * movewid * 2, ($2-1) * moveht * 2); warmengate($3) % until "END"
  376. 0 1  6
  377. 0 2  6
  378. 0 3  1
  379. 0 4  1
  380. 0 5  1
  381. 0 6  1
  382. 0 7  1
  383. 0 8  1
  384. 0 9  1
  385. 0 10 1
  386. END
  387. copy thru % move to ((boxwid + movewid * 7 / 5) + ($1-2) * movewid * 2, ($2-1) * moveht * 2); warmengate($3) % until "END"
  388. 1 1  1
  389. 1 2  2
  390. 1 3  2
  391. 1 4  2
  392. 1 5  2
  393. 1 6  2
  394. 1 7  2
  395. 1 8  2
  396. 1 9  2
  397. 1 10 2
  398. 2 1  1
  399. 2 2  7
  400. 2 3  4
  401. 2 4  3
  402. 2 5  3
  403. 2 6  3
  404. 2 7  7
  405. 2 8  3
  406. 2 9  7
  407. 2 10 3
  408. 3 1  1
  409. 3 2  3
  410. 3 3  3
  411. 3 4  4
  412. 3 5  4
  413. 3 6  3
  414. 3 7  3
  415. 3 8  3
  416. 3 9  3
  417. 3 10 3
  418. 4 1  1
  419. 4 2  4
  420. 4 3  5
  421. 4 4  5
  422. 4 5  4
  423. 4 6  5
  424. 4 7  4
  425. 4 8  3
  426. 4 9  2
  427. 4 10 1
  428. END
  429.  
  430. # Draw bus line:
  431. BUSLINE: box with .sw at 41st [].se + (boxwid/2, 0) \
  432.                 wid (boxwid / 2) \
  433.                 ht (50th [].n.y - 41st [] .s.y)
  434. copy thru % move to $1 / 40 <last box .n, last box .s>; "$2"  % until "END"
  435. 9  B
  436. 11  U
  437. 13  S
  438. 17  L
  439. 19  I
  440. 21  N
  441. 23  E
  442. 30  8
  443. END
  444. define newyork {
  445.         line right boxwid/3
  446.         box invis "" "TO" "NEW" "YORK" ""
  447. }
  448. define philly {
  449.         line right boxwid/3
  450.         box invis "" "TO" "PHILA-" "DELPHIA" ""
  451. }
  452. for i = 0 to 14 do {
  453.         move to (i+1)/18 <BUSLINE.ne,BUSLINE.se>
  454.         newyork
  455. }
  456. move to (i+1)/18 <BUSLINE.ne,BUSLINE.se>
  457. philly
  458.  
  459. define dot {circle rad 0.03 filled 1}
  460.  
  461. # Place a junction dot wherever we are
  462. define junction % {dot at Here}; %
  463.  
  464. # Draw inputs
  465. define inwidth {boxwid*3/4}
  466. define drawinputs {
  467.         line left inwidth from $1.UP;
  468.         "A" at last line .end - (0.1, 0) rjust;
  469.         "$2" at last line .end - (0.05, 0.1) rjust;
  470.         move to last line .center; A$2: junction
  471.         line left inwidth from $1.DN;
  472.         "B" at last line .end - (0.1, 0) rjust;
  473.         "$2" at last line .end - (0.05, 0.1) rjust;
  474.         move to last line .center; B$2: junction
  475. }
  476. drawinputs(3rd [],8)
  477. drawinputs(4th [],7)
  478. drawinputs(5th [],6)
  479. drawinputs(6th [],5)
  480. drawinputs(7th [],4)
  481. drawinputs(8th [],3)
  482. drawinputs(9rd [],2)
  483. # Gate 10 inputs have to be done by hand
  484.  
  485. define go {move to $1;}
  486.  
  487. # Define `gate' to *refer* to nth gate
  488. define gate {`$1'th []}
  489.  
  490. # Go to specified pin of given gate
  491. define pin {gate($1).$2}
  492.  
  493. # We exploit the quantization of lead placements here
  494. # Draw from left edge of box $1 quanta of inter-box horizontal distance
  495. define left_mv {line left boxwid * $1 / 5;}
  496. # Draw from right edge of box $1 quanta of inter-box horizontal distance
  497. define right_mv {line right boxwid * $1 / 5;}
  498. # Draw from top pin of box $1 quanta of inter-box vertical distance up
  499. define up_mv {line up (boxht * (2 - pinoffset)) * $1 / 4;}
  500. # Draw from bottom pin of box $1 quanta of inter-box vertical distance down
  501. define dn_mv {line down (boxht * (2 - pinoffset)) * $1 / 4;}
  502.  
  503. # Draw from here to given object, with directional constraint
  504. define vert {line up ($1.y - Here.y);}
  505. define horz {line right ($1.x - Here.x);}
  506. define zig {vert($1) horz($1)}
  507. define to_bus {line to (BUSLINE.w, Here)} 
  508.  
  509. define ground {
  510.         dn_mv(1)
  511.         [
  512.         boxwid = boxwid * (3/4)
  513.         boxht = boxht / 3
  514.         box invis
  515.         line from last box .ne to last box .nw
  516.         line from 1/3 <last box.e,last box.c> to 1/3 <last box.w,last box.c>
  517.         line from 2/3 <last box.se,last box.s> to 2/3 <last box.sw,last box.s>
  518.         ]
  519. }
  520.  
  521. # Now all those connections
  522. # Gate 1:
  523. go(pin(1,OUT)) right_mv(3) CORNER:Here; zig(pin(12,DN))
  524. go(CORNER) vert(pin(1,UP)) \
  525.         {junction horz(pin(11,UP))} \
  526.         up_mv(2) junction 
  527.         horz(gate(32).e) right_mv(3) junction
  528.         {zig(pin(43,IN))}
  529.         horz(gate(42).e) right_mv(1) junction
  530.         {to_bus}
  531.         vert(pin(43,UP)) up_mv(2) to_bus
  532.  
  533. # Gate 2
  534. go(pin(2,OUT)) right_mv(2) zig(pin(12,UP))
  535. # Gate 3
  536. go(A8) up_mv(1) horz(gate(13).e) right_mv(3) zig(pin(23,IN))
  537. go(B8) dn_mv(1) horz(gate(13))
  538.         right_mv(1) dn_mv(1)
  539.         horz(gate(23).e) right_mv(2) dn_mv(2) horz(pin(32,UP)) 
  540. go(pin(3,OUT)) right_mv(2)
  541.         vert(gate(3).UP) up_mv(3) 
  542.         horz(gate(13).e) right_mv(2)
  543.         vert(gate(15,UP)) up_mv(4)      #??? don't know why 4 is necessary
  544.         horz(gate(16).w) left_mv(1) 
  545.         vert(gate(6).w) up_mv(4) 
  546.         left_mv(2) zig(pin(7,OUT))
  547. # Gate 4
  548. go(A7) up_mv(1) horz(gate(14).e) right_mv(1) zig(pin(24,UP))
  549. go(B7) dn_mv(1) horz(gate(4))
  550.         right_mv(1) dn_mv(1)
  551.         horz(gate(14).e) right_mv(3)
  552.         vert(pin(26,UP)) up_mv(1)
  553.         horz(gate(25)) up_mv(2) 
  554.         horz(gate(25).e) right_mv(4)
  555.         vert(pin(38,UP)) up_mv(1)
  556.         horz(gate(48).e) right_mv(1)
  557.         vert(pin(47,DN)) dn_mv(1)
  558.         horz(gate(47).w) left_mv(3)
  559.         vert(gate(46).DN) dn_mv(2) right_mv(2)
  560.         vert(gate(45).DN) dn_mv(2) left_mv(3)
  561.         vert(gate(44).DN) right_mv(3) dn_mv(2)
  562.         horz(gate(33).w) left_mv(1)
  563.         vert(gate(33).DN) dn_mv(3)
  564.         horz(gate(32).e) up_mv(2)
  565.         horz(gate(42).e) dn_mv(2) line down boxwid/5
  566.         to_bus
  567. go(pin(4,OUT)) right_mv(3) junction
  568.         {zig(pin(13,UP))}
  569.         vert(pin(4,UP)) up_mv(3) junction
  570.         {right_mv(3) zig(pin(15,IN))}
  571.         left_mv(2) vert(pin(7,UP)) up_mv(3)
  572.         right_mv(3) zig(pin(19,DN))
  573. # Gate 5
  574. go(A6) up_mv(1) horz(gate(15).e) right_mv(1) vert(pin(15,UP)) junction
  575.         {horz(pin(25,UP))}
  576.         vert(pin(15,DN)) dn_mv(1)
  577.         horz(gate(25).e) right_mv(1)
  578.         zig(pin(34,UP)) 
  579. go(B6) dn_mv(2) horz(gate(25).e) dn_mv(1) right_mv(4)
  580.         vert(pin(24,DN)) dn_mv(1)
  581.         horz(gate(34).e) right_mv(1)
  582.         vert(pin(32,DN)) dn_mv(1)
  583.         right_mv(3) zig(pin(42,IN))
  584. go(pin(5,OUT)) right_mv(5) junction
  585.         {vert(pin(14,IN)) junction {horz(pin(14,IN))} zig(pin(13,IN)) }
  586.         vert(pin(17,DN)) junction {horz(pin(17,DN))} zig(pin(18,DN))
  587. # Gate 6
  588. go(A5) up_mv(1) horz(gate(16).e) right_mv(1) zig(pin(26,UP))
  589. go(B5) dn_mv(2) horz(gate(26).e) right_mv(3) zig(pin(34,IN))
  590. go(pin(6,OUT)) right_mv(4) junction 
  591.         {horz(pin(16,IN))}
  592.         vert(pin(15,DN)) junction
  593.         {horz(pin(15,DN))}
  594.         vert(pin(14,DN)) junction
  595.         {horz(pin(14,DN))}
  596.         zig(pin(13,DN))
  597. # Gate 7
  598. go(A4) up_mv(1) horz(gate(27).e) right_mv(3) vert(pin(37,IN)) junction
  599.         {horz(pin(37,IN))}
  600.         vert(pin(37,DN)) dn_mv(2) right_mv(1) junction
  601.         {zig(pin(36,IN))}
  602.         horz(gate(37).e) right_mv(3)
  603.         zig(pin(45,IN))
  604. go(B4) dn_mv(2) horz(gate(17).e) right_mv(4) 
  605.         vert(pin(26,DN)) dn_mv(1) 
  606.         horz(gate(26).e) dn_mv(2)
  607.         right_mv(4) vert(pin(35,DN)) dn_mv(1)
  608.         horz(gate(35).e) right_mv(2) junction
  609.         {zig(pin(45,UP))} {zig(pin(44,UP))}
  610. # Gate 8
  611. go(A3) up_mv(1) horz(gate(28).e) right_mv(1) zig(pin(38,UP))
  612. go(B3) dn_mv(2) horz(gate(28).e) right_mv(2) zig(pin(37,UP))
  613. go(pin(8,OUT)) right_mv(6) junction
  614.         {zig(pin(17,IN))}
  615.         up_mv(4) left_mv(1) vert(pin(19,UP)) junction
  616.         {horz(pin(19,UP))}
  617.         zig(pin(20,UP))
  618. # Gate 9
  619. go(A2) up_mv(1) horz(gate(19).e) right_mv(1) zig(pin(28,UP))
  620. go(B2) dn_mv(2) horz(gate(39).e) right_mv(1)
  621.         vert(pin(38,DN)) dn_mv(2) right_mv(2) zig(pin(47,IN))
  622. go(pin(9,OUT)) right_mv(3) junction
  623.         {zig(pin(20,DN))}
  624.         {horz(pin(19,IN))}
  625.         vert(pin(16,DN)) junction
  626.         {horz(pin(16,DN))}
  627.         zig(pin(15,UP))
  628. # Gate 10
  629. line left inwidth from 10th[].UP;
  630. "A" at last line .end - (0.1, 0) rjust;
  631. "1" at last line .end - (0.05, 0.1) rjust;
  632. move to last line .center; A1: junction
  633. line left inwidth from 10th [].DN;
  634. "B" at last line .end - (0.1, 0) rjust;
  635. "1" at last line .end - (0.05, 0.1) rjust;
  636. move to 1/2 <last line .center, last line .start>; B1: junction
  637. go(A1) vert(pin(10,DN)) dn_mv(1) horz(gate(20).e) right_mv(2) zig(pin(30,UP))
  638. go(B1) dn_mv(2) horz(gate(30).e) right_mv(1) junction
  639.         {zig(pin(39,UP))}
  640.         right_mv(3) zig(pin(40,DN))
  641. go(pin(10,OUT)) right_mv(2) junction
  642.         {horz(pin(20,IN))}
  643.         vert(pin(18,UP)) junction
  644.         {horz(pin(18,UP))}
  645.         vert(pin(16,UP)) junction
  646.         {horz(pin(16,UP))}
  647.         zig(pin(14,UP))
  648. # Gate 11
  649. go(pin(11, DN)) left_mv(3) vert(pin(11,UP)) up_mv(1) \
  650.         horz(gate(31).e) right_mv(1) zig(pin(41,DN))
  651. go(pin(11,OUT)) right_mv(2) zig(pin(21,DN))
  652. # Gate 12
  653. go(pin(12,OUT)) right_mv(3) junction
  654.         {horz(pin(22,IN))}
  655.         vert(pin(12,UP)) up_mv(1)
  656.         horz(gate(12).w) left_mv(3)
  657.         zig(pin(12,IN)) 
  658. # Gate 13
  659. go(pin(13,OUT)) right_mv(1) zig(pin(23,UP))
  660. # Gate 14
  661. go(pin(14,OUT)) horz(pin(24,IN))
  662. # Gate 15
  663. go(pin(15,OUT)) horz(pin(25,IN))
  664. # Gate 16
  665. go(pin(16,OUT)) right_mv(2) junction
  666.         {horz(pin(26,IN))}
  667.         vert(pin(27,UP)) junction
  668.         {horz(pin(27,UP))}
  669.         zig(pin(29,DN))
  670. # Gate 17
  671. go(pin(17,OUT)) horz(pin(27,IN))
  672. # Gate 18
  673. go(pin(18,OUT)) right_mv(3) junction
  674.         {horz(pin(28,IN))}
  675.         zig(pin(27,DN))
  676. # Gate 19
  677. go(pin(19,OUT)) horz(pin(29,IN))
  678. # Gate 20
  679. go(pin(20,OUT)) right_mv(3) junction
  680.         {horz(pin(30,IN))}
  681.         zig(pin(29,UP))
  682. # Gate 21
  683. go(pin(21,UP)) left_mv(2) vert(pin(21,DN)) ground
  684. go(pin(21,OUT)) right_mv(2) junction
  685.         {zig(pin(31,DN))}
  686.         up_mv(2) junction
  687. # Gate 22
  688. go(pin(22,UP)) left_mv(3) up_mv(2) junction
  689. go(pin(22,DN)) left_mv(4)
  690.         vert(pin(22,UP)) up_mv(3) right_mv(3)
  691.         vert(pin(23,UP)) up_mv(3)
  692.         horz(gate(23).e) right_mv(2)
  693.         vert(pin(25,UP)) left_mv(1)
  694.         vert(pin(28,DN)) right_mv(1)
  695.         zig(pin(40,IN))
  696. go(pin(22,OUT)) right_mv(3) junction
  697.         {horz(pin(32,IN))} 
  698.         {zig(pin(33,IN))} 
  699.         zig(pin(31,UP)) 
  700. # Gate 23
  701. go(pin(23,OUT)) right_mv(1) 
  702.         vert(gate(23).DN) dn_mv(1)
  703.         horz(gate(33)) right_mv(1)
  704.         dn_mv(1) to_bus
  705. # Gate 24
  706. go(pin(24,OUT)) right_mv(1) zig(pin(33,UP))
  707. # Gate 25
  708. go(pin(25,OUT)) horz(pin(35,IN))
  709. # Gate 26
  710. go(pin(26,OUT)) right_mv(2) vert(pin(26,DN)) dn_mv(1) junction
  711.         {to_bus}
  712.         zig(pin(35,UP))
  713. # Gate 27
  714. go(pin(27,OUT)) right_mv(2) zig(pin(36,UP))
  715. # Gate 28
  716. go(pin(28,OUT)) right_mv(3) junction
  717.         {horz(pin(38,IN))}
  718.         vert(pin(38, DN)) dn_mv(1) to_bus 
  719. # Gate 29
  720. go(pin(29,OUT)) right_mv(3) junction
  721.         {horz(pin(39,IN))}
  722.         {vert(pin(39, DN)) dn_mv(1) to_bus} 
  723.         zig(pin(40,UP))
  724. # Gate 30
  725. go(pin(30,OUT)) right_mv(1)
  726.         vert(pin(30,DN)) dn_mv(1)
  727.         horz(gate(40).e) right_mv(2)
  728.         zig(pin(50,UP))
  729. # Gate 31
  730. go(pin(31,OUT)) right_mv(2) zig(pin(41,UP))
  731. # Gate 32
  732. go(pin(32,OUT)) right_mv(2) vert(pin(32,UP)) junction
  733.         {horz(pin(42,UP))}
  734.         up_mv(1) to_bus
  735. # Gate 33
  736. go(pin(33,OUT)) right_mv(2) zig(pin(43,UP))
  737. # Gate 34
  738. go(pin(34,OUT)) right_mv(3) junction
  739.         {horz(pin(44,IN))}
  740.         vert(pin(44, DN)) dn_mv(1) to_bus 
  741. # Gate 35
  742. go(pin(35,OUT)) right_mv(1) dn_mv(1) right_mv(2) dn_mv(1) to_bus
  743. # Gate 36
  744. go(pin(36,OUT)) horz(pin(46,IN))
  745. # Gate 37
  746. go(pin(37,OUT)) right_mv(2) vert(pin(48,UP)) junction
  747.         {horz(pin(48,UP))}
  748.         zig(pin(49,DN))
  749. # Gate 38
  750. go(pin(38,OUT)) right_mv(3) junction
  751.         {horz(pin(48,IN))}
  752.         vert(pin(48,DN)) right_mv(1) dn_mv(3) left_mv(3)
  753.         vert(pin(47,UP)) junction 
  754.         {horz(pin(47,UP))}
  755.         zig(pin(46,UP))
  756. # Gate 39
  757. go(pin(39,OUT)) right_mv(3) junction
  758.         {horz(pin(49,IN))}
  759.         {vert(pin(49, DN)) dn_mv(2) to_bus}
  760.         zig(pin(50,IN))
  761. # Gate 40
  762. go(pin(40,OUT)) right_mv(1)
  763.         vert(pin(40,DN))
  764.         dn_mv(2) junction
  765.         {horz(gate(40).w); dn_mv(1); horz(gate(40).e); right_mv(1)}
  766.         dn_mv(1) junction
  767.         zig(pin(49,UP))
  768. # Gate 41
  769. # (should be right_mv(2) but we've squeezed the bus line a bit left)
  770. go(pin(41,OUT)) right_mv(1) vert(pin(41,DN)) ground
  771. # Gate 42
  772. go(pin(42,OUT)) to_bus
  773. # Gate 43
  774. go(pin(43,OUT)) to_bus
  775. # Gate 44
  776. go(pin(44,OUT)) to_bus
  777. # Gate 45
  778. go(pin(45,OUT)) to_bus
  779. # Gate 46
  780. go(pin(46,OUT)) to_bus
  781. # Gate 47
  782. go(pin(47,OUT)) to_bus
  783. # Gate 48
  784. go(pin(48,OUT)) to_bus
  785. # Gate 49
  786. go(pin(49,OUT)) to_bus
  787. # Gate 50
  788. go(pin(50,OUT)) to_bus
  789. # The adventitious lead
  790. go(pin(17,OUT)) right_mv(1)
  791.         {vert(pin(17,UP)) up_mv(3) horz(gate(17))}
  792.         vert(pin(17,DN)) dn_mv(1)
  793.         horz(gate(27).w) dn_mv(1) horz(gate(27).e)
  794.         dn_mv(1) horz(gate(36).w) 
  795.         up_mv(2) right_mv(1) dn_mv(2)
  796.         right_mv(1) up_mv(2) right_mv(1) dn_mv(2)
  797.         right_mv(1) up_mv(2) right_mv(1) 
  798.         vert(pin(37,DN)) right_mv(4) dn_mv(2) 
  799.         right_mv(3) dn_mv(1) left_mv(3)
  800.         vert(pin(46,DN)) left_mv(3) dn_mv(3)
  801.         horz(gate(36).w) up_mv(1) horz(gate(36)) right_mv(1) 
  802.  
  803. ] # End of diagram object
  804. .PE
  805. .ce 1
  806. FIGURE 1. CIRCUITOUS DIAGRAM
  807. .bp
  808. .sp 10
  809. .ps 8
  810. .vs 10
  811. .nf
  812. .cs R 24
  813. .ec %
  814. .ds EO %(ci%v'-0.08'%h'-0.67'+%v'0.08'
  815. .%" This is dodgy, but it's the last place es is used
  816. .if n .ds es %o"O|"
  817. .if t .ds es %(es
  818.    __________________________________________________________
  819.   |\                                                         \
  820.   | \ 1. Logic gate.  Inputs A, B.  Output O = AB.            \
  821.   |  \                                                         \
  822.   | \ \ 2. Logic gate.  Inputs A, B, C.  Output O = A+BC.       \
  823.   | |\ \                                                         \
  824.   | | \ \ 3. Logic gate.  Inputs A, B.  Output O = A+AB.          \
  825.   | |  \ \                                                         \
  826.   | |  |\ \ 4. Logic gate.  Inputs A, B.  Output O = AB %*(EO -(A+-B)   \
  827.   | |  | \ \                                                         \
  828.   | |  |  \ \ 5. Logic gate.  Inputs A, B.  Output O = A%*(EOA + AA       \
  829.   | |  |   \ \                                                         \
  830.   | |  |    \ \ 6. Uninitialized flip-flop.  Inputs none.  Output O = ? \
  831.   | |  |     \ \                                                         \
  832.   | |  |      \ \ 7. Flip-flop-flap.  Inputs A, B, C.  Output O = 1 if    \
  833.   | |  |       \ \    A=0 or B+C=0 and A=1.  O = 0 if AC=1, B=0.  O = %*(es if \
  834.   | |  |        \ \    AB=1, C=0.  O = ? if ABC=1.  O as yet undetermined   \
  835.   | |  |         \ \    for other Warmenhovian inputs.  See Figure 2.        \
  836.   | |  |          \ \                                                         \
  837.   | |  |           \ \ 8. Bus line.                                            \
  838.   | |  |            \ \_________________________________________________________\
  839.   | |  |             \ |                                                         |
  840.   | |  |             | |  _____________________________________________________  |
  841.   | |  |             | |  |                              | |  |             | |  |
  842.   | |  |             | |  |                              | |  |             | |  |
  843.   | |  |             | |  |                              | |  |             | |  |
  844.   | |  |             | |  |                              | |  |             | |  |
  845.   | |  |             | |  |                              | |  |             | |  |
  846.    \|__|             | |  |                               \|__|             | |  |
  847.                      | |  |                                                 | |  |
  848.                      | |  |                                                 | |  |
  849.                      | |  |                                                 | |  |
  850.                      | |  |                                                 | |  |
  851.                      | |  |                                                 | |  |
  852.                      | |  |                                                 | |  |
  853.                      | |  |                                                 | |  |
  854.                      | |  |                                                 | |  |
  855.                      | |  |                                                 | |  |
  856.                      | |  |                                                 | |  |
  857.                      | |  |                                                 | |  |
  858.                      | |  |                                                 | |  |
  859.                      | |  |                                                 | |  |
  860.                      | |  |                                                 | |  |
  861.                      | |  |                                                 | |  |
  862.                      | |  |                                                 | |  |
  863.                      | |  |                                                 | |  |
  864.                      | |  |                                                 | |  |
  865.                       \|__|                                                  \|__|
  866. .ec \
  867. .cs R
  868. .fi
  869. .ps 10
  870. .vs 12
  871. .sp
  872. .ce 1
  873. Table 1.  Logical (and other) functions.
  874. .bp
  875. .if n \{\
  876. .P
  877. [Warning: The following picture will be garbled or missing.
  878. Get a better output device.] \}
  879. .sp 10
  880. .PS
  881. # The FLIP FLAP FLOP, Figure 2 of the INTERCAL manual
  882. down;
  883. A: warmengate();
  884. move; move;
  885. B: warmengate();
  886. move; move;
  887. C: warmengate();
  888. move; move;
  889. D: warmengate();
  890. dot at 1st [];
  891. dot at 2nd [];
  892. dot at 3rd [];
  893. circle rad 0.06 at last [];
  894. line from last circle.w to last circle.e;
  895. line from last circle.n to last circle.s;
  896. line left 3 from A.UP; "A" rjust
  897. line left 3 from B.IN; "B" rjust
  898. line left 3 from C.UP; "C" rjust
  899. line left 2 from C.IN then down 2 then left; "1" rjust
  900. right; circle rad 0.06 with .w at A.OUT; 
  901. line right 0.5; junction {line right 1.5; "D" ljust}
  902. line down 0.25; X1: Here
  903. line left 0.5 from A.IN; line down 0.25; X2: Here
  904. line left 0.5 from B.UP; line up 0.25; line to X1;
  905. line right 1.0 from D.OUT; vert(B.UP) line up 0.25; line to X2;
  906. right; circle rad 0.06 with .w at B.OUT; 
  907. line right 0.5; vert(C.DN) line down 0.25; X3: Here;
  908. line left 0.25 from D.UP then up 0.25 then to X3;
  909. right; circle rad 0.06 with .w at C.OUT; 
  910. line right 0.3; vert(C.DN) line down 0.25; X4: Here
  911. line left 0.5 from D.IN; vert(D.UP) line up 0.25 then to X4;
  912. .PE
  913. .sp 10
  914. .ce 1
  915. FIGURE 2. FLIP FLAP FLOP
  916. .bp
  917. .if n \{\
  918. .P
  919. [Warning: The following picture will be garbled or missing.
  920. Get a better output device.] \}
  921. .PS
  922. [
  923.         NYC: box ht 4 wid 0.5 "9";
  924.         for i = 0 to 16 do {
  925.                 move to (i+1)/18 <NYC.nw,NYC.sw>
  926.                 line left 0.5
  927.         }
  928.         for i = 0 to 8 do {
  929.                 move to (i+1)/10 <NYC.ne,NYC.se>
  930.                 line right 0.5
  931.         }
  932. ]
  933. move right from last [].w;
  934. box invis wid 6 \
  935.       "GATE TYPE 9.  BLACK BOX" ljust \
  936.       "INPUTS A1-8,  B1-8.    " ljust \
  937.       "OUTPUT D1-8 = A1-8~B1=8" ljust
  938. .PE
  939. .sp 10
  940. .ce 1
  941. FIGURE 1  (CONTINUED).  NEW YORK
  942. .bp
  943. .H 3 "Unary Operators"
  944. .P
  945. The unary operators are & (logical \fBAND\fR), V (logical \fBOR\fR),
  946. and \*(vb (logical
  947. \fBXOR\fR). This last character is obtained by overpunching a worm (\-) on a V
  948. (V).
  949. .if '\*c'y' \{\
  950. (In C-INTERCAL'S ASCII environment, EBCDIC \*(vb is replaced by the
  951. what (?). The compiler recognizes -<backspace>V as a valid
  952. equivalent, in case you are concerned about compatibility with the 
  953. Princeton compiler.) \}
  954. The operator is inserted between the spot, two-spot, mesh, or
  955. what-have-you, and the integer, thus: .&123, #\*(vb123. Multiple unary
  956. operators may not be concatenated, thus the form #\*(vb&123 is invalid. This
  957. will be covered later when precedence is discussed. These operators perform
  958. their respective logical operations on all pairs of adjacent bits, the
  959. result from the first and last bits going into the first bit of the result.
  960. The effect is that of rotating the operand one place to the right and
  961. ANDing, ORing, or XORing with its initial value. Thus, #&77 (binary =
  962. 1001101) is binary 0000000000000100 = 4, #V77 is binary 1000000001101111 =
  963. 32879, and #\*(vb77 is binary 1000000001101011 = 32875.
  964. .H 3 "Precedence"
  965. .SETR precedence
  966. .P
  967. Precedence of operators is as follows:
  968. .sp 10
  969. (The remainder of this page intentionally left blank)\*F
  970. .FS
  971. Keep in mind that the aim in designing INTERCAL was to have no 
  972. precedents.
  973. .FE
  974. .bp
  975. .P
  976. This precedence (or lack thereof) may be overruled by grouping expressions
  977. between pairs of sparks (') or rabbit-ears ("). Thus '#165\*(ct#203'~#358 
  978. (binary value '10100101\*(ct11001011'~101100110) has the value 15, but
  979. #165\*(ct'#203~#358' has the value 34915, and #165\*(ct#203~#358 is invalid
  980. syntax and is completely valueless (except perhaps as an educational tool
  981. to the programmer). A unary operator is applied to a sparked or rabbit-eared
  982. expression by inserting the operator immediately following the opening spark
  983. or ears. Thus, the invalid expression #\*(vb&123,
  984. which was described earlier,
  985. could be coded as '\*(vb#&123' or '\*(vb"{"'.
  986. Note: In the interests of 
  987. simplifying the sometimes overly-complex form of expressions, INTERCAL allows
  988. a spark-spot combination ('.) to be replaced with a wow (!). Thus '.1~.2'
  989. is equivalent to !1~.2', and 'V.1\*(ct.2' is equivalent to "V!1\*(ct.2'".
  990. .P
  991. Combining a rabbit-ears with a spot to form a rabbit (\o'".') is not permitted,
  992. although the programmer is free to use it should he find an EBCDIC reader
  993. which will properly translate a 12-3-7-8 punch.
  994. .P
  995. Sparks and/or rabbit-ears must also be used to distinguish among such
  996. otherwise ambiguous subscripted and multiply-subscripted expressions as:
  997. .DS L
  998.         ,1 SUB #1 ~ #2
  999.         ,1 SUB ,2 SUB #1 #2 #3
  1000.         ,1 SUB " ,2 SUB " ,3 SUB #1 " #2 " " #3 "
  1001. .DE
  1002. The third case may be isolated into either of its possible interpretations
  1003. by simply changing some pairs of rabbit-ears to sparks, instead of adding
  1004. more ears (which would only confuse the issue further). Ambiguous cases are
  1005. defined as those for which the compiler being used finds a legitimate
  1006. interpretation which is different from that which the user had in mind. See
  1007. also section 
  1008. .GETHN princeton
  1009. \&.
  1010. .H 1 "STATEMENTS"
  1011. .P
  1012. In this section is described the format of INTERCAL statements.
  1013. .H 2 "General Format"
  1014. .P
  1015. Statements may be entered in 'free format'. That is, more than one statement
  1016. may occur on a single card, and a statement may begin on one card and end
  1017. on a later one. Note that if this is done, all intervening cards and portions
  1018. thereof must be part of the same statement. That this restriction is necessary
  1019. is immediately apparent from the following example of what might occur if
  1020. statements could be interlaced.
  1021. .DS L
  1022.         DO .1 <- ".1\*(ct'&:51~"#\*(vb1c!12~;&75SUB"\*(vb'V.1~
  1023.         DO .2 <- '"!1\*(ct"&';\*(vb79SUB",&7SUB:173"'~!\*(vb9\*(ct
  1024.         .2'\*(ct,&1SUB:5~#33578"'"'"~'#65535\*(ct"\*(vb'V#&85'"'
  1025.         #8196'"'~.1"\*(ct.2'~'#&5\*(ct"'#1279\*(ct#4351'~#65535"'
  1026. .DE
  1027. The above statements are obviously meaningless. (For that matter, so are
  1028. the statements
  1029. .DS L
  1030.         DO .1 <- ".1\*(ct"&:51~"#\*(vb1\*(ct!12~;&75SUB"\*(vb'V.1~
  1031.         .2'\*(ct,&1SUB:5~#333578"'"'"~#65535\*(ct"\*(vb'V#&85'"'
  1032.         DO .2 <- '"!1\*(ct"&';\*(vb79SUB",&7SUB:173"'~!\*(vb9\*(ct
  1033.         #8196'"'~.1"\*(ct.2'~'#&5\*(ct"'#1279\*(ct#4351'~#65535"'
  1034. .DE
  1035. but this is not of interest here.)
  1036. .P
  1037. Spaces may be used freely to enhance program legibility (or at least reduce
  1038. program illegibility), with the restriction that no word of a statement
  1039. identifier (see section
  1040. .GETHN identifiers
  1041. ) may contain any spaces.
  1042. .H 2 "Labels"
  1043. .P
  1044. A statement may begin with a
  1045. .B "logical line label"
  1046. enclosed in wax-wane pairs
  1047. (()). A statement may not have more than one label, although it is possible
  1048. to omit the label entirely. A line label is any integer from 1 to 65535,
  1049. which must be unique within each program. The user is cautioned, however,
  1050. that many line labels between 1000 and 1999 are used in the INTERCAL System
  1051. Library functions.
  1052. .H 2 "Identifiers and Qualifiers"
  1053. .SETR identifiers
  1054. .P
  1055. After the line label (if any), must follow one of the following statement
  1056. identifiers: DO, PLEASE, or PLEASE DO. These may be used interchangeably to
  1057. improve the aesthetics of the program. The identifier is then followed by
  1058. either, neither, or both of the following optional parameters (qualifiers):
  1059. (1) either of the character strings NOT or N'T, which causes the statement
  1060. to be automatically abstained from (see section
  1061. .GETHN abstain
  1062. ) when execution
  1063. begins, and (2) a number between 0 and 100, preceded by a double-oh-seven
  1064. (%), which causes the statement to have only the specified percent chance
  1065. of being executed each time it is encountered in the course of execution.
  1066. .H 2 "Statements"
  1067. .P
  1068. Following the qualifiers (or, if none are used, the identifier) must occur
  1069. one of the 13 valid operations. (Exception: see section 
  1070. .GETHN comments
  1071. \&.) These are 
  1072. described individually in sections 
  1073. .GETHN calculate
  1074.  through 
  1075. .GETHN last_statement
  1076. \&.
  1077. .H 3 "Calculate"
  1078. .SETR calculate
  1079. .P
  1080. The INTERCAL equivalent of the half-mesh (=) in FORTRAN, BASIC, PL/I, and
  1081. others, is represented by an angle (<) followed by a worm (-). This
  1082. combination is read 'gets'. 32-bit variables may be assigned 16-bit values,
  1083. which are padded on the left with 16 zero bits. 16-bit variables may be
  1084. assigned 32-bit values only if the value is less than 65535. Thus, to
  1085. invert the least significant bit of the first element of 16-bit
  1086. 2-dimensional array number 1, one could write:
  1087. .DS
  1088. ,1SUB#1#1 <- '\*(vb,1SUB#1#1\*(ct#1'~'#0\*(ct#65535'
  1089. .DE
  1090. Similarly to SNOBOL and SPITBOL, INTERCAL uses the angle-worm to define the
  1091. dimensions of arrays. An example will probably best describe the format. 
  1092. To define 32-bit array number 7 as 3-dimensional, the first dimension being
  1093. seven, the second being the current value of 16-bit variable number seven,
  1094. and the third being the current value of the seventh element of 16-bit array
  1095. number seven (which is one-dimensional) mingled with the last three bits of
  1096. 32-bit variable number seven, one would write (just before they came to take
  1097. him away):
  1098. .DS 
  1099. ;7 <- #7 BY .7 BY ",7SUB#7"\*(ct':7~#7'
  1100. .DE
  1101. This is, of course, different from the statement:
  1102. .DS
  1103. ;7 <- #7 BY .7 BY ,7SUB"#7\*(ct':7~#7'"
  1104. .DE
  1105. INTERCAL also permits the redefining of array dimensioning, which is done 
  1106. the same way as is the initial dimensioning. All values of items in an array
  1107. are lost upon redimensioning, unless they have been STASHed (see section
  1108. .GETHN stash
  1109. ), in which case restoring them also restores the old dimensions.
  1110. .H 3 "NEXT"
  1111. .SETR next
  1112. .P
  1113. The NEXT statement is used both for subroutine calls and for unconditional
  1114. transfers. This statement takes the form:
  1115. .DS
  1116. DO (label) NEXT
  1117. .DE
  1118. (or, of course,
  1119. .DS
  1120. PLEASE DO (label) NEXT
  1121. .DE
  1122. etc.), where (label) represents any logical line label which appears in the
  1123. program. The effect of such a statement is to transfer control to the
  1124. statement specified, and to store in a push down list (which is initially
  1125. empty) the location from which the transfer takes place. Items may be
  1126. removed from this list and may be discarded or used to return to the
  1127. statement immediately following the NEXT statement. These operations are
  1128. described in sections 
  1129. .GETHN forget
  1130.  and
  1131. .GETHN resume
  1132.  respectively. The programmer is
  1133. generally advised to discard any stack entries which he does not intend to
  1134. utilize, since the stack has a maximum depth of 79 entries. A program's
  1135. attempting to initiate an 80th level of NEXTing will result in the fatal
  1136. error message, "PROGRAM HAS DISAPPEARED INTO THE BLACK LAGOON."
  1137. .H 3 "FORGET"
  1138. .SETR forget
  1139. .P
  1140. The statement PLEASE FORGET exp, where exp represents any expression
  1141. (except colloquial and facial expressions), causes the expression to be
  1142. evaluated, and the specified number of entries to be removed from the
  1143. NEXTing stack and discarded. An attempt to FORGET more levels of NEXTing
  1144. than are currently stacked will cause the stack to be emptied, and no error
  1145. condition is indicated. This is because the condition is not considered to
  1146. be an error. As described in section
  1147. .GETHN next
  1148. \&, it is good programming practice
  1149. to execute a DO FORGET #1 after using a NEXT statement as an unconditional
  1150. transfer, so that the stack does not get cluttered up with unused entries:
  1151. .DS L
  1152. .cs R 24
  1153.         DO (123) NEXT
  1154.         .
  1155.         .
  1156.   (123) DO FORGET #1
  1157. .cs R
  1158. .DE
  1159. .H 3 "RESUME"
  1160. .SETR resume
  1161. .P
  1162. The statement PLEASE RESUME exp has the same effect as FORGET, except that
  1163. program control is returned to the statement immediately following the NEXT
  1164. statement which stored in the stack the last entry to be removed. Note that
  1165. a rough equivalent of the FORTRAN computed GO TO and BASIC ON exp GO TO is
  1166. performed by a sequence of the form:
  1167. .DS L
  1168. .cs R 24
  1169.         DO (1) NEXT
  1170.         .
  1171.         .
  1172.     (1) DO (2) NEXT
  1173.         PLEASE FORGET #1
  1174.         .
  1175.         .
  1176.     (2) DO RESUME .1
  1177. .cs R
  1178. .DE
  1179. Unlike the FORGET statement, an attempt to RESUME more levels of NEXTing than
  1180. been stacked will cause program termination. See also section 
  1181. .GETHN give_up
  1182. \&.
  1183. .H 3 "STASH"
  1184. .SETR stash
  1185. .P
  1186. Since subroutines are not explicitly implemented in INTERCAL, the NEXT and
  1187. RESUME statements must be used to execute common routines. However, as
  1188. these routines might use the same variables as the main program, it is
  1189. necessary for them to save the values of any variables whose values they
  1190. alter, and later restore them. This process is simplified by the STASH
  1191. statement, which has the form DO STASH list, where list represents a
  1192. string of one or more variable or array names, separated by intersections
  1193. (+). Thus
  1194. .DS
  1195. PLEASE STASH .123+:123+,123
  1196. .DE
  1197. stashes the values of two variables and one entire array. The values are
  1198. left intact, and copies thereof are saved for later retrieval by (what else?)
  1199. the RETRIEVE statement (see section 
  1200. .GETHN retrieve
  1201. ). It is not possible to STASH
  1202. single array items.
  1203. .H 3 "RETRIEVE"
  1204. .SETR retrieve
  1205. .P
  1206. PLEASE RETRIEVE list restores the previously STASHed values of the variables
  1207. and arrays named in the list. If a value has been stashed more than once,
  1208. the most recently STASHed values are RETRIEVEd, and a second RETRIEVE will
  1209. restore the second most recent values STASHed. Attempting to RETRIEVE a
  1210. value which has not been STASHed will result in the error message, "THROW
  1211. STICK BEFORE RETRIEVING."
  1212. .H 3 "IGNORE"
  1213. .SETR ignore
  1214. .P
  1215. The statement DO IGNORE list causes all subsequent statements to have no 
  1216. effect upon variables and/or arrays named in the list. Thus, for example, 
  1217. after the sequence
  1218. .DS L
  1219.         DO .1 <- #1
  1220.         PLEASE IGNORE .1
  1221.         DO .1 <- #0
  1222. .DE
  1223. 16-bit variable number 1 would have the value 1, not 0. Inputting (see
  1224. section 
  1225. .GETHN input
  1226. ) into an IGNOREd variable also has no effect. The condition
  1227. is annulled via the REMEMBER statement (see section
  1228. .GETHN remember
  1229. ). Note that, when
  1230. a variable is being IGNOREd, its value, though immutable, is still
  1231. available for use in expressions and the like.
  1232. .if '\*c'y' \{\
  1233. .P
  1234. Though the INTERCAL-72 manual laid down that the value of an IGNOREd
  1235. variable cannot change, it was unclear about whether or not a
  1236. statement which appears to change an IGNOREd variable is executed or
  1237. not.  This may appear to be a "If a tree falls in the forest..." type
  1238. of question, but if the statement in question has other side effects
  1239. it is not.
  1240. .P
  1241. Since another mechanism already exists for ABSTAINing from a
  1242. statement, C-INTERCAL's IGNORE only prevents the changing of the
  1243. specific variable in question, not the execution of the entire
  1244. statement.  In the present version of the language this only makes
  1245. a difference for the WRITE IN statement.  Attempting to WRITE IN
  1246. to an IGNOREd variable will cause a number to be read from the input,
  1247. which will be discarded since it cannot be stored in the variable. \}
  1248. .H 3 "REMEMBER"
  1249. .SETR remember
  1250. .P
  1251. PLEASE REMEMBER list terminates the effect of the IGNORE statement for all
  1252. variables and/or arrays named in the list. It does not matter if a variable
  1253. has been IGNOREd more than once, nor is it an error if the variable has not
  1254. been IGNOREd at all.
  1255. .H 3 "ABSTAIN"
  1256. .SETR abstain
  1257. .P
  1258. INTERCAL contains no simple equivalent to an IF statement or computed GO
  1259. TO, making it difficult to combine similar sections of code into a single
  1260. routine which occasionally skips around certain statements. The IGNORE
  1261. statement (see section 
  1262. .GETHN ignore
  1263. ) is helpful in some cases, but a more viable
  1264. method is often required. In keeping with the goal of INTERCAL having
  1265. nothing in common with any other language, this is made possible via the
  1266. ABSTAIN statement.
  1267. .P
  1268. This statement takes on one of two forms. It may not take on both at any one
  1269. time. DO ABSTAIN FROM (label) causes the statement whose logical line label
  1270. is (label) to be abstained from. PLEASE ABSTAIN FROM gerund list causes all
  1271. statements of the specified type(s) to be abstained from, as in
  1272. .DS L
  1273.         PLEASE ABSTAIN FROM STASHING
  1274.         PLEASE ABSTAIN FROM IGNORING + FORGETTING
  1275.         PLEASE ABSTAIN FROM NEXTING
  1276.      or PLEASE ABSTAIN FROM CALCULATING
  1277. .DE
  1278. Statements may also be automatically abstained from at the start of
  1279. execution via the NOT or N'T parameter (see section 
  1280. .GETHN identifiers
  1281. ).
  1282. .P
  1283. If, in the course of execution, a statement is encountered which is being
  1284. abstained from, it is ignored and control passes to the next statement in
  1285. the program (unless it, too, is being abstained from).
  1286. .P
  1287. The statement DO ABSTAIN FROM ABSTAINING is perfectly valid, as is DO ABSTAIN
  1288. FROM REINSTATING (although this latter is not usually recommended). However,
  1289. the statement DO ABSTAIN FROM GIVING UP is not accepted, even though DON'T
  1290. GIVE UP is.
  1291. .H 3 "REINSTATE"
  1292. .SETR reinstate
  1293. .P
  1294. The REINSTATE statement, like the ABSTAIN, takes as an argument either a 
  1295. line label or a gerund list. No other form of argument is permitted. For
  1296. example, the following is an invalid argument:
  1297. .DS L
  1298.         Given: x\(!=0, y\(!=0,  Prove: x+y=0
  1299.         Since x\(!=0, then x+1\(!=1, x+a\(!=a, x+y\(!=y.
  1300.         But what is y? y is anything but 0.
  1301.         Thus x+y \(!= anything but 0.
  1302.         Since x+y cannot equal anything but 0, x+y=0.
  1303.                                                          Q.E.D.
  1304. .DE
  1305. REINSTATEment nullifies the effects of an abstention. Either form of
  1306. REINSTATEment can be used to "free" a statement, regardless of whether the
  1307. statement was abstained from by gerund list, line label, or NOT. Thus,
  1308. PLEASE REINSTATE REINSTATING is not necessarily an irrelevant statement,
  1309. since it might free a DON'T REINSTATE command or a REINSTATE the line label
  1310. of which was abstained from. However, DO REINSTATE GIVING UP is invalid,
  1311. and attempting to REINSTATE a GIVE UP statement by line label will have no
  1312. effect. Note that this insures that DON'T GIVE UP will always be a
  1313. "do-nothing" statement.
  1314. .H 3 "GIVE UP"
  1315. .SETR give_up
  1316. .P
  1317. PLEASE GIVE UP is used to exit from a program. It has the effect of a PLEASE
  1318. RESUME #80. DON'T GIVE UP, as noted in section 
  1319. .GETHN reinstate
  1320. \&, is effectively a null
  1321. statement.
  1322. .H 3 "Input"
  1323. .SETR input
  1324. .P
  1325. Input is accomplished with the statement DO WRITE IN list, where list
  1326. represents a string of variables and/or elements or arrays, separated by
  1327. intersections. Numbers are represented on cards, each number on a separate
  1328. card, by spelling out each digit (in English) and separating the digits
  1329. with one or more spaces. A zero (0) may be spelled as either ZERO or OH.
  1330. Thus the range of (32-bit) input values permissible extends from ZERO (or
  1331. OH) through FOUR TWO NINE FOUR NINE SIX SEVEN TWO NINE FIVE.
  1332. .if '\*c'y' \{\
  1333. (For the convenience of aviators, C-INTERCAL accepts the spelling
  1334. NINER for NINE.  In the service of internationalization, C-INTERCAL
  1335. also accepts input digits in Sanskrit, Basque, Tagalog, Classical
  1336. Nahuatl, Georgian, Kwakiutl, and Volapuk. \}
  1337. .P
  1338. Attempting to write in a value greater than or equal to SIX FIVE FIVE THREE
  1339. SIX for a 16-bit variable will result in the error message, "DON'T BYTE OFF
  1340. MORE THAN YOU CAN CHEW."
  1341. .H 3 "Output"
  1342. .P
  1343. Values may be output to the printer, one value per line, via the statement
  1344. DO READ OUT list, where the list contains variables, array elements, and/or
  1345. constants.  Output is in the form of "extended" Roman numerals (also called
  1346. "butchered" Roman numerals), with an overline
  1347. .if t (\(rn)
  1348. indicating the value below
  1349. is "times 1000", and lower-case letters indicating "times 1000000". Zero
  1350. is indicated by an overline with no character underneath. Thus, the range 
  1351. of (32-bit) output values possible is from 
  1352. .if t \(rn
  1353. .if n \{\
  1354. .nf
  1355. _
  1356.  
  1357. .fi \}
  1358. through
  1359. .ie t \o"i\(rn"\o"v\(rn"ccxciv\o"C\(rn"\o"M\(rn"\o"L\(rn"\o"X\(rn"\o"V\(rn"\o"I\(rn"\o"I\(rn"CCXCV.
  1360. .el \{\
  1361. .br
  1362. .nf
  1363. __      ____________
  1364. ivccxcivCMLXVIICCXCV.
  1365. .fi \}
  1366. Note: For values whose residues modulo 1000000 are less than 4000, M is
  1367. used to represent 1000; for values whose residues are 4000 or greater,
  1368. .if t \o"I\(rn"
  1369. .if n \{\
  1370. .nf
  1371. _
  1372. I
  1373. .fi \}
  1374. .\" This is the one place we corrected the original manual.
  1375. is used. Thus #3999 would read out as MMMCMXCIX \*F while #4000 would
  1376. .FS
  1377. The original INTERCAL-72 manual claimed
  1378. that #3999 should render as MMMIM, but the C-INTERCAL developers have
  1379. been unable to find an algorithm that does this and is consistent
  1380. with the rest of the rules.
  1381. .FE
  1382. readout as
  1383. .if t \o"I\(rn"\o"V\(rn".
  1384. .if n \{\
  1385. .nf
  1386. __
  1387. IV
  1388. .fi \}
  1389. Similar rules apply to the use of
  1390. .if t \o"M\(rn"
  1391. .if n \{\
  1392. .nf
  1393. _
  1394. M
  1395. .fi \}
  1396. and i for 1000000, and to that of m and
  1397. .if t \o"i\(rn"
  1398. .if n \{\
  1399. .nf
  1400. _
  1401. i
  1402. .fi \}
  1403. for 1000000000.
  1404. .if '\*c'y' \{\
  1405. .H 3 "COME FROM"
  1406. .P
  1407. In which we try to precisely define a statement that should never
  1408. have been born, but is nevertheless one of the more useful statements
  1409. in INTERCAL.
  1410. .H 4 "Background"
  1411. .P
  1412. The earliest known description of the COME FROM statement in the computing
  1413. literature is in [R. L. Clark, "A linguistic contribution to GOTO-less
  1414. programming," Commun. ACM 27 (1984), pp. 349--350], part of the famous April
  1415. Fools issue of CACM.  The subsequent rush by language designers to include the
  1416. statement in their languages was underwhelming, one might even say nonexistent.
  1417. It was therefore decided that COME FROM would be an appropriate addition
  1418. to C-INTERCAL.
  1419. .H 4 "Description"
  1420. .P
  1421. There are two useful ways to visualize the action of the COME FROM
  1422. statement.  The simpler is to see that it acts like a GOTO when the
  1423. program is traced backwards in time.  More precisely, the statements
  1424. .DS L
  1425. (1)     DO <any statement>
  1426.         .
  1427.         .
  1428.         .
  1429. (2)     DO COME FROM (1)
  1430. .DE
  1431. should be thought of as being equivalent to
  1432. .DS L
  1433. (1)     DO <any statement>
  1434. (2)     DO GOTO (3)
  1435.         .
  1436.         .
  1437.         .
  1438. (3)     DO NOTHING
  1439. .DE
  1440. if INTERCAL actually had a GOTO statement at all, which of course it
  1441. doesn't.
  1442. .P
  1443. What this boils down to is that the statement DO COME FROM (label),
  1444. anywhere in the program, places a kind of invisible trap door
  1445. immediately after statement (label).  Execution or abstention of that
  1446. statement is immediately followed by an unconditional jump to the
  1447. COME FROM, unless the (label)ed statement is an executed NEXT, in which
  1448. case the jump occurs if the program attempts to RESUME back to that
  1449. NEXT statement.  It is an error for more than one COME FROM to refer
  1450. to the same (label).
  1451. .P
  1452. Modification of the target statement by ABSTAIN or by the % qualifier
  1453. affects only that statement, not the subsequent jump.  Such
  1454. modifications to the COME FROM itself, however, do affect the jump.
  1455. Encountering the COME FROM statement itself, rather than its target,
  1456. has no effect. \}
  1457. .SETR last_statement
  1458. .H 2 "Comments"
  1459. .SETR comments
  1460. .P
  1461. Unrecognizable statements, as noted in section 
  1462. .GETHN error_messages
  1463. \&, are flagged with a splat
  1464. (*) during compilation, and are not considered fatal errors unless they
  1465. are encountered during execution, at which time the statement (as input at 
  1466. compilation time) is printed and execution is terminated. This allows for 
  1467. an interesting (and, by necessity, unique) means of including comments in 
  1468. an INTERCAL listing. For example, the statement:
  1469. .sp 1
  1470. *       PLEASE NOTE THAT THIS LINE HAS NO EFFECT
  1471. .P
  1472. will be ignored during execution due to the inclusion of the NOT qualifier.
  1473. User-supplied error messages are also easy to implement:
  1474. .sp 1
  1475. *       DO SOMETHING ABOUT OVERFLOW IN ;3
  1476. .P
  1477. as are certain simple conditional errors:
  1478. .DS L
  1479. .cs R 24
  1480. * (123) DON'T YOU REALIZE THIS STATEMENT SHOULD ONLY BE ENCOUNTERED
  1481.                 ONCE?
  1482.         PLEASE REINSTATE (123)
  1483. .cs R
  1484. .DE
  1485. This pair of statements will cause an error exit the second time they are
  1486. encountered. Caution!! The appearance of a statement identifier in an
  1487. intended comment will be taken as the beginning of a new statement. Thus,
  1488. the first example on the preceding page could not have been:
  1489. .sp 1
  1490. *       PLEASE NOTE THAT THIS LINE DOES NOTHING
  1491. .P
  1492. The third example, however, is valid, despite the appearance of two cases 
  1493. of D-space-O, since INTERCAL does not ignore extraneous spaces in statement
  1494. identifiers.
  1495. .if '\*c'y' \{\
  1496. .H 1 "OUTSIDE COMMUNICATION"
  1497. .P
  1498. In which we try to remedy the fact that, due to I/O limitations, INTERCAL
  1499. can not even in principle perform the same tasks as other languages.  It
  1500. is hoped that this addition will permit INTERCAL users to waste vast
  1501. quantities of computer time well into the 21st century.
  1502. .H 2 "Motivation"
  1503. .P
  1504. One of the goals of INTERCAL was to provide a language which, though
  1505. different from all other languages, is nevertheless theoretically
  1506. capable of all the same tasks.  INTERCAL-72 failed to
  1507. accomplish this because its I/O functions could not handle arbitrary
  1508. streams of bits, or even arbitrary sequences of characters.  A
  1509. language which can't even send its input directly to its output
  1510. can hardly be considered as capable as other languages.
  1511. .H 2 "Turing Text Model"
  1512. .P
  1513. To remedy this problem, character I/O is now provided in a form based
  1514. on the "Turing Text" model, originally proposed by Jon Blow.  The
  1515. C-INTERCAL programmer can access this capability by placing a one-
  1516. dimensional array in the list of items given to a WRITE IN or READ OUT
  1517. statement.  On execution of the statement, the elements of the array
  1518. will, from first to last, be either loaded from the input or sent
  1519. to the output, as appropriate, in the manner described below.  There
  1520. is currently no support for I/O involving higher-dimensional arrays,
  1521. but some form of graphics might be a possible 2-D interpretation.
  1522. .P
  1523. The heart of the Turing Text model is the idea of a continuous loop
  1524. of tape containing, in order, all the characters in the machine's
  1525. character set.  When a character is received by the input routine,
  1526. the tape is advanced the appropriate number of spaces to bring
  1527. that character under the tape head, and the number of spaces the
  1528. tape was moved is the number that is actually seen by the INTERCAL
  1529. program.  Another way to say this is that the number placed in an
  1530. INTERCAL array is the difference between the character just
  1531. received and the previous character, modulo the number of characters
  1532. in the machine character set.
  1533. .P
  1534. Output works in just the opposite fashion, except that the characters
  1535. being output come from the other side of the tape.  From this position
  1536. the characters on the tape appear to be in reverse order, and are
  1537. individually backwards as well.  (We would show you what it looks
  1538. like, but we don't have a font with backwards letters available.
  1539. Use your imagination.)  The effect is that a number is taken out
  1540. of an INTERCAL array, subtracted from the last character output---
  1541. i.e., the result of the last subtraction---and then sent on down
  1542. the output channel.  The only catch is that the character as seen
  1543. by the INTERCAL program is the mirror-image of the character as
  1544. seen by the machine and the user.  The bits of the character are
  1545. therefore taken in reverse order as it is sent to the output.
  1546. Note that this bit reversal affects only the character seen by
  1547. the outside world; it does not affect the character stored internally
  1548. by the program, from which the next output number will be subtracted.
  1549. All subtractions are done modulo the number of characters in the
  1550. character set.
  1551. .P
  1552. Two different tapes are used for input and for output to allow for
  1553. future expansion of the language to include multiple input and
  1554. output channels.  Both tapes start at character 0 when a program
  1555. begins execution.  On input, when an end of file marker is reached
  1556. the number placed in the array is one greater than the highest-
  1557. numbered character on the tape.
  1558. .H 2 "Example Program"
  1559. .P
  1560. If all this seems terribly complicated, it should be made perfectly
  1561. clear by the following example program, which simply maps its input
  1562. to its output (like a simplified UNIX "cat").  It assumes that
  1563. characters are 8 bits long, but that's fine since the current version
  1564. of C-INTERCAL does too.  It uses the standard library routines for addition
  1565. and subtraction.
  1566. .DS L
  1567.         DO ,1 <- #1
  1568.         DO .4 <- #0
  1569.         DO .5 <- #0
  1570.         DO COME FROM (30)
  1571.         DO WRITE IN ,1
  1572.         DO .1 <- ,1SUB#1
  1573.         DO (10) NEXT
  1574.         PLEASE GIVE UP
  1575. (20)    PLEASE RESUME '?.1$#256'~'#256$#256'
  1576. (10)    DO (20) NEXT
  1577.         DO FORGET #1
  1578.         DO .2 <- .4
  1579.         DO (1000) NEXT
  1580.         DO .4 <- .3~#255
  1581.         DO .3 <- !3~#15'$!3~#240'
  1582.         DO .3 <- !3~#15'$!3~#240'
  1583.         DO .2 <- !3~#15'$!3~#240'
  1584.         DO .1 <- .5
  1585.         DO (1010) NEXT
  1586.         DO .5 <- .2
  1587.         DO ,1SUB#1 <- .3
  1588. (30)    PLEASE READ OUT ,1
  1589. .DE
  1590. For each number received in the input array, the program first tests
  1591. the #256 bit to see if the end of file has been reached.  If not, the
  1592. previous input character is subtracted off to obtain the current
  1593. input character.  Then the order of the bits is reversed to find
  1594. out what character should be sent to the output, and the result
  1595. is subtracted from the last character sent.  Finally, the difference
  1596. is placed in an array and given to a READ OUT statement.  See?
  1597. We told you it was simple! \}
  1598. .if '\*c'y' \{\
  1599. .H 1 "TriINTERCAL"
  1600. .P
  1601. In which it is revealed that bitwise operations are too ordinary for
  1602. hard-core INTERCAL programmers, and extensions to other bases are
  1603. discussed.  These are not, strictly speaking, extensions to INTERCAL
  1604. itself, but rather new dialects sharing most of the features of the
  1605. parent language.
  1606. .H 2 "Motivation"
  1607. .P
  1608. INTERCAL is really a pretty sissy language.  It tries hard to be
  1609. different, but when you get right down to its roots, what do you find?
  1610. You find bits, that's what.  Plain old ones and zeroes, in groups of
  1611. 16 and 32, just like every other language you've ever heard of.  And
  1612. what operations can you perform on these bits?  The INTERCAL operators
  1613. may arrange and permute them in weird and wonderful ways, but at the
  1614. bit level the operators are the same AND, OR and XOR you've seen
  1615. countless times before.
  1616. .P
  1617. Once the prospective INTERCAL programmer masters the unusual syntax,
  1618. she finds herself working with the familiar Boolean operators on
  1619. perfectly ordinary unsigned integer words.  Even the constants she uses
  1620. are familiar.  After all, who would not immediately recognize #65535
  1621. and #32768?  It may take a just a moment more to figure out #65280,
  1622. and #21845 and #43690 could be puzzles until she notices that they
  1623. sum to #65535, but basically she's still on her home turf.  The 16-bit
  1624. limit on constants actually works in the programmer's favor by insuring
  1625. that very long anonymous constants can not appear in INTERCAL programs.
  1626. And this is in a language that is supposed to be different from any
  1627. other!
  1628. .H 2 "Abandon All Hope..."
  1629. .P
  1630. Standard INTERCAL is based on variables consisting of ordinary bits
  1631. and familiar Boolean operations on those bits.  In pursuit of uniqueness,
  1632. it seems appropriate to provide a new dialect, otherwise identical to
  1633. INTERCAL, which instead uses variables consisting of trits, i.e. ternary
  1634. digits, and operators based on tritwise logical operations.  This is
  1635. intended to be a separate dialect, rather than an extension to INTERCAL
  1636. itself, for a number of reasons.  Doing it this way avoids word-length
  1637. conflicts, does not spoil the elegance of the Spartan INTERCAL operator
  1638. set, and dodges the objections of those who might feel it too great an
  1639. alteration to the original language.  Primarily, though, giving INTERCAL
  1640. programmers the ability to switch numeric base at will amounts to
  1641. excessive functionality.  So much better that a programmer choose a base
  1642. at the outset and then be forced to stick with it for the remainder of
  1643. the program.
  1644. .H 2 "Compiler Operation"
  1645. .P
  1646. The same compiler, ick, supports both INTERCAL and TriINTERCAL.
  1647. This has the advantage that future bug fixes and additions to the
  1648. language not related to arithmetic immediately apply to both versions.
  1649. The compiler recognizes INTERCAL source files by the extension '.i',
  1650. and TriINTERCAL source files by the extension '.3i'.  It's as simple
  1651. as that.  There is no way to mix INTERCAL and TriINTERCAL source in
  1652. the same program, and it is not always possible to determine which
  1653. dialect a program is written in just by looking at the source code.
  1654. .H 2 "Data Types"
  1655. .P
  1656. The two TriINTERCAL data types are 10-trit unsigned integers and
  1657. 20-trit unsigned integers.  All INTERCAL syntax for distinguishing
  1658. data types is ported to these new types in the obvious way.  Small
  1659. words may contain numbers from #0 to #59048, large words may contain
  1660. numbers from #0$#0 to #59048$#59048.  Errors are signaled for constants
  1661. greater than #59048 and for attempts to WRITE IN numbers too large
  1662. for a given variable or array element to hold.
  1663. .P
  1664. Note that though TriINTERCAL considers all numbers to be unsigned,
  1665. nothing prevents the programmer from implementing arithmetic operations
  1666. that treat their operands as signed.  Three's complement is one obvious
  1667. choice, but balanced ternary notation is also a possibility.  This
  1668. latter is a very pretty and symmetrical system in which all 2 trits
  1669. are treated as if they had the value -1.
  1670. .H 2 "Operators"
  1671. .P
  1672. The TriINTERCAL operators are designed to inherit the relevant properties
  1673. of the standard INTERCAL operators, so that both can be considered as
  1674. merely different aspects of the same Platonic ideal.  (Not that the word
  1675. "ideal" is ever particularly relevant when used in connection with
  1676. INTERCAL.)
  1677. .H 3 "Binary Operators I"
  1678. .P
  1679. The binary operators carry over from the original language with only
  1680. minor changes.  The MINGLE operator ($) creates a 20-trit word by
  1681. alternating trits from its two 10-trit operands.  The SELECT operator (~)
  1682. is a little more complicated, since the ternary tritmask may contain 0, 1,
  1683. and 2 trits.  If we observe that the SELECT operation on binary operands
  1684. amounts to a bitwise AND and some rearrangement of bits, it seems
  1685. appropriate to base the SELECT for ternary operands on a tritwise AND in
  1686. the analogous fashion.  We therefore postpone the definition of SELECT
  1687. until we know what a tritwise AND looks like.
  1688. .H 3 "Unary Operators"
  1689. .P
  1690. The unary operators in INTERCAL are all derived from the familiar
  1691. Boolean operations on single bits.  To extend these operations to trits,
  1692. we first ask ourselves what the important properties of these operations
  1693. are that we wish to be preserved, then design the tritwise operators so
  1694. that they behave in a similar fashion.
  1695. .H 4 "Unary Logical Operators"
  1696. .P
  1697. Let's start with AND and OR.  To begin with, these can be considered
  1698. "choice" or "preference" operators, as they always return one of their
  1699. operands.  AND can be described as wanting to return 0, but returning 1
  1700. if it is given no other choice, i.e., if both operands are 1.  Similarly,
  1701. OR wants to return 1 but returns 0 if that is its only choice.  From
  1702. this it is immediately apparent that each operator has an identity
  1703. element that "always loses", and a dominator element that "always wins".
  1704. .P
  1705. AND and OR are commutative and associative, and each distributes
  1706. over the other.  They are also symmetric with each other, in the sense
  1707. that AND looks like OR and OR looks like AND when the roles of 0 and 1
  1708. are interchanged (De Morgan's Laws).  This symmetry property seems to be
  1709. a key element to the idea that these are logical, rather than arithmetic,
  1710. operators.  In a three-valued logic we would similarly expect a three-
  1711. way symmetry among the three values 0, 1 and 2 and the three operators
  1712. AND, OR and (of course) BUT.
  1713. .P
  1714. The following tritwise operations have all the desired properties:
  1715. OR returns the greater of its two operands.  That is, it returns 2 if
  1716. it can get it, else it tries to return 1, and it returns 0 only if both
  1717. operands are 0.  AND wants to return 0, will return 2 if it can't get
  1718. 0, and returns 1 only if forced.  BUT wants 1, will take 0, and tries
  1719. to avoid 2.  The equivalents to De Morgan's Laws apply to rotations
  1720. of the three elements, e.g., 0 -> 1, 1 -> 2, 2 -> 0.  Each operator
  1721. distributes over exactly one other operator, so the property
  1722. "X distributes over Y" is not transitive.  The question of which way
  1723. this distributivity ring goes around is left as an exercise for the
  1724. student.
  1725. .P
  1726. In TriINTERCAL programs the whirlpool (@) symbol denotes the unary
  1727. tritwise BUT operation.  You can think of the whirlpool as drawing
  1728. values preferentially towards the central value 1.  Alternatively,
  1729. you can think of it as drawing your soul and your sanity inexorably
  1730. down...
  1731. .P
  1732. On the other hand, maybe it's best you \fInot\fR think of it that way.
  1733. .P
  1734. A few comments about how these operators can be used.  OR acts like
  1735. a tritwise maximum operation.  AND can be used with tritmasks.  0's
  1736. in a mask wipe out the corresponding elements in the other operand,
  1737. while 1's let the corresponding elements pass through unchanged.  2's
  1738. in a mask consolidate the values of nonzero elements, as both 1's and
  1739. 2's in the other operand yield 2's in the output.  BUT can be used to
  1740. create "partial tritmasks".  0's in a mask let BUT eliminate 2's from
  1741. the other operand while leaving other values unchanged.  Of course,
  1742. the symmetry property guarantees that the operators don't really
  1743. behave differently from each other in any fundamental way; the apparent
  1744. differences come from the intuitive view that a 0 trit is "not set"
  1745. while a 1 or 2 trit is "set".
  1746. .H 4 "Binary Operators II"
  1747. .P
  1748. At this point we can define SELECT, since we now know what the
  1749. tritwise AND looks like.  SELECT takes the binary tritwise AND of
  1750. its two operands.  It shifts all the trits of the result corresponding
  1751. to 2's in the right operand over to the right (low) end of the result,
  1752. then follows them with all the output trits corresponding to 1's in
  1753. the right operand.  Trits corresponding to 0's in the right operand,
  1754. which are all 0 anyway, occupy the remaining space at the left end of
  1755. the output word.  Both 10-trit and 20-trit operands are accepted,
  1756. and are padded with zeroes on the left if necessary.  The output
  1757. type is determined the same way as in standard INTERCAL.
  1758. .H 4 "Unary Arithmetic Operators"
  1759. .P
  1760. Now that we've got all that settled, what about XOR?  This is
  1761. easily the most-useful of the three unary INTERCAL operators,
  1762. because it combines in one package the operations ADD WITHOUT CARRY,
  1763. SUBTRACT WITHOUT BORROW, BITWISE NOT-EQUAL, and BITWISE NOT.  In
  1764. TriINTERCAL we can't have all of these in the same operator, since
  1765. addition and subtraction are no longer the same thing.  The solution
  1766. is to split the XOR concept into two operators.  The ADD WITHOUT CARRY
  1767. operation is represented by the new sharkfin (^) symbol, while the
  1768. old what (?) symbol represents SUBTRACT WITHOUT BORROW.  The reason for
  1769. this choice is so that what (?) will also represent the TRITWISE NOT-EQUAL
  1770. operation.
  1771. .P
  1772. Note that what (?), unlike the other four unary operators, is not
  1773. symmetrical.  It should be thought of as rotating its operand one trit
  1774. to the right (with wraparound) and then subtracting off the trits of
  1775. the original number.  These subtractions are done without borrowing,
  1776. i.e., trit-by-trit modulo 3.
  1777. .H 3 "Examples"
  1778. .P
  1779. The TriINTERCAL operators really aren't all that bad once you get
  1780. used to them.  Let's look at a few examples to show how they can
  1781. be used in practice.  In all of these examples the input value is
  1782. contained in the 10-trit variable .3.
  1783. .P
  1784. In INTERCAL, single-bit values often have to be converted from
  1785. {0,1} to {1,2} for use in RESUME statements.  Examples of how to do
  1786. this appear in the original manual.  In TriINTERCAL the expression
  1787. "^.3$#1"~#1 sends 0 -> 1 and 1 -> 2.  If the 1-trit input value can
  1788. take on any of its three possible states, however, we will also have
  1789. to deal with the 2 case.  The expression "V.3$#1"~#1 sends {0,1} -> 1
  1790. and 2 -> 2.  To test if a trit is set, we can use "V'"&.3$#2"~#1'$#1"~#1,
  1791. sending 0 -> 1 and {1,2} -> 2.  To reverse the test we use
  1792. "?'"&.3$#2"~#1'$#1"~#1, sending 0 -> 2 and {1,2} -> 1.  Note that we
  1793. have not been taking full advantage of the new SELECT operator.  These
  1794. last two expressions can be simplified into "V!3~#2'$#1"~#1 and
  1795. "?!3~#2'$#1"~#1, which perform exactly the same mappings.  Finally, if
  1796. we need a 3-way test, we can use "@'"^.3$#7"~#4'$#2"~#10, which
  1797. obviously sends 0 -> 1, 1 -> 2, and 2 -> 3.
  1798. .P
  1799. For an unrelated example, the expression "^.3$.3"~"#0$#29524"
  1800. converts all of the 1-trits of .3 into 2's and all of the 2-trits
  1801. into 1's.  In balanced ternary, where 2-trits represent -1 values,
  1802. this is the negation operation.
  1803. .H 2 "Beyond Ternary..."
  1804. .P
  1805. While we're at it, we might as well extend this multiple bases
  1806. business a little farther.  The ick compiler actually recognizes
  1807. filename suffixes of the form '.Ni', where N is any number from 2
  1808. to 7.  2 of course gives standard INTERCAL, while 3 gives TriINTERCAL.
  1809. We cut off before 8 because octal notation is the smallest base used
  1810. to facilitate human-to-machine communication, and this seems quite
  1811. contrary to the basic principles behind INTERCAL.  The small data
  1812. types hold 16 bits, 10 trits, 8 quarts, 6 quints, 6 sexts, or 5 septs,
  1813. and the large types are always twice this size.
  1814. .P
  1815. As for operators, '?' is always SUBTRACT WITHOUT BORROW, and '^'
  1816. is always ADD WITHOUT CARRY.  'V' is the OR operation and always
  1817. returns the max of its inputs.  '&' is the AND operation, which chooses
  1818. 0 if possible but otherwise returns the max of the inputs.  '@' is BUT,
  1819. which prefers 1, then 0, then the max of the remaining possibilities.
  1820. Rather than add more special symbols forever, a numeric modifier may
  1821. be placed directly before the '@' symbol to indicate the operation
  1822. that prefers one of the digits not already represented.  Thus in files
  1823. ending in '.5i', the permitted unary operators are '?', '^', '&', '@',
  1824. \&'2@', '3@', and 'V'.  Use of such barbarisms as '0@' to represent '&'
  1825. are not permitted, nor is the use of '@' or '^' in files with either
  1826. of the extensions '.i' or '.2i'.  Why not?  You just can't, that's why.
  1827. Don't ask so many questions.
  1828. .P
  1829. As a closing example, we note that in balanced quinary notation,
  1830. where 3 means -2 and 4 means -1, the negation operation can be written
  1831. as either
  1832. .DS L
  1833.   DO .1 <- "^'"^.3$.3"~"#0$#3906"'$'"^.3$.3"~"#0$#3906"'"~"#0$#3906"
  1834. .DE
  1835. or as
  1836. .DS L
  1837.   DO .1 <- "^.3$.3"~"#0$#3906"
  1838.   DO .1 <- "^.1$.1"~"#0$#3906"
  1839. .DE
  1840. These work because multiplication by -1 is the same as multiplication
  1841. by 4, modulo 5.
  1842. .P
  1843. Now go beat your head against the wall for a while.\}
  1844. .H 1 "SUBROUTINE LIBRARY"
  1845. .SETR sublib
  1846. .P
  1847. INTERCAL provides several built-in subroutines to which control can be
  1848. transferred to perform various operations. These operations include many
  1849. useful functions which are not easily representable in INTERCAL, such as
  1850. addition, subtraction, etc.
  1851. .H 2 "Usage"
  1852. .P
  1853. In general, the operands are .1, .2, etc., or :1, :2, etc., and the result(s)
  1854. are stored in what would have been the next operand(s). For instance, one
  1855. routine adds .1 to .2 and store the sum in .3, with .4 being used to indicate
  1856. overflow. All variables not used for results are left unchanged.
  1857. .H 2 "Available Functions"
  1858. .SETR functions
  1859. .P
  1860. At the time of this writing, only the most fundamental operations are offered
  1861. in the library, as a more complete selection would require prohibitive time
  1862. and coree to implement. These functions, along with their corresponding entry
  1863. points (entered via DO (entry) NEXT) are listed below.
  1864. .DS L
  1865. .cs R 24
  1866.  (1000) .3 <- .1 plus .2, error exit on overflow
  1867.  (1009) .3 <- .1 plus .2
  1868.         .4 <- #1 if no overflow, else .4 <- #2
  1869.  (1010) .3 <- .1 minus .2, no action on overflow
  1870.  (1020) .1 <- .1 plus #1, no action on overflow
  1871.  (1030) .3 <- .1 times .2, error exit on overflow
  1872.  (1039) .3 <- .1 times .2
  1873.         .4 <- #1 if no overflow, else .4 <- #2
  1874.  (1040) .3 <- .1 divided by .2
  1875.         .3 <- #0 if .2 is #0
  1876.  (1050) .2 <- :1 divided by .1, error exit on overflow
  1877.         .2 <- #0 if .1 is #0
  1878. .if '\*c'y' \{\
  1879.  (1060) .3 <- logical or of .1 and .2 
  1880.  (1070) .3 <- logical and of .1 and .2
  1881.  (1080) .3 <- logical xor of .1 and .2 \}
  1882.  
  1883.  (1500) :3 <- :1 plus :2, error exit on overflow
  1884.  (1509) :3 <- :1 plus :2
  1885.         :4 <- #1 if no overflow, else :4 <- #2
  1886.  (1510) :3 <- :1 minus :2, no action on overflow
  1887.  (1520) :1 <- .1 concatenated with .2
  1888.  (1525) This subroutine is intended solely for internal
  1889.         use within the subroutine library and is therefore
  1890.         not described here. Its effect is to shift .3
  1891.         logically 8 bits to the left.
  1892.  (1530) :1 <- .1 times .2
  1893.  (1540) :3 <- :1 times :2, error exit on overflow
  1894.  (1549) :3 <- :1 times :2
  1895.         :4 <- #1 if no overflow, else :4 <- #2
  1896.  (1550) :3 <- :1 divided by :2
  1897.         :3 <- #0 if :2 is #0
  1898.  
  1899.  (1900) .1 <- uniform random no. from #0 to #65535
  1900.  (1910) .2 <- normal random no. from #0 to .1, with
  1901.               standard deviation .1 divided by #12
  1902. .cs R
  1903. .DE
  1904. .if '\*c'y' \{\
  1905. .H 2 "Automagical Inclusion Of The Subroutine Library"
  1906. .P
  1907. The C-INTERCAL compiler will automatically include the system library if a DO
  1908. (1xxx) NEXT statement is used, and if no (1xxx) labels are defined anywhere,
  1909. where (1xxx) is a label in the 1000-1999 range, inclusive.  This was not
  1910. an INTERCAL-72 feature. \}
  1911. .H 1 "PROGRAMMING HINTS"
  1912. .SETR proghints
  1913. .P
  1914. For the user looking to become more familiar with the INTERCAL language, we
  1915. present in this section an analysis of a complex program, as well as some
  1916. suggested projects for the ambitious programmer.
  1917. .P
  1918. Considering the effort involved in writing an INTERCAL program, it was 
  1919. decided in putting together this manual to use an already existing program 
  1920. for instructive analysis. Since there was only one such program available,
  1921. we have proceeded to use it. It is known as the "INTERCAL System Library."
  1922. .H 2 "Description"
  1923. .P
  1924. The program listing begins on the second page following. It is in the same
  1925. format as would be produced by the Princeton INTERCAL compiler in FORMAT
  1926. mode with WIDTH=62 (see section 
  1927. .GETHN princeton
  1928. ). For a description of the functions
  1929. performed by the Library, see section 
  1930. .GETHN functions
  1931. \&.
  1932. .H 2 "Analysis"
  1933. .P
  1934. We shall not attempt to discuss here the algorithms used, but rather we
  1935. shall point out some of the general techniques applicable to a wide range
  1936. of problems.
  1937. .P
  1938. Statements 10, 14, 15, and 26 make up a virtual "computed GO TO". When
  1939. statement 10 is executed, control passes eventually to statement 16 or 11,
  1940. depending on whether .5 contains #1 or #2, respectively. The value of .5
  1941. is determined in statement 9, which demonstrates another handy technique.
  1942. To turn an expression, exp, with value #0 or #1, into #1 or #2 (for use in
  1943. a "GO TO"), use "\*(vb'exp'\*(ct#1"~#3.
  1944. To reverse the condition (i.e., convert #0
  1945. to #2 and leave #1 alone) use "\*(vb'exp'\*(ct#2"~#3.
  1946. .P
  1947. Certain conditions are easily checked. For example, to test for zero,
  1948. select the value from itself and select the bottom bit (see statement 54).
  1949. To test for all bits being 1's, select the value from itself and select the
  1950. top bit (see statement 261). The test for greater than, performed in
  1951. statements 192 and 193 on 32-bit values, employs binary logical operations,
  1952. which are performed as follows:
  1953. .DS
  1954. \&'\*(vb.1\*(ct.2'~'#0\*(ct#65535'
  1955. .DE
  1956. for 16-bit values or, for 32-bit values:
  1957. .DS L
  1958.         "'\*(vb":1~'#65535\*(ct30'"\*(ct":2~'#65535\*(ct#0'"'~'#0
  1959.         \*(ct#65535'"\*(ct"'\*(vb":1~'#0\*(ct#65535'"\*(ct":2~'#0
  1960.         \*(ct#65535'"'~'#0\*(ct#65535'"
  1961. .DE
  1962. (The proofs are left as an exercise to the reader.)
  1963. .P
  1964. Testing for greater-than with 16-bit values is somewhat simpler and is done
  1965. with the pair of statements:
  1966. .DS L
  1967.         DO .C <- '\*(vb.Ac.B'~'#0\*(ct#65535'
  1968.         DO .C <- '&"'.A~.C'~'"\*(vb'\*(vb.C~.C'\*(ct#32768"
  1969.                 ~"#0\*(ct#65535"'"\*(ct".C~.C"'~#1
  1970. .DE
  1971. This sets .C (a dummy variable) to #1 if .A > .B, and #0 otherwise. The
  1972. expression may be expanded as described above to instead set .C to #1 or
  1973. #2.
  1974. .P
  1975. Note also in statement 220 the occurrence of ~"#65535\*(ct#65535". Although
  1976. these operations select the entire value, they are not extraneous, as they
  1977. ensure that the forthcoming \*(vbs will be operating on 32-bit values.
  1978. .P
  1979. In several virtual computed GO TOs the DO FORGET #1 (statement 15 in the
  1980. earlier example) has been omitted, since the next transfer of control would
  1981. be a DO RESUME #1.  By making this a DO RESUME #2 instead, the FORGET may
  1982. be forgotten.
  1983. .P
  1984. In statement 64, note that .2 is STASHed twice by a single statement. This
  1985. is perfectly legal.
  1986. .P
  1987. Lastly, note in statements 243 and 214 respectively, expressions for
  1988. shifting 16- and 32-bit variables logically one place to the left.
  1989. Statement 231 demonstrates right-shifting for 32-bit variables.
  1990. .bp
  1991. .H 2 "Program Listing"
  1992. .DS L
  1993. .cs R 24
  1994.     1   (1000)  PLEASE IGNORE .4
  1995.     2           PLEASE ABSTAIN FROM (1005)
  1996.     3   (1009)  DO STASH .1 + .2 + .5 + .6
  1997.     4           DO .4 <- #1
  1998.     5           DO (1004) NEXT
  1999.     6   (1004)  PLEASE FORGET #1
  2000.     7           DO .3 <- '\*(vb.1\*(ct.2'~'#0\*(ct#65535'
  2001.     8           DO .6 <- '&.1\*(ct.2'~'#0\*(ct#65535'
  2002.     9           PLEASE DO .5 <- "\*(vb!6~#32768'\*(ct#1"~#3
  2003.    10           DO (1002) NEXT
  2004.    11           DO .4 <- #2
  2005.    12   (1005)  DO (1006) NEXT
  2006. *  13   (1999)  DOUBLE OR SINGLE PRECISION OVERFLOW
  2007.    14   (1002)  DO (1001) NEXT
  2008.    15   (1006)  PLEASE FORGET #1
  2009.    16           DO .5 <- '\*(vb"!6~.6'~#1"\*(ct#1'~#3
  2010.    17           DO (1003) NEXT
  2011.    18           DO .1 <- .3
  2012.    19           DO .2 <- !6\*(ct#0'~'#32767\*(ct#1'
  2013.    20           DO (1004) NEXT
  2014.    21   (1003)  DO (1001) NEXT
  2015.    22           DO REINSTATE (1005)
  2016.    23   (1007)  PLEASE RETRIEVE .1 + .2 + .5 + .6
  2017.    24           DO REMEMBER .4
  2018.    25           PLEASE RESUME #2
  2019.    26   (1001)  DO RESUME .5
  2020.    27   (1010)  DO STASH .1 + .2 + .4
  2021.    28           DO .4 <- .1
  2022.    29           DO .1 <- '\*(vb.2\*(ct#65535'~'#0\*(ct#65535'
  2023.    30           DO (1020) NEXT
  2024.    31           PLEASE DO .2 <- .4
  2025.    32           PLEASE DO (1009) NEXT
  2026.    33           DO RETRIEVE .1 + .2 + .4
  2027.    34           PLEASE RESUME #1
  2028.    35   (1020)  DO STASH .2 + .3
  2029.    36           DO .2 <- #1
  2030.    37           PLEASE DO (1021) NEXT
  2031.    38   (1021)  DO FORGET #1
  2032.    39           DO .3 <- "\*(vb!1~.2'\*(ct#1"~#3
  2033.    40           PLEASE DO .1 <- '\*(vb.1\*(ct.2'~'#0\*(ct#65535'
  2034.    41           DO (1022) NEXT
  2035.    42           DO .2 <- !2\*(ct#0'~'#32767\*(ct#1'
  2036.    43           DO (1021) NEXT
  2037.    44   (1023)  PLEASE RESUME .3
  2038.    45   (1022)  DO (1023) NEXT
  2039.    46           PLEASE RETRIEVE .2 + .3
  2040.    47           PLEASE RESUME #2
  2041.    48   (1030)  DO ABSTAIN FROM (1033)
  2042.    49           PLEASE ABSTAIN FROM (1032)
  2043.    50   (1039)  DO STASH :1 + .5
  2044.    51           DO (1530) NEXT
  2045.    52           DO .3 <- :1~#65535
  2046.    53           PLEASE DO .5 <- :1~'#65280\*(ct#65280'
  2047.    54           DO .5 <- '\*(vb"!5~.5'~#1"\*(ct#1'~#3
  2048.    55           DO (1031) NEXT
  2049.    56   (1032)  DO (1033) NEXT
  2050.    57           DO (1999) NEXT
  2051.    58   (1031)  DO (1001) NEXT
  2052.    59   (1033)  DO .4 <- .5
  2053.    60           DO REINSTATE (1032)
  2054.    61           PLEASE REINSTATE (1033)
  2055.    62           DO RETRIEVE :1 + .5
  2056.    63           PLEASE RESUME #2
  2057.    64   (1040)  PLEASE STASH .1 + .2 + .2 + :1 + :2 + :3
  2058.    65           DO .2 <- #0
  2059.    66           DO (1520) NEXT
  2060.    67           DO STASH :1
  2061.    68           PLEASE RETRIEVE .2
  2062.    69           DO .1 <- .2
  2063.    70           DO .2 <- #0
  2064.    71           PLEASE DO (1520) NEXT
  2065.    72           DO :2 <- :1
  2066.    73           DO RETRIEVE .1 + .2 + :1
  2067.    74           DO (1550) NEXT
  2068.    75           PLEASE DO .3 <- :3
  2069.    76           DO RETRIEVE :1 + :2 + :3
  2070.    77           DO RESUME #1
  2071.    78   (1050)  PLEASE STASH :2 + :3 + .5
  2072.    79           DO :2 <- .1
  2073.    80           PLEASE DO (1550) NEXT
  2074.    81           DO .5 <- :3~'#65280\*(ct#65280'
  2075.    82           DO .5 <- '\*(vb"!5~.5'~#1"\*(ct#1'~#3
  2076.    83           DO (1051) NEXT
  2077.    84           DO (1999) NEXT
  2078.    85   (1051)  DO (1001) NEXT
  2079.    86           DO .2 <- :3
  2080.    87           PLEASE RETRIEVE :2 + :3 + .5
  2081.    88           DO RESUME #2
  2082.    89   (1500)  PLEASE ABSTAIN FROM (1502)
  2083.    90           PLEASE ABSTAIN FROM (1506)
  2084.    91   (1509)  PLEASE STASH :1 + .1 + .2 + .3 + .4 + .5 + .6
  2085.    92           DO .1 <- :1~#65535
  2086.    93           PLEASE DO .2 <- :2~#65535
  2087.    94           DO (1009) NEXT
  2088.    95           DO .5 <- .3
  2089.    96           PLEASE DO .6 <- .4
  2090.    97           DO .1 <- :1~'#65280\*(ct#65280'
  2091.    98           DO .2 <- :2~'#65280\*(ct#65280'
  2092.    99           DO (1009) NEXT
  2093.   100           DO .1 <- .3
  2094.   101           PLEASE DO (1503) NEXT
  2095.   102           DO .6 <- .4
  2096.   103           DO .2 <- #1
  2097.   104           DO (1009) NEXT
  2098.   105           DO .1 <- .3
  2099.   106           DO (1501) NEXT
  2100.   107   (1504)  PLEASE RESUME .6
  2101.   108   (1503)  DO (1504) NEXT
  2102.   109   (1501)  DO .2 <- .5
  2103.   110           DO .5 <- '\*(vb"'&.6\*(ct.4'~#1"\*(ct#2'~#3
  2104.   111           DO (1505) NEXT
  2105.   112   (1506)  DO (1502) NEXT
  2106.   113           PLEASE DO (1999) NEXT
  2107.   114   (1505)  DO (1001) NEXT
  2108.   115   (1502)  DO :4 <- .5
  2109.   116           DO (1520) NEXT
  2110.   117           DO :3 <- :1
  2111.   118           PLEASE RETRIEVE :1 + .1 + .2 + .3 + .4 + .5 + .6
  2112.   119           DO REINSTATE (1502)
  2113.   120           DO REINSTATE (1506)
  2114.   121           PLEASE RESUME #3
  2115.   122   (1510)  DO STASH :1 + :2 + :4
  2116.   123           DO :1 <- "'\*(vb":2~'#65535\*(ct#0'"\*(ct#65535'~'#0\*(ct#6553
  2117.             5'"\*(ct"'\*(vb":2~'#0\*(ct#65535'"\*(ct#65535'~'#0\*(ct#65535
  2118.             '"
  2119.   124           DO :2 <- #1
  2120.   125           DO (1509) NEXT
  2121.   126           PLEASE RETRIEVE :1
  2122.   127           DO :2 <- :3
  2123.   128           PLEASE DO (1509) NEXT
  2124.   129           DO RETRIEVE :2 + :4
  2125.   130           PLEASE RESUME #1
  2126.   131   (1520)  PLEASE STASH .3 + .4
  2127.   132           DO .3 <- .1~#43690
  2128.   133           DO (1525) NEXT
  2129.   134           PLEASE DO .4 <- 'V.3\*(ct".2~#43690"'~'#0\*(ct#65535'
  2130.   135           DO .3 <- .1~#21845
  2131.   136           PLEASE DO (1525) NEXT
  2132.   137           DO :1 <- .4\*(ct"'V.3\*(ct".2~#21845"'~'#0\*(ct#65535'"
  2133.   138           PLEASE RETRIEVE .3 + .4
  2134.   139           DO RESUME #1
  2135.   140   (1525)  DO .3 <- '"'"'"!3\*(ct#0'~'#32767\*(ct#1'"\*(ct#0'~'#32767
  2136.             \*(ct#1'"\*(ct#0'~'#16383\*(ct#3'"\*(ct#0'~'#4095\*(ct#15'
  2137.   141           PLEASE RESUME #1
  2138.   142   (1530)  DO STASH :2 + :3 + .3 + .5
  2139.   143           DO :1 <- #0
  2140.   144           DO :2 <- .2
  2141.   145           DO .3 <- #1
  2142.   146           DO (1535) NEXT
  2143.   147   (1535)  PLEASE FORGET #1
  2144.   148           DO .5 <- "\*(vb!1~.3'\*(ct#1"~#3
  2145.   149           DO (1531) NEXT
  2146.   150           DO (1500) NEXT
  2147.   151           DO :1 <- :3
  2148.   152           PLEASE DO (1533) NEXT
  2149.   153   (1531)  PLEASE DO (1001) NEXT
  2150.   154   (1533)  DO FORGET #1
  2151.   155           DO .3 <- !3\*(ct#0'~'#32767\*(ct#1'
  2152.   156           DO :2 <- ":2~'#0\*(ct#65535'"\*(ct"'":2~'#32767\*(ct#0'"\*(ct#
  2153.             0'~'#32767\*(ct#1'"
  2154.   157           PLEASE DO .5 <- "\*(vb!3~.3'\*(ct#1"~#3
  2155.   158           DO (1532) NEXT
  2156.   159           DO (1535) NEXT
  2157.   160   (1532)  DO (1001) NEXT
  2158.   161           PLEASE RETRIEVE :2 + :3 + .3 + .5
  2159.   162           DO RESUME #2
  2160.   163   (1540)  PLEASE ABSTAIN FROM (1541)
  2161.   164           DO ABSTAIN FROM (1542)
  2162.   165   (1549)  PLEASE STASH :1 + :2 + :4 + :5 + .1 + .2 + .5
  2163.   166           DO .1 <- :1~#65535
  2164.   167           PLEASE DO .2 <- :2~'#65280\*(ct#65280'
  2165.   168           DO .5 <- :1~'#65280\*(ct#65280'
  2166.   169           DO (1530) NEXT
  2167.   170           DO :3 <- :1
  2168.   171           DO .2 <- :2~#65535
  2169.   172           PLEASE DO (1530) NEXT
  2170.   173           DO :5 <- :1
  2171.   174           DO .1 <- .5
  2172.   175           DO (1530) NEXT
  2173.   176           DO :4 <- :1
  2174.   177           PLEASE DO :1 <- ":3~'#65280\*(ct#65280'"\*(ct":5~'#652
  2175.             80\*(ct#65280'"
  2176.   178           DO .5 <- ':1~:1'~#1
  2177.   179           DO .2 <- :2~'#65280\*(ct#65280'
  2178.   180           DO (1530) NEXT
  2179.   181           PLEASE DO .5 <- '"':1~:1'~#1"\*(ct.5'~#3
  2180.   182           DO .1 <- :3~#65535
  2181.   183           DO .2 <- #0
  2182.   184           DO (1520) NEXT
  2183.   185           PLEASE DO :2 <- :1
  2184.   186           PLEASE DO .1 <- :4~#65535
  2185.   187           DO (1520) NEXT
  2186.   188           DO (1509) NEXT
  2187.   189           DO .5 <- !5\*(ct":4~#3"'~#15
  2188.   190           DO :1 <- :3
  2189.   191           DO :2 <- :5
  2190.   192           DO (1509) NEXT
  2191.   193           PLEASE DO .5 <- !5\*(ct":4~#3"'~#63
  2192.   194           DO .5 <- '\*(vb"!5~.5'~#1"\*(ct#1'~#3
  2193.   195           PLEASE RETRIEVE :4
  2194.   196   (1541)  DO :4 <- .5
  2195.   197           DO (1543) NEXT
  2196.   198   (1542)  DO (1544) NEXT
  2197.   199           PLEASE DO (1999) NEXT
  2198.   200   (1543)  DO (1001) NEXT
  2199.   201   (1544)  DO REINSTATE (1541)
  2200.   202           PLEASE REINSTATE (1542)
  2201.   203           PLEASE RETRIEVE :1 + :2 + :5 + .1 + .2 + .5
  2202.   204           DO RESUME #2
  2203.   205   (1550)  DO STASH :1 + :4 + :5 + .5
  2204.   206           DO :3 <- #0
  2205.   207           DO .5 <- '\*(vb"':2~:2'~#1"\*(ct#1'~#3
  2206.   208           PLEASE DO (1551) NEXT
  2207.   209           DO :4 <- #1
  2208.   210           PLEASE DO (1553) NEXT
  2209.   211   (1553)  DO FORGET #1
  2210.   212           DO .5 <- '\*(vb":2~'#32768\*(ct#0'"\*(ct#2'~#3
  2211.   213           DO (1552) NEXT
  2212.   214           DO :2 <- ":2~'#0\*(ct#65535'"\*(ct"'":2~'#32767\*(ct#0'"\*(ct#
  2213.                    0'~'#32767\*(ct#1'"
  2214.   215           PLEASE DO :4 <- ":4~'#0\*(ct#65535'"\*(ct"'":4~'#32767
  2215.                      \*(ct#0'"\*(ct#0'~'#32767\*(ct#1'"
  2216.   216           DO (1553) NEXT
  2217.   217   (1552)  DO (1001) NEXT
  2218.   218   (1556)  PLEASE FORGET #1
  2219.   219           DO :5 <- "'\*(vb":1~'#65535\*(ct#0'"\*(ct":2~'#65535\*(ct#0'"'
  2220.                      ~'#0\*(ct#65535'"\*(ct"'\*(vb":1~'#0\*(ct#65535'"\*(ct":2~'#0\*(ct
  2221.                      #65535'"'~'#0\*(ct#65535'"
  2222.   220           DO .5 <- '\*(vb"'&"':2~:5'~'"'\*(vb"'\*(vb":5~:5"~"#65535~
  2223.                      #65535"'~'#65535\*(ct#0'"\*(ct#32768'~'#0\*(ct#65535'"
  2224.                      \*(ct"'\*(vb":5~:5"~"#65535\*(ct#65535"'~'#0\*(ct#65535'"'
  2225.                      "\*(ct"':5~:5'~#1"'~#1"\*(ct#2'~#3
  2226.   221           DO (1554) NEXT
  2227.   222           DO :5 <- :3
  2228.   223           DO (1510) NEXT
  2229.   224           PLEASE DO :1 <- :3
  2230.   225           DO :3 <- "'V":4~'#65535\*(ct#0'"\*(ct":5~'#65535\*(ct#0'"'
  2231.                      ~'#0\*(ct#65535'"\*(ct"'V":4~'#0\*(ct#65535'"\*(ct":5~'#0\*(ct
  2232.                      #65535'"'~'#0\*(ct#65535'"
  2233.   226           DO (1555) NEXT
  2234.   227   (1554)  PLEASE DO (1001) NEXT
  2235.   228   (1555)  DO FORGET #1
  2236.   229           DO .5 <- "\*(vb':4~#1'\*(ct#2"~#3
  2237.   230           DO (1551) NEXT
  2238.   231           DO :2 <- ":2~'#0\*(ct#65534'"\*(ct":2~'#65535\*(ct#0'"
  2239.   232           DO :4 <- ":4~'#0\*(ct#65534'"\*(ct":4~'#65535\*(ct#0'"
  2240.   233           PLEASE DO (1556) NEXT
  2241.   234   (1551)  DO (1001) NEXT
  2242.   235           PLEASE RETRIEVE :1 + :4 + :5 + .5
  2243.   236           PLEASE RESUME #2
  2244.   237   (1900)  DO STASH .2 + .3 + .5
  2245.   238           DO .1 <- #0
  2246.   239           DO .2 <- #1
  2247.   240           PLEASE DO (1901) NEXT
  2248.   241   (1901)  DO FORGET #1
  2249.   242           DO %50 .1 <- 'V.1\*(ct.2'~'#0\*(ct#65535'
  2250.   243           DO .2 <- !2\*(ct#0'~'#32767\*(ct#1'
  2251.   244           PLEASE DO .5 <- "\*(vb!2~.2'\*(ct#1"~#3
  2252.   245           DO (1902) NEXT
  2253.   246           DO (1901) NEXT
  2254.   247   (1902)  DO (1001) NEXT
  2255.   248           DO RETRIEVE .2 + .3 + .5
  2256.   249           PLEASE RESUME #2
  2257.   250   (1910)  PLEASE STASH .1 + .3 + .5 + :1 + :2 + :3
  2258.   251           DO .3 <- #65524
  2259.   252           DO :1 <- #6
  2260.   253           DO (1911) NEXT
  2261. * 254           PLEASE NOTE THAT YOU CAN'T GET THERE FROM HERE
  2262.   255   (1912)  DO (1001) NEXT
  2263.   256   (1911)  DO FORGET #1
  2264.   257           PLEASE DO (1900) NEXT
  2265.   258           DO :2 <- .1
  2266.   259           DO (1500) NEXT
  2267.   260           PLEASE DO :1 <- :3
  2268.   261           DO .1 <- .3
  2269.   262           DO (1020) NEXT
  2270.   263           PLEASE DO .3 <- .1
  2271.   264           DO .5 <- '\*(vb"!3~.3'~#1"\*(ct#2'~#3
  2272.   265           DO (1912) NEXT
  2273.   266           DO .1 <- #12
  2274.   267           PLEASE DO (1050) NEXT
  2275.   268           DO RETRIEVE .1
  2276.   269           DO (1530) NEXT
  2277.   270           DO :2 <- #32768
  2278.   271           DO (1500) NEXT
  2279.   272           PLEASE DO .2 <- :3~'#65280\*(ct#65280'
  2280.   273           PLEASE RETRIEVE .3 + .5 + :1 + :2 + :3
  2281.   274           DO RESUME #1
  2282. .if '\*c'y' \{\
  2283.   275   (1060)  DO .3<-'V".1\*(ct.2"'~'#0\*(ct#65535'
  2284.   276           DO RESUME #1
  2285.   277   (1070)  DO .3<-'&".1\*(ct.2"'~'#0\*(ct#65535'
  2286.   278           DO RESUME #1
  2287.   279   (1080)  DO .3<-'\*(vb".1\*(ct.2"'~'#0\*(ct#65535' \}
  2288.   280           DO RESUME #1
  2289. .cs R
  2290. .DE
  2291. .bp
  2292. .H 2 "Programming Suggestions"
  2293. .P
  2294. For the novice INTERCAL programmer, we provide here a list of suggested 
  2295. INTERCAL programming projects:
  2296. .P
  2297. Write an integer exponentiation subroutine.  :1 <- .1 raised to the .2 power.
  2298. .P
  2299. Write a double-precision sorting subroutine. Given 32-bit array ;1 of size
  2300. :1, sort the contents into numerically increasing order, leaving the results
  2301. in ;1.
  2302. .P
  2303. Generate a table of prime numbers.
  2304. .P
  2305. Put together a floating-point library, using 32-bit variables to represent
  2306. floating-point numbers (let the upper half be the mantissa and the lower
  2307. half be the characteristic).  The library should be capable of performing 
  2308. floating-point addition, subtraction, multiplication, and division, as well
  2309. as the natural logarithm function.
  2310. .P
  2311. Program a Fast Fourier Transform (FFT).  This project would probably entail
  2312. the writing of the floating-point library as well as sine and cosine functions.
  2313. .P
  2314. Calculate, to :1 places, the value of pi.
  2315. .if '\*c'y' \{\
  2316. .P
  2317. (The first three and last one of the preceding suggested projects from
  2318. the INTERCAL-72 manual are included in the C-INTERCAL distribution's 
  2319. pit directory of sample code.  The floating-point library and FFT
  2320. routine remain as worthy challenges...) \} 
  2321. .bp
  2322. .H 1 "ERROR MESSAGES"
  2323. .SETR error_messages
  2324. .P
  2325. Due to INTERCAL's implementation of comment lines (see section 4.5), most
  2326. error messages are produced during execution instead of during compilation.
  2327. All errors except those not causing immediate termination of program execution
  2328. are treated as fatal.
  2329. .H 2 "Format"
  2330. .P
  2331. All error messages appear in the following form:
  2332. .DS L
  2333.         ICLnnnI (error message)
  2334.                 ON THE WAY TO STATEMENT nnnn
  2335.                 CORRECT SOURCE AND RESUBMIT
  2336. .DE
  2337. The message varies depending upon the error involved.  For undecodable
  2338. statements the message is the statement itself.  The second line tells
  2339. which statement would have been executed next had the error not occurred.
  2340. Note that if the error is due to 80 attempted levels of NEXTing, the
  2341. statement which would have been executed next need not be anywhere near the
  2342. statement causing the error.
  2343. .H 2 "Messages"
  2344. .P
  2345. Brief descriptions of the different error types are listed below according
  2346. to message number.
  2347. .BL
  2348. .LI 000
  2349. An undecodable statement has been encountered in the course of
  2350. execution. Note that keypunching errors can be slightly disastrous,
  2351. since if 'FORGET' were misspelled F-O-R-G-E-R, the results would 
  2352. probably not be those desired. Extreme misspellings may have even 
  2353. more surprising consequences. For example, misspelling 'FORGET' 
  2354. R-E-S-U-M-E could have drastic results.
  2355. .LI 017
  2356. An expression contains a syntax error.
  2357. .LI 079
  2358. Improper use has been made of statement identifiers.
  2359. .LI 099
  2360. Improper use has been made of statement identifiers.
  2361. .LI 123
  2362. Program has attempted 80 levels of NEXTing.
  2363. .LI 129
  2364. Program has attempted to transfer to a non-existent line label.
  2365. .LI 139
  2366. An ABSTAIN or REINSTATE statement references a non-existent line label.
  2367. .LI 182
  2368. A line label has been multiply defined.
  2369. .LI 197
  2370. An invalid line label has been encountered.
  2371. .LI 200
  2372. An expression involves an unidentified variable.
  2373. .LI 240
  2374. An attempt has been made to give an array a dimension of zero.
  2375. .LI 241
  2376. Invalid dimensioning information was supplied in defining or using
  2377. an array.
  2378. .LI 275
  2379. A 32-bit value has been assigned to a 16-bit variable.
  2380. .LI 436
  2381. A retrieval has been attempted for an unSTASHed value.
  2382. .LI 533
  2383. A WRITE IN statement or interleave (\*(ct) operation has produced a
  2384. value requiring over 32 bits to represent.
  2385. .LI 562
  2386. Insufficient data.
  2387. .LI 579
  2388. Input data is invalid.
  2389. .LI 621
  2390. The expression of a RESUME statement evaluated to #0.
  2391. .LI 632
  2392. Program execution was terminated via a RESUME statement instead of
  2393. GIVE UP.
  2394. .LI 633
  2395. Execution has passed beyond the last statement of the program.
  2396. .LI 774
  2397. A compiler error has occurred (see section 
  2398. .GETHN princeton
  2399. ).
  2400. .LI 778
  2401. .ie '\*c'n' \{\
  2402. An unexplainable compiler error has occurred (see J. Lyon or D. Woods)\}.
  2403. .el An unexplainable compiler error has occurred.
  2404. .LE
  2405. .if '\*c'y' \{\
  2406. .P
  2407. The following error codes are new in C-INTERCAL:
  2408. .BL
  2409. .LI 111
  2410. You tried to use a C-INTERCAL extension with the `traditional' flag on.
  2411. .LI 127
  2412. Can't find syslib.i file when it's needed for magical inclusion.
  2413. .LI 222
  2414. Out of stash space.
  2415. .LI 333
  2416. Too many variables.
  2417. .LI 444
  2418. A COME FROM statement references a non-existent line label.
  2419. .LI 555
  2420. More than one COME FROM references the same label.
  2421. .LI 666
  2422. Too many source lines.
  2423. .LI 777
  2424. No such source file.
  2425. .LI 888
  2426. Can't open C output file
  2427. .LI 999
  2428. Can't open C skeleton file.
  2429. .LI 998
  2430. Source file name with invalid extension (use .i or .[3-7]i).
  2431. .LI 997
  2432. Illegal possession of a controlled unary operator.
  2433. .LE \}
  2434. .if '\*c'y' \{\
  2435. .H 1 "The C-INTERCAL Compiler"
  2436. .H 2 "Character Set"
  2437. .P
  2438. The C-INTERCAL compiler uses ASCII rather than EBCDIC. We follow the
  2439. Atari implementation by (a) replacing the change sign (\*(ct) with
  2440. big money ($) as the mingle operator, and (b) replacing the
  2441. bookworm (\*(vb) symbol with what (?) as the exclusive-or
  2442. operator.
  2443. .H 2 "Usage and Compilation Options"
  2444. .P
  2445. To compile an INTERCAL program `foo.i' to executable code, just do
  2446.  
  2447.         ick foo.i
  2448.  
  2449. There's a -c option that leaves the generated C code in place for
  2450. inspection (suppressing compilation to machine code), a -d option that
  2451. enables verbose parse reporting from the yacc/bison parser, a -t
  2452. option that requires strict INTERCAL-72 compliance (rejecting COME
  2453. FROM and the extensions for bases other than two), a -b option that
  2454. disables the INTERCAL-72 random-bug feature (E774), and an -O option
  2455. that enables the (hah!) optimizer.  Invoking ick -?  prints a usage
  2456. message.
  2457. .P
  2458. Another compilation switch affects C-INTERCAL's runtime behavior.  The `-C'
  2459. option forces output in "clockface" mode, for superstitious users who
  2460. believe writing "IV" upside-down offends IVPITER and would rather
  2461. see IIII.
  2462. .H 2 "Runtime Options"
  2463. .P
  2464. Every C-INTERCAL runtime also accepts certain options at runtime. 
  2465. These include [+/-]help, [+/-]traditional, and [+/-]wimpmode. 
  2466. The help option (with either + or -) triggers a 'usage' message. The
  2467. +traditional option is presently a no-op.
  2468. .P
  2469. Steve explains: "The wimpmode option is the most interesting. I found
  2470. myself always running my test programs with filters on both ends to
  2471. work around the \&'nifty' INTERCAL number representations. This was so
  2472. painful that I decided it would be LESS painful (and a lot less code)
  2473. if I added a 'wimp' option.  With the +wimpmode option, the user is
  2474. subjected to a humiliating message about what a wimp he or she is to
  2475. use this mode, but after that is allowed to use conventional numerical
  2476. notation.  While such a mode doubtless violates to some extent the
  2477. INTERCAL philosophy, the fact that a 'unbutcher' command has been
  2478. posted clearly indicates the need for it. Anyway... if you don't like
  2479. it, don't use it... the default is -wimpmode (i.e. NOT wimp mode)."
  2480. .H 2 "PLEASE Politesse Checking"
  2481. .P
  2482. A feature of INTERCAL-72 not documented in the original manual was that it
  2483. required a certain level of politesse from the programmer.  If fewer than
  2484. 1/5th of the program statements included the PLEASE qualifier, the program
  2485. would be rejected as insufficiently polite.  If more than 1/3rd of them
  2486. included PLEASE, the program would be rejected as excessively polite.
  2487. .P
  2488. This check has been implemented in C-INTERCAL.  To assist programmers in
  2489. coping with it, the intercal.el mode included with the distribution randomly
  2490. expands "do " in entered source to "DO PLEASE" or "PLEASE DO" 1/4th of the
  2491. time. \}
  2492. .if '\*c'y' \{\
  2493. .\" This is the same text as the ATARI NOTES at the end of the manual.
  2494. .H 1 "The Atari Implementation"
  2495. .P
  2496. The Atari implementation of INTERCAL differs from the original Princeton
  2497. version primarily in the use of ASCII rather than EBCDIC. Since there is no
  2498. "change" sign (\*(ct) in ASCII, we have substituted the "big money" ($) as the
  2499. mingle operator. We feel that this correctly represents the increasing cost
  2500. of software in relation to hardware. (Consider that in 1970 one could get
  2501. RUNOFF for free, to run on a $20K machine, whereas today a not quite as
  2502. powerful formatter costs $99 and runs on a $75 machine.)  We also feel that
  2503. there should be no defensible contention that INTERCAL has any sense.
  2504. Also, since overpunches are difficult to read on the average VDT, the
  2505. exclusive-or operator may be written ?.  This correctly expresses the
  2506. average person's reaction on first encountering exclusive-or, especially on
  2507. a PDP-11.  Note that in both of these cases, the over-punched symbol may
  2508. also be used if one is masochistic, or concerned with portability to the
  2509. Princeton compiler.  The correct over-punch for "change" is "c<backspace>/"
  2510. and the correct over-punch for \*(vb is "V<backspace>-".  These codes will be
  2511. properly printed if you have a proper printer, and the corresponding EBCDIC
  2512. code will be produced by the /IBM option on the LIST command. \}
  2513. .ie '\*c'n' \{\
  2514. .H 1 "JCL"
  2515. .P
  2516. The information contained in the following section applies
  2517. only to the Princeton compiler, run under OS/360.
  2518. .H 2 "The Princeton Compiler" \}
  2519. .el .H 1 "The Princeton Compiler"
  2520. .P
  2521. The Princeton compiler, written in SPITBOL (a variant of
  2522. SNOBOL), performs the compilation in two stages. First the
  2523. INTERCAL source is converted into SPITBOL source, then the
  2524. latter is compiled and executed.
  2525. .SETR princeton
  2526. .P
  2527. It should be noted that the Princeton compiler fails to
  2528. properly interpret certain multiply-subscripted expressions,
  2529. such as:
  2530. .DS
  2531.         ",1SUB",2SUB#1"#2"
  2532. .DE
  2533. .P
  2534. This is not a "bug". Being documented, it is merely a
  2535. "restriction". Such cases may be resolved by alternating
  2536. sparks and ears in various levels of expression nesting:
  2537. .DS
  2538.         ",1SUB',2SUB#1'#2"
  2539. .DE
  2540. which is advisable in any case, since INTERCAL expressions
  2541. are unreadable enough as is.
  2542. .P
  2543. Since there is currently no catalogued procedure for
  2544. invoking the compiler, the user must include the in-line
  2545. procedure shown on the following page in his job before the
  2546. compilation step. Copies of this in-line procedure may be
  2547. obtained at any keypunch if the proper keys are struck.
  2548. .P
  2549. The compiler is then executed in the usual manner:
  2550. .DS L
  2551.  
  2552.         // EXEC INTERCAL[,PARM='parameters']
  2553.         //COMPILE.SYSIN DD *
  2554.         {INTERCAL source deck}
  2555.         /* 
  2556.         //EXECUTE.SYSWRITE DD *
  2557.         {input data}
  2558.         /*
  2559.  
  2560. .DE
  2561. The various parameters are described following the in-line
  2562. procedure. At most one parameter from each set may apply to
  2563. a given compilation; if more than one are specified, the
  2564. results are undefined, and may vary depending upon the
  2565. particular set of options. The default parameters are
  2566. underlined.
  2567. .DS L
  2568.         //INTERCAL PROC
  2569.         //COMPILE EXEC PGM=INTERCAL
  2570.         //STEPLIB DD DSN=U.INTERCAL.LIBRARY,DISP=SHR
  2571.         //             DD DSN=SYS1.FORTLIB,DISP=SHR
  2572.         //SYSPRINT DD SYSOUT=A,DCB=(BLKSIZE=992,LRECL=137,RECFM=VBA)
  2573.         //SYSPUNCH DD DUMMY
  2574.         //SCRATCH DD DSN=&COMPSET,UNIT=SYSDA,SPACE=(CYL,(3,1)),DISP=(,PASS)
  2575.         //EXECUTE EXEC PGM=EXECUTE,COND=(4,LT)   \*F
  2576.         //SOURCES DD DSN=U.INTERCAL.SOURCES,DISP=SHR
  2577.         //STEPLIB DD DSN=U.INTERCAL.LIBRARY,DISP=SHR
  2578.         //             DD DSN=SYS5.SPITLIB,DISP=SHR
  2579.         //             DD DSN=SYS1.FORTLIB,DISP=SHR
  2580.         //SYSIN DD DSN=&COMPSET,DISP=(OLD,DELETE)
  2581.         //SYSOBJ DD SYSOUT=B,DCB=(BLKSIZE=80,LRECL=80,RECFM=F)
  2582.         //SYSPRINT DD SYSOUT=A,DCB=(BLKSIZE=992,LRECL=137,RECFM=VBA)
  2583.         //SYSPUNCH DD DUMMY
  2584.         // PEND
  2585. .DE
  2586. .FS
  2587. Pending acquisition of SPITBOL release 3.0, the SOURCES
  2588. DD card must be replaced by the five cards:
  2589. .DS L
  2590.         //NOOPTPFX DD DSN=U.INTERCAL.SOURCES(NOOPTPFX),DISP=SHR
  2591.         //NOOPTSUB DD DSN=U.INTERCAL.SOURCES(NOOPTSUB),DISP=SHR
  2592.         //OPTPFX DD DSN=U.INTERCAL.SOURCES(OPTPFX),DISP=SHR
  2593.         //OPTSUB DD DSN=U.INTERCAL.SOURCES(OPTSUB),DISP=SHR
  2594.         //PRELIM DD DSN=U.INTERCAL.SOURCES(PRELIM),DISP=SHR
  2595. .DE
  2596. .FE
  2597. .ce 1
  2598. Figure 3.  Inline procedure for using INTERCAL.
  2599. .P
  2600. .LB 5 0 " " 0 * 0 0
  2601. .LI "\fBOPT\fR"
  2602. .LI "NOOPT"
  2603. .LI " "
  2604. In the default mode, the compiler will print a
  2605. list of all options in effect, including the
  2606. defaults for unspecified parameter groups and the
  2607. effective option for those sets where one was
  2608. specified. If NOOPT is requested, it causes the
  2609. default mode to be assumed.
  2610.  
  2611. .LI "\fBOPTSUB\fR
  2612. .LI "NOOPTSUB"
  2613. .LI "NOSUB"
  2614. .LI " "
  2615. Unless 'NOOPTSUB' is requested, the System Library
  2616. is optimized, resulting in much more rapid
  2617. NOSUB processing of function calls. Specifying NOOPTSUB
  2618. causes the non-optimized INTERCAL code shown in
  2619. section 6.3 to be used, whereas NOSUB requests
  2620. that the System Library be omitted altogether.
  2621.  
  2622. .LI IAMBIC
  2623. .LI "\fBPROSE\fR
  2624. .LI " "
  2625. The IAMBIC parameter permits the programmer to use
  2626. poetic license and thus write in verse. If the
  2627. reader does not believe it possible to write verse
  2628. in INTERCAL, he should send the authors a stamped,
  2629. self-addressed envelope, along with any INTERCAL
  2630. program, and they will provide one which is verse.
  2631.  
  2632. .LI "\fBFORMAT\fR"
  2633. .LI NOFORMAT
  2634. .LI " "
  2635. In FORMAT mode, each statement printed is put on a
  2636. separate line (or lines). In NOFORMAT mode, the
  2637. free-format source is printed exactly as input.
  2638. In this latter case, statement numbers are
  2639. provided only for the first statement on a card,
  2640. and they may be only approximate. Also,
  2641. unrecognizable statements are not flagged.
  2642.  
  2643. .LI SEQ
  2644. .LI "\fBNOSEQ\fR"
  2645. .LI " "
  2646. If the source deck has sequence numbers in columns
  2647. 73 through 80, specifying 'SEQ' will cause them to
  2648. be ignored.
  2649.  
  2650. .LI "SOURCE"
  2651. .LI "\fBNOSOURCE\fR"
  2652. .LI " "
  2653. If NOSOURCE is selected, all source listing is
  2654. suppressed.
  2655.  
  2656. .LI LIST
  2657. .LI "\fBNOLIST\fR"
  2658. .LI " "
  2659. If LIST is specified, the compiler will provide a
  2660. list of statement numbers catalogued according to
  2661. type of statement. The compiler uses this table
  2662. to perform abstentions by gerund.
  2663.  
  2664. .LI "WIDTH=nn"
  2665. .LI " "
  2666. This sets the width (in number of characters) of
  2667. the output line for FORMAT mode output. The
  2668. default is
  2669. .B 132.
  2670.  
  2671. .LI "CODE"
  2672. .LI "\fBNOCODE\fR"
  2673. .LI " "
  2674. Include 'CODE' in the parameter list to obtain a
  2675. listing of the SPITBOL code produced for each
  2676. INTERCAL statement.
  2677.  
  2678. .LI "LINES=nn"
  2679. .LI " "
  2680. This determines the number of lines per page,
  2681. during both compilation and execution. The
  2682. default is
  2683. .B 60.
  2684.  
  2685. .LI DECK
  2686. .LI "\fBNODECK\fR"
  2687. .LI " "
  2688. Selecting 'DECK' will cause the compiler to punch
  2689. out a SPITBOL object deck which may then be run
  2690. without reinvoking the INTERCAL (or SPITBOL)
  2691. compiler.
  2692.  
  2693. .LI "\fBKIDDING\fR"
  2694. .LI NOKIDDING
  2695. .LI " "
  2696. Select NOKIDDING to eliminate the snide remarks
  2697. which ordinarily accompany INTERCAL error
  2698. messages.
  2699.  
  2700. .LI "\fBGO\fR"
  2701. .LI NOGO
  2702. .LI " "
  2703. Specifying 'NOGO' will cause  the program to be
  2704. compiled but not executed. EXECUTE/NOEXECUTE may
  2705. be substituted for GO/NOGO, but this will result
  2706. in an error, and GO will be assumed.
  2707.  
  2708. .LI "\fBBUG\fR"
  2709. .LI NOBUG
  2710. .LI " "
  2711. Under the default, there is a fixed probability of
  2712. a fatal compiler bug being worked at random into
  2713. the program being compiled. Encountering this bug
  2714. during execution results in error message 774 (see
  2715. section 7.2). This probability is reduced to zero
  2716. under 'NOBUG'. This does not affect the
  2717. probability (presumably negligible) of error
  2718. message 778.
  2719. .LE
  2720. .H 2 "Other INTERCAL Compilers"
  2721. .P
  2722. There are no other INTERCAL compilers. \*F
  2723. .FS
  2724. This assertion in the INTERCAL-72 manual was blatantly contradicted by
  2725. some notes on an Atari implementation included at the end of the manual.
  2726. So, you expect compiler manuals to be consistent?
  2727. .FE
  2728. .ds App TONSIL
  2729. .APP A ""
  2730. .P
  2731. The Official INTERCAL Character Set
  2732. .FS
  2733. Since all other reference manuals have Appendices, it was decided that
  2734. the INTERCAL manual should contain some other type of removable organ.
  2735. .FE
  2736. .\".nr * \n*+1
  2737. .nr PG \n%+1
  2738. .P
  2739. Tabulated on page \n(PG are all the characters used in INTERCAL, excepting
  2740. letters and digits, along with their names and interpretations. Also
  2741. included are several characters not used in INTERCAL, which are presented
  2742. for completeness and to allow for future expansion.
  2743. .FS
  2744. \*F This footnote intentionally unreferenced.
  2745. .FE
  2746. .ds CH - % -
  2747. .bp
  2748. .\".nr * \n*-1
  2749. .TS
  2750. box;
  2751. c c c
  2752. l l l.
  2753. Character       Name    Use (if any)
  2754. =
  2755. \&.     spot    identify 16-bit variable
  2756. :       two-spot        identify 32-bit variable
  2757. ,       tail    identify 16-bit array
  2758. ;       hybrid  identify 32-bit array
  2759. #       mesh    identify constant
  2760. \&=     half-mesh
  2761. \'      spark   grouper
  2762. `       backspark
  2763. !       wow     equivalent to spark-spot
  2764. ?       what    \fIunary exlusive OR (ASCII)\fR
  2765. "       rabbit-ears     grouper
  2766. \o'".'  rabbit  equivalent to ears-spot
  2767. |       spike
  2768. %       double-oh-seven percentage qualifier
  2769. \-      worm    used with angles
  2770. <       angle   used with worms
  2771. >       right angle
  2772. (       wax     precedes line label
  2773. )       wane    follows line label
  2774. [       U turn
  2775. ]       U turn back
  2776. {       embrace
  2777. }       bracelet
  2778. *       splat   flags invalid statements
  2779. &       ampersand\*F    unary logical AND
  2780. V       V (or book)     unary logical OR
  2781. \*(vb   bookworm (or universal qualifier)       unary exclusive OR
  2782. $       big money       \fIbinary mingle (ASCII)\fR
  2783. \*(ct   change  binary mingle
  2784. ~       sqiggle binary select
  2785. \&_     flat worm
  2786. \*(ov   overline        indicates "times 1000"
  2787. +       intersection    separates list items
  2788. /       slat
  2789. \e      backslat
  2790. @       whirlpool
  2791. \*(no   hookworm
  2792. ^       shark (or simply sharkfin)
  2793. \o"#*\(sq"      blotch
  2794. .TE
  2795. .ce 1
  2796. Table 2 (top view). INTERCAL character set.
  2797. .FS
  2798. Got any better ideas?
  2799. .FE
  2800. .if '\*c'n' \{\
  2801. .APP "B" "NOTES ON THE ATARI IMPLEMENTATION"
  2802. .P
  2803. The Atari implementation of INTERCAL differs from the original Princeton
  2804. .ds CH INTERCAL
  2805. version primarily in the use of ASCII rather than EBCDIC. Since there is no
  2806. "change" sign (\*(ct) in ASCII, we have substituted the "big money" ($) as the
  2807. mingle operator. We feel that this correctly represents the increasing cost
  2808. of software in relation to hardware. (Consider that in 1970 one could get
  2809. RUNOFF for free, to run on a $20K machine, whereas today a not quite as
  2810. powerful formatter costs $99 and runs on a $75 machine.)  We also feel that
  2811. there should be no defensible contention that INTERCAL has any sense.
  2812. Also, since overpunches are difficult to read on the average VDT, the
  2813. exclusive-or operator may be written ?.  This correctly expresses the
  2814. average person's reaction on first encountering exclusive-or, especially on
  2815. a PDP-11.  Note that in both of these cases, the over-punched symbol may
  2816. also be used if one is masochistic, or concerned with portability to the
  2817. Princeton compiler.  The correct over-punch for "change" is "c<backspace>/"
  2818. and the correct over-punch for \*(vb is "V<backspace>-".  These codes will be
  2819. properly printed if you have a proper printer, and the corresponding EBCDIC
  2820. code will be produced by the /IBM option on the LIST command. \}
  2821.