addend.n 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122
  1. .lg 0
  2. .ta 8 16 24 32 40 48 56 64 72 80
  3. .hw iden-ti-fi-er
  4. .nr a 0 1
  5. .nr f 1 1
  6. .de x1
  7. 'sp 2
  8. 'tl '''%'
  9. 'sp 2
  10. .ns
  11. ..
  12. .wh 0 x1
  13. .de fo
  14. 'bp
  15. ..
  16. .wh 60 fo
  17. .ll 79
  18. .lt 79
  19. .de HT
  20. .ti -4
  21. ..
  22. .de PP
  23. .sp
  24. .ne 2
  25. .ti +5
  26. ..
  27. .de SE
  28. .bp
  29. \fB\\n+a. \\$1\fR
  30. .nr b 0 1
  31. ..
  32. .de SB
  33. .br
  34. .ne 10
  35. .sp 5
  36. \fB\\na.\\n+b. \\$1\fR
  37. ..
  38. .de DC
  39. .ti -14
  40. DECISION~\\$1:
  41. ..
  42. .de IN
  43. .in +6
  44. ..
  45. .de OU
  46. .in -6
  47. ..
  48. .tr ~
  49. .sp 5
  50. .rs
  51. .sp 10
  52. .ce 3
  53. Changes in EM-1
  54. Addendum to Informatica Rapport IR-54
  55. .sp 5
  56. .PP
  57. This document describes a revision of EM-1.
  58. A list of differences is presented roughly in the order IR-54
  59. describes the original architecture.
  60. A complete list of EM-1 pseudo's and instructions is also included.
  61. .SE Introduction
  62. .PP
  63. EM is a family of intermediate languages, resembling assembly
  64. language for a stack machine.
  65. EM defines the layout of data memory and a partitioning
  66. of instruction memory.
  67. EM has can do operations on five basic types:
  68. pointers, signed integers, unsigned integers, floating point numbers
  69. and sets of bits.
  70. The size of pointers is fixed in each member,
  71. in contrast to the sizes of the other types.
  72. Each member has one more fixed size: the word size.
  73. This is the mimimum size of any object on the stack.
  74. The sizes of all objects on the stack are assumed to
  75. multiples of the word size.
  76. We assume that pointer and word-sizes are both powers of two.
  77. .PP
  78. It is possible to load objects smaller then the word size from memory.
  79. These objects are converted to objects of the word size by
  80. clearing the most significant bytes.
  81. (A separate conversion instruction can do sign extension).
  82. While storing objects smaller then the word size are stored in memory,
  83. the most significant bytes are ignored.
  84. The size of such objects has to be a divisor of the word size.
  85. .PP
  86. Put in other terms, instructions such as LOC, LOL, LOE, STF, etc.
  87. manipulate WORDS. Up until now, a word was defined as 16 bits.
  88. It is now possible to define a word size other than 16 bits. For
  89. example, MES 2,1,2 defines a word to be 8 bits and a pointer to be
  90. 16 bits. As another example, MES 2,4,4 defines a word to be 32 bits
  91. and a pointer to be 32 bits.
  92. .PP
  93. If a compiler receives flags telling it to use 32 bit integers, it now
  94. has a choice of setting the word length to 16 bits and using LDL etc
  95. for dealing with integers, or setting the word length to 32 bits and using
  96. LOL etc for integers.
  97. For example, x:=a+b for 32-bit integers would become:
  98. MES 2,2,4 MES 2,4,4
  99. LDL a LOL a
  100. LDL b LOL b
  101. ADI 4 ADI 4
  102. SDL x STL x
  103. In many cases, the target machine code that is finally produced from either
  104. of the above sequences will not show any traces of the stack machine, however
  105. for some instructions actual pushes and pops at run time will be necessary.
  106. Choosing a wider EM word will usually produce fewer stack operations than
  107. a narrower word, but it eliminates the possibility of doing arithmetic on
  108. quantities smaller than a word. If, for example, a compiler chooses a 32-bit
  109. EM word, it will be difficult to add two 16 bit integers with ADI, since
  110. the argument must be multiple of the word size.
  111. (The operation can be done by converting the operands to 32 bits using CII,
  112. adding the 32-bit numbers, and reconverting the result.)
  113. On the other hand, choosing a 16-bit EM word makes it possible to do both
  114. 16-bit adds (ADI 2) and 32-bit adds (ADI 4),
  115. but the price paid is that 32-bit operations will be viewed as double
  116. precision, and may be slightly less efficient on target machines with a
  117. 32-bit word, i.e. the EM to target translator may not take full advantage
  118. of the 32 bit facilities.
  119. .PP
  120. Note that since LOC pushes a WORD on the stack, the argument of LOC
  121. must fit ina word. LOC 256 on an EM machine with a 1-byte word length
  122. is not allowed. LDC 256 is allowed, however.
  123. .PP
  124. A general rule of thumb is that the compiler should choose an EM word
  125. length equal to the width of a single precision integer.
  126. Obviously, compilers should be well parameterized to allow the integer
  127. size(s) and word size(s) to be changed by just changing a few constants.
  128. .PP
  129. The size of a instruction space pointer in is the same
  130. as the size of a data space pointer.
  131. .PP
  132. EM assumes two's complement arithmetic on signed integers,
  133. but does not define an ordering of the bytes in a integer.
  134. The lowest numbered byte of a two-byte object can contain
  135. either the most or the least significant part.
  136. .SE Memory
  137. .PP
  138. EM has two separate addressing spaces, instruction and data.
  139. The sizes of these spaces are not specified.
  140. The layout of instruction space in not defined.
  141. Any interpreter or translator may assume a layout fitting his/her needs.
  142. The layout of data memory is specified by EM.
  143. EM data memory consists of a sequence of 8-bit bytes each separately
  144. addressable.
  145. Certain alignment restrictions exist for object consisting of multiple bytes.
  146. Objects smaller then the word size can only be addressed
  147. at multiples of the object size.
  148. For example: in a member with a four-byte word size, two-byte integers
  149. can only be accessed from even addresses.
  150. Objects larger then the word size can only be placed at multiples
  151. of the word size.
  152. For example: in a member with a four-byte word size,
  153. eight-byte floating point numbers can be fetched at addresses
  154. 0, 4, 8, 12, etc.
  155. .SB "Procedure identifiers"
  156. .PP
  157. Procedure identifiers in EM have the same size
  158. as pointers.
  159. Any implementation of EM is free to use any method of identifying procedures.
  160. Common methods are indices into tables containing further information
  161. and addresses of the first instructions of procedures.
  162. .SB "Heap and Stack in global data"
  163. .PP
  164. The stack grows downward, the heap grows upward.
  165. The stack pointer points to the lowest occupied word on the stack.
  166. The heap pointer marks the first free word in the heap area.
  167. .br
  168. .ne 39
  169. .sp 1
  170. .nf
  171. 65534 -> |-------------------------------|
  172. |///////////////////////////////|
  173. |//// unimplemented memory /////|
  174. |///////////////////////////////|
  175. SB -> |-------------------------------|
  176. | |
  177. | stack and local area | <- LB
  178. | |
  179. | |
  180. |-------------------------------| <- SP
  181. |///////////////////////////////|
  182. |// implementation dependent //|
  183. |///////////////////////////////|
  184. |-------------------------------| <- HP
  185. | |
  186. | heap area |
  187. | |
  188. | |
  189. |-------------------------------|
  190. | |
  191. | global area |
  192. | |
  193. EB -> |-------------------------------|
  194. | |
  195. | |
  196. | program text | <- PC
  197. | |
  198. | |
  199. PB -> |-------------------------------|
  200. |///////////////////////////////|
  201. |////////// undefined //////////|
  202. |///////////////////////////////|
  203. 0 -> |-------------------------------|
  204. Fig. \nf. Example of memory layout showing typical register
  205. positions during execution of an EM program.
  206. .fi
  207. .SB "Data addresses as arguments"
  208. .PP
  209. Anywhere previous versions of the EM assembly language
  210. allowed identifiers of objects in
  211. data space,
  212. it is also possible to use 'identifier+constant' or 'identifier-constant'.
  213. For example, both "CON LABEL+4" and "LAE SAVED+3" are allowed.
  214. More complicated expressions are illegal.
  215. .SB "Local data area"
  216. .PP
  217. The mark block has been banished.
  218. When calling a procedure,
  219. the calling routine first has to push the actual parameters.
  220. All language implementations currently push their arguments
  221. in reverse order, to be compatible with C.
  222. Then the procedure is called using a CAL or CAI instruction.
  223. Either the call or the procedure prolog somehow has to save
  224. the return address and dynamic link.
  225. The prolog allocates the space needed for locals and is free to
  226. surround this space with saved registers and other information it
  227. deems necessary.
  228. .PP
  229. The locals are now accessed using negative offsets in LOL, LDL, SDL, LAL,
  230. LIL, SIL and STL instructions.
  231. The parameters are accessed using positive offsets in LOL, LDL, SDL, LAL,
  232. LIL, STL and
  233. STL instructions.
  234. The prolog might have stored information in the area between parameters and
  235. locals.
  236. As a consequence there are two bases, AB(virtual) and LB.
  237. AB stands for Argument Base and LB stands for Local Base.
  238. Positive arguments to LOL etc ... are interpreted as offsets from AB,
  239. negative arguments as offsets from LB.
  240. .PP
  241. The BEG instruction is not needed to allocate the locals because
  242. storage for locals is set aside in the prolog.
  243. The instruction still exists under the name ASP (Adjust Stack Pointer).
  244. .PP
  245. Procedures return using the RET instruction.
  246. The RET pops the function result from the stack and
  247. brings the stack pointer and other relevant registers to the state
  248. they had just before the procedure was called.
  249. The RET instruction expects that - aside from possible function results -
  250. the stack pointer has the value it had after execution of the prolog.
  251. RET finally returns control to the calling routine.
  252. The actual parameters have to be removed from the stack by the calling routine,
  253. and not by the called procedure.
  254. .sp 1
  255. .ne 38
  256. .nf
  257. |===============================|
  258. | actual argument n |
  259. |-------------------------------|
  260. | . |
  261. | . |
  262. | . |
  263. |-------------------------------|
  264. | actual argument 1 | ( <- AB )
  265. |===============================|
  266. |///////////////////////////////|
  267. |// implementation dependent //|
  268. |///////////////////////////////| <- LB
  269. |===============================|
  270. | |
  271. | local variables |
  272. | |
  273. |-------------------------------|
  274. | |
  275. | compiler temporaries |
  276. | |
  277. |===============================|
  278. |///////////////////////////////|
  279. |// implementation dependent //|
  280. |///////////////////////////////|
  281. |===============================|
  282. | |
  283. | dynamic local generators |
  284. | |
  285. |===============================|
  286. | operand |
  287. |-------------------------------|
  288. | operand | <- SP
  289. |===============================|
  290. A sample procedure frame.
  291. .fi
  292. .sp 1
  293. This scheme allows procedures to be called with a variable number
  294. of parameters.
  295. The parameters have to be pushed in reverse order,
  296. because the called procedure has to be able to locate the first one.
  297. .PP
  298. .PP
  299. Since the mark block has disappeared, a new mechanism for static
  300. links had to be created.
  301. All compilers use the convention that EM procedures needing
  302. a static link will find a link in their zero'th parameter,
  303. i.e. the last one pushed on the stack.
  304. This parameter should be invisible to users of the compiler.
  305. The link needs to be in a fixed place because the lexical instructions
  306. have to locate it.
  307. The LEX instruction is replaced by two instructions: LXL and LXA.
  308. \&"LXL~n" finds the LB of a procedure n static levels removed.
  309. \&"LXA~n" finds the (virtual) AB.
  310. The value used for static link is LB.
  311. .PP
  312. When a procedure needing a static link is called, first the actual
  313. parameters are pushed, then the static link is pushed using LXL
  314. and finally the procedure is called with a CAL with the procedure's
  315. name as argument.
  316. .br
  317. .ne 40
  318. .nf
  319. |===============================|
  320. | actual argument n |
  321. |-------------------------------|
  322. | . |
  323. | . |
  324. | . |
  325. |-------------------------------|
  326. | actual argument 1 |
  327. |-------------------------------|
  328. | static link | ( <- AB )
  329. |===============================|
  330. |///////////////////////////////|
  331. |// implementation dependent //|
  332. |///////////////////////////////| <- LB
  333. |===============================|
  334. | |
  335. | local variables |
  336. | |
  337. |-------------------------------|
  338. | |
  339. | compiler temporaries |
  340. | |
  341. |===============================|
  342. |///////////////////////////////|
  343. |// implementation dependent //|
  344. |///////////////////////////////|
  345. |===============================|
  346. | |
  347. | dynamic local generators |
  348. | |
  349. |===============================|
  350. | operand |
  351. |-------------------------------|
  352. | operand | <- SP
  353. |===============================|
  354. A procedure frame with static link.
  355. .fi
  356. .sp 1
  357. .sp 1
  358. .PP
  359. Pascal and other languages have to use procedure
  360. instance identifiers containing
  361. the procedure identifier
  362. 'ul
  363. and
  364. the static link the procedure has to be called with.
  365. A static link having a value of zero signals
  366. that the called procedure does not need a static link.
  367. C uses the same convention for pointers to C-routines.
  368. In pointers to C-routines the static link is set to zero.
  369. .PP
  370. Note: The distance from LB to AB must be known for each procedure, otherwise
  371. LXA can not be implemented.
  372. Most implementations will have a fixed size area between
  373. the parameter and local storage.
  374. The zone between the compiler temporaries and the dynamic
  375. local generators can be used
  376. to save a variable number of registers.
  377. .PP
  378. .ne 11
  379. Prolog examples:
  380. .sp 2
  381. .nf
  382. proc1 proc2
  383. mov lb,-(sp) mov lb,-(sp)
  384. mov sp,lb mov sp,lb
  385. sub $loc_size,sp sub $loc_size,sp
  386. mov r2,-(sp) ; save r2 mov r2,-(sp)
  387. mov r4,-(sp) ; save r4
  388. .fi
  389. .SB "Return values"
  390. .PP
  391. The return value popped by RET is stored in an unnamed 'function return area'.
  392. This area can be different for different sized objects returned,
  393. e.g. one register for two byte objects,
  394. two registers for four byte objects,
  395. memory for larger objects.
  396. The area is available for 'READ-ONCE' access using the LFR instruction.
  397. The result of a LFR is only defined if the sizes used to store and
  398. fetch are identical.
  399. The only instructions guaranteed not to destroy the contents of
  400. any 'function return area' are ASP and BRA.
  401. Thus parameters can be popped before fetching the function result.
  402. The maximum size of all function return areas is
  403. implementation dependant,
  404. but allows procedure instance identifiers and all
  405. implemented objects of type integer, unsigned, float
  406. and pointer to be returned.
  407. .SE "EM Assembly Language"
  408. .nr b 0 1
  409. .SB "Object types and instructions"
  410. .PP
  411. EM knows five basic object types:
  412. pointers,
  413. signed integers,
  414. unsigned integers,
  415. floating point numbers and
  416. sets of bits.
  417. Operations on objects of the last four types do not assume
  418. a specific size.
  419. Pointers (including procedure identifiers) have a fixed size in each
  420. implementation.
  421. Instructions acting on one or more objects of the last four types need
  422. explicit size information.
  423. This information can be given either as the argument of the
  424. instruction or on top of the stack.
  425. .sp 1
  426. For example:
  427. .nf
  428. addition of integers LOL a, LOL b, ADI 2
  429. subtraction of two floats LDL a, LDL b, SBF 4
  430. integer to float LOL a, LOC 2, LOC 4, CIF, SDL b
  431. .fi
  432. .sp
  433. Note that conversion instructions always expect size
  434. before and size after conversion on the stack.
  435. .sp
  436. No obligation exists to implement all operations on all possible sizes.
  437. .PP
  438. The EM assembly language
  439. allows constants as instruction arguments up to a size of four bytes.
  440. In all EM's it is possible to initialize any type and size object.
  441. BSS, HOL, CON and ROM allow type and size indication in initializers.
  442. .SB "Conversion instructions"
  443. .PP
  444. The conversion operators can convert from any type and size to any
  445. type and size.
  446. The types are specified by the instruction,
  447. the sizes should be in words on top of the stack.
  448. Normally the sizes are multiples of the word size,
  449. There is one exception: the CII instructions sign-extends if the
  450. size of the source is a divisor of the word size.
  451. .SB "CSA and CSB"
  452. .PP
  453. The tables used by these instructions do not contain the procedure
  454. identifier any more.
  455. See also "Descriptors".
  456. .SB EXG
  457. .PP
  458. The EXG instruction is deleted from the EM instruction set.
  459. If future applications show any need for this instruction,
  460. it will be added again.
  461. .SB "FIL"
  462. .PP
  463. A FIL instruction has been introduced.
  464. When using separate compilation,
  465. the LIN feature of EM was insufficient.
  466. FIL expects as argument an address in global data.
  467. This address is stored in a fixed place in memory,
  468. where it can be used by any implementation for diagnostics etc.
  469. Like LIN, it provides access to the ABS fragment at the start
  470. of external data.
  471. .SB "LAI and SAI"
  472. .PP
  473. LAI and SAI have been dropped, they thwarted register optimization.
  474. .SB LNC
  475. .PP
  476. The LNC instruction is deleted from the instruction set.
  477. LOC -n wil do what it is supposed to.
  478. .SB "Branch instructions"
  479. .PP
  480. The branch instructions are allowed to branch both forward and backward.
  481. Consequently BRF and BRB are deleted and a BRA instruction is added.
  482. BRA branches unconditionally in any direction.
  483. .SB LDC
  484. .PP
  485. Loads a double word constant on the stack.
  486. .SB LEX
  487. .PP
  488. LXA and LXL replace LEX.
  489. .SB LFR
  490. .PP
  491. LFR loads the function result stored by RET.
  492. .SB "LIL and SIL"
  493. .PP
  494. They replace LOP and STP. (Name change only)
  495. .SB "Traps and Interrupts"
  496. .PP
  497. The numbers used for distinguishing the various types
  498. of traps and interrupts have been reassigned.
  499. The new instructions LIM and SIM
  500. allow setting and clearing of bits in a mask.
  501. The bits in the mask control the action taken upon encountering certain
  502. errors at runtime.
  503. A 1 bit causes the corresponding error to be ignored,
  504. a 0 bit causes the run-time system to trap.
  505. .SB LPI
  506. .PP
  507. Loads a procedure identifier on the stack.
  508. LOC cannot be used to do this anymore.
  509. .SB "ZER and ZRF"
  510. .PP
  511. ZER loads S zero bytes on the stack.
  512. ZRF loads a floating point zero of size S.
  513. .SB "Descriptors"
  514. .PP
  515. All instructions using descriptors have the size of the integer used
  516. in the descriptor as argument.
  517. The descriptors are: case descriptors (CSA and CSB),
  518. range check descriptors (RCK) and
  519. array descriptors ( LAR, SAR, AAR).
  520. .SB "Case descriptors"
  521. .PP
  522. The value used in a case descriptor to indicate the absence of a label
  523. is zero instead of -1.
  524. .SE "EM assembly language"
  525. .SB "Instruction arguments"
  526. .PP
  527. The previous EM had different instructions for distinguishing
  528. between operand on the stack and explicit argument in the instruction.
  529. For example, LOI and LOS.
  530. This distinction has been removed.
  531. Several instructions have two possible forms:
  532. with explicit argument and with implicit argument on top of the stack.
  533. The size of the implicit argument is the word size.
  534. The implicit argument is always popped before all other operands.
  535. Appendix 1 shows what is allowed for each instruction.
  536. .SB Notation
  537. .PP
  538. First the notation used for the arguments of
  539. instructions and pseudo instructions.
  540. .in +12
  541. .ti -11
  542. <num>~~=~~an integer number in the range -32768..32767
  543. .ti -11
  544. <off>~~=~~an offset -2**31..2**31~-~1
  545. .ti -11
  546. <sym>~~=~~an identifier
  547. .ti -11
  548. <arg>~~=~~<off> or <sym> or <sym>+<off> or <sym>-<off>
  549. .ti -11
  550. <con>~~=~~integer constant,
  551. unsigned constant,
  552. floating point constant
  553. .ti -11
  554. <str>~~=~~string constant (surrounded by double quotes),
  555. .ti -11
  556. <lab>~~=~~instruction label ('*' followed by an integer in the range
  557. 0..32767).
  558. .ti -11
  559. <pro>~~=~~procedure number ('$' followed by a procedure name)
  560. .ti -11
  561. <val>~~=~~<arg>,
  562. <con>,
  563. <pro> or
  564. <lab>.
  565. .ti -11
  566. <...>*~=~~zero or more of <...>
  567. .ti -11
  568. <...>+~=~~one or more of <...>
  569. .ti -11
  570. [...]~~=~~optional ...
  571. .in -12
  572. .SB Labels
  573. .PP
  574. No label, instruction or data, can have a (pseudo) instruction
  575. on the same line.
  576. .SB Constants
  577. .PP
  578. All constants in EM are interpreted in the decimal base.
  579. .PP
  580. In BSS, HOL, CON and ROM pseudo-instructions
  581. numbers must be followed by I, U or F
  582. indicating Integer, Unsigned or Float.
  583. If no character is present I is assumed.
  584. This character can be followed by an even positive number or a 1.
  585. The number indicates the size in bytes of the object to be initialized,
  586. up to 32766.
  587. Double precision integers can no longer be indicated by a trailing L.
  588. As said before CON and ROM also allow expressions of the form:
  589. \&"LABEL+offset" and "LABEL-offset".
  590. The offset must be an unsigned decimal number.
  591. The 'IUF' indicators cannot be used with the offsets.
  592. .PP
  593. Areas reserved in the global data area by HOL or BSS can be
  594. initialized.
  595. BSS and HOL have a third parameter indicating whether the initialization
  596. is mandatory or optional.
  597. .PP
  598. Since EM needs aligment of objects, this alignment is enforced by the
  599. pseudo instructions.
  600. All objects are aligned on a multiple of their size or the word size
  601. whichever is smaller.
  602. Switching to another type of fragment or placing a label forces word-alignment.
  603. There are three types of fragments in global data space: CON, ROM and BSS-HOL.
  604. .sp
  605. .SB "Pseudo instructions"
  606. .PP
  607. The LET, IMC and FWC pseudo's have disappeared.
  608. The only application of these pseudo's was in postponing the
  609. specification of the size of the local storage to just before
  610. the END of the procedure.
  611. A new mechanism has been introduced to handle this problem.
  612. .ti +5
  613. The pseudos involved in separate compilation and linking have
  614. been reorganized.
  615. .ti +5
  616. PRO and END are altered and reflect the new calling sequence.
  617. EOF has disappeared.
  618. .ti +5
  619. BSS and HOL allow initialization of the requested data areas.
  620. .sp 2
  621. Four pseudo instructions request global data:
  622. .sp 2
  623. BSS <off>,<val>,<num>
  624. .IN
  625. Reserve <off> bytes.
  626. <val> is the value used to initialize the area.
  627. <off> must be a multiple of the size of <val>.
  628. <num> is 0 if the initialization is not strictly necessary,
  629. 1 otherwise.
  630. .OU
  631. .sp
  632. HOL <off>,<val>,<num>
  633. .IN
  634. Idem, but all following absolute global data references will
  635. refer to this block.
  636. Only one HOL is allowed per procedure,
  637. it has to be placed before the first instruction.
  638. .OU
  639. .sp
  640. CON <val>+
  641. .IN
  642. Assemble global data words initialized with the <val> constants.
  643. .OU
  644. .sp
  645. ROM <val>+
  646. .IN
  647. Idem, but the initialized data will never be changed by the program.
  648. .OU
  649. .sp 2
  650. Two pseudo instructions partition the input into procedures:
  651. .sp 2
  652. PRO <sym>[,<off>]
  653. .IN
  654. Start of procedure.
  655. <sym> is the procedure name.
  656. <off> is the number of bytes for locals.
  657. The number of bytes for locals must be specified in the PRO or
  658. END pseudo-instruction.
  659. When specified in both, they must be identical.
  660. .OU
  661. .sp
  662. END [<off>]
  663. .IN
  664. End of Procedure.
  665. <off> is the number of bytes for locals.
  666. The number of bytes for locals must be specified in either the PRO or
  667. END pseudo-instruction or both.
  668. .OU
  669. .PP
  670. Names of data and procedures in a EM module can either be
  671. internal or external.
  672. External names are known outside the module and are used to link
  673. several pieces of a program.
  674. Internal names are not known outside the modules they are used in.
  675. Other modules will not 'see' an internal name.
  676. .ti +5
  677. In order to reduce the number of passes needed,
  678. it must be known at the first occurrence whether
  679. a name is internal or external.
  680. If the first occurrence of a name is in a definition,
  681. the name is considered to be internal.
  682. If the first occurrence of a name is a reference,
  683. the name is considered to be external.
  684. If the first occurrence is in one of the following pseudo instructions,
  685. the effect of the pseudo has precedence.
  686. .sp 2
  687. EXA <sym>
  688. .IN
  689. External name.
  690. <sym> is external to this module.
  691. Note that <sym> may be defined in the same module.
  692. .OU
  693. .sp
  694. EXP <pro>
  695. .IN
  696. External procedure identifier.
  697. Note that <sym> may be defined in the same module.
  698. .OU
  699. .sp
  700. INA <sym>
  701. .IN
  702. Internal name.
  703. <sym> is internal to this module and must be defined in this module.
  704. .OU
  705. .sp
  706. INP <pro>
  707. .IN
  708. Internal procedure.
  709. <sym> is internal to this module and must be defined in this module.
  710. .OU
  711. .sp 2
  712. Two other pseudo instructions provide miscellaneous features:
  713. .sp 2
  714. EXC <num1>,<num2>
  715. .IN
  716. Two blocks of instructions preceding this one are
  717. interchanged before being processed.
  718. <num1> gives the number of lines of the first block.
  719. <num2> gives the number of lines of the second one.
  720. Blank and pure comment lines do not count.
  721. This instruction is obsolete. Its use is strongly discouraged.
  722. .OU
  723. .sp
  724. MES <num>,<val>*
  725. .IN
  726. A special type of comment. Used by compilers to communicate with the
  727. optimizer, assembler, etc. as follows:
  728. .br
  729. MES 0 -
  730. .IN
  731. An error has occurred, stop further processing.
  732. .OU
  733. .br
  734. MES 1 -
  735. .IN
  736. Suppress optimization
  737. .OU
  738. .br
  739. MES 2,<num1>,<num2>
  740. .IN
  741. Use word-size <num1> and pointer size <num2>.
  742. .OU
  743. .br
  744. MES 3,<off>,<num1>,<num2> -
  745. .IN
  746. Indicates that a local variable is never referenced indirectly.
  747. <off> is offset in bytes from LB if positive
  748. and offset from AB if negative.
  749. <num1> gives the size of the variable.
  750. <num2> indicates the class of the variable.
  751. .OU
  752. .br
  753. MES 4,<num>,<str>
  754. .IN
  755. Number of source lines in file <str> (for profiler).
  756. .OU
  757. .br
  758. MES 5 -
  759. .IN
  760. Floating point used.
  761. .OU
  762. .br
  763. MES 6,<val>* -
  764. .IN
  765. Comment. Used to provide comments in compact assembly language (see below).
  766. .OU
  767. .sp 1
  768. Each back end is free to skip irrelevant MES pseudos.
  769. .OU
  770. .SB "The Compact Assembly Language"
  771. .PP
  772. The assembler accepts input in a highly encoded form. This
  773. form is intended to reduce the amount of file transport between the compiler
  774. and assembler, and also reduce the amount of storage required for storing
  775. libraries.
  776. Libraries are stored as archived compact assembly language, not machine language.
  777. .PP
  778. When beginning to read the input, the assembler is in neutral state, and
  779. expects either a label or an instruction (including the pseudoinstructions).
  780. The meaning of the next byte(s) when in neutral state is as follows, where b1, b2
  781. etc. represent the succeeding bytes.
  782. .sp
  783. 0 Reserved for future use
  784. 1-129 Machine instructions, see Appendix 2, alphabetical list
  785. 130-149 Reserved for future use
  786. 150-161 BSS,CON,END,EXC,EXA,EXP,HOL,INA,INP,MES,PRO,ROM
  787. 162-179 Reserved for future pseudoinstructions
  788. 180-239 Instruction labels 0 - 59 (180 is local label 0 etc.)
  789. 240-244 See the Common Table below
  790. 245-255 Not used
  791. After a label, the assembler is back in neutral state; it can immediately
  792. accept another label or an instruction in the very next byte. There are
  793. no linefeeds used to separate lines.
  794. .PP
  795. If an opcode expects no arguments,
  796. the assembler is back in neutral state after
  797. reading the one byte containing the instruction number. If it has one or
  798. more arguments (only pseudos have more than 1), the arguments follow directly,
  799. encoded as follows:
  800. .sp
  801. 0-239 Offsets from -120 to 119
  802. .br
  803. 240-255 See the Common Table below
  804. .sp 2
  805. If an opcode has one optional argument,
  806. a special byte is used to announce that the argument is not present.
  807. .ce 1
  808. Common Table for Neutral State and Arguments
  809. .sp
  810. .nf
  811. <lab> 240 b1 Instruction label b1 (Not used for branches)
  812. <lab> 241 b1 b2 16 bit instruction label (256*b2 + b1)
  813. <sym> 242 b1 Global label .0-.255, with b1 being the label
  814. <sym> 243 b1 b2 Global label .0-.32767
  815. with 256*b2+b1 being the label
  816. <sym> 244 <string> Global symbol not of the form .nnn
  817. . \" Only the previous can occur in neutral state.
  818. <num> 245 b1 b2 (16 bit constant) 256*b2+b1
  819. <off> 246 b1 b2 b3 b4 (32 bit constant) (256*(256*(256*b4)+b3)+b2)+b1
  820. <arg> 247 <sym><off> Global label + (possibly negative) constant
  821. <pro> 248 <string> Procedure name (not including $)
  822. <str> 249 <string> String used in CON or ROM (no quotes)
  823. <con> 250 <num><string> Integer constant, size <num> bytes
  824. <con> 251 <num><string> Unsigned constant, size <num> bytes
  825. <con> 252 <num><string> Floating constant, size <num> bytes
  826. <end> 255 Delimiter for argument lists or
  827. indicates absence of optional argument
  828. .fi
  829. .PP
  830. The notation <string> consists first of a length field, and then an
  831. arbitrary string of bytes.
  832. The length is specified by a <num>.
  833. .PP
  834. .ne 8
  835. The pseudoinstructions fall into several categories, depending on their
  836. arguments:
  837. .sp
  838. Group 1 -- EXC, BSS, HOL have a known number of arguments
  839. Group 2 -- EXA, EXP, INA, INP start with a string
  840. Group 3 -- CON, MES, ROM have a variable number of various things
  841. Group 4 -- END, PRO have a trailing optional argument.
  842. Groups 1 and 2
  843. use the encoding described above.
  844. Group 3 also uses the encoding listed above, with a <end> byte after the
  845. last argument to indicate the end of the list.
  846. Group 4 uses
  847. a <end> byte if the trailing argument is not present.
  848. .ad
  849. .fi
  850. .sp 2
  851. .ne 12
  852. .nf
  853. Example ASCII Example compact
  854. (LOC = 66, BRA = 18 here):
  855. 2 182
  856. 1 181
  857. LOC 10 66 130
  858. LOC -10 66 110
  859. LOC 300 66 245 44 1
  860. BRA 19 18 139
  861. 300 241 44 1
  862. .3 242 3
  863. CON 4,9,*2,$foo 151 124 130 240 2 248 3 102 111 111 255
  864. LOC .35 66 242 35
  865. .fi
  866. .nr a 0 1
  867. .SE "ASSEMBLY LANGUAGE INSTRUCTION LIST"
  868. .PP
  869. For each instruction in the list the range of operand values
  870. in the assembly language is given.
  871. All constants, offsets and sizes are in the range -2**31~..~2**31-1.
  872. The column headed \fIassem\fP contains the mnemonics defined
  873. in 4.1.
  874. The following column indicates restrictions in the range of the operand.
  875. Addresses have to obey the restrictions mentioned in chapter 2 - Memory -.
  876. The size parameter of most instructions has to be a multiple
  877. of the word size.
  878. The classes of operands
  879. are indicated by letters:
  880. .ds b \fBb\fP
  881. .ds c \fBc\fP
  882. .ds d \fBd\fP
  883. .ds g \fBg\fP
  884. .ds f \fBf\fP
  885. .ds l \fBl\fP
  886. .ds n \fBn\fP
  887. .ds i \fBi\fP
  888. .ds p \fBp\fP
  889. .ds r \fBr\fP
  890. .ds s \fBs\fP
  891. .ds z \fBz\fP
  892. .ds - \fB-\fP
  893. .nf
  894. \fIassem\fP constraints rationale
  895. \&\*c off 1-word constant
  896. \&\*d off 2-word constant
  897. \&\*l off local offset
  898. \&\*g arg >= 0 global offset
  899. \&\*f off fragment offset
  900. \&\*n num >= 0 counter
  901. \&\*s off > 0 object size
  902. \&\*z off >= 0 object size
  903. \&\*i off > 0 object size *
  904. \&\*p pro pro identifier
  905. \&\*b lab >= 0 label number
  906. \&\*r num 0,1,2 register number
  907. \&\*- no operand
  908. .fi
  909. .PP
  910. The * at the rationale for \*i indicates that the operand
  911. can either be given as argument or on top of the stack.
  912. If the operand has to be fetched from the stack,
  913. it is assumed to be a word-sized unsigned integer.
  914. .PP
  915. Instructions that check for undefined operands and underflow or overflow
  916. are indicated by (*).
  917. .nf
  918. GROUP 1 - LOAD
  919. LOC \*c : Load constant (i.e. push one word onto the stack)
  920. LDC \*d : Load double constant ( push two words )
  921. LOL \*l : Load word at \*l-th local (l<0) or parameter (l>=0)
  922. LOE \*g : Load external word \*g
  923. LIL \*l : Load word pointed to by \*l-th local or parameter
  924. LOF \*f : Load offsetted. (top of stack + \*f yield address)
  925. LAL \*l : Load address of local or parameter
  926. LAE \*g : Load address of external
  927. LXL \*n : Load lexical. (address of LB \*n static levels back)
  928. LXA \*n : Load lexical. (address of AB \*n static levels back)
  929. LOI \*s : Load indirect \*s bytes (address is popped from the stack)
  930. LOS \*i : Load indirect. \*i-byte integer on top of stack gives object size
  931. LDL \*l : Load double local or parameter (two consecutive words are stacked)
  932. LDE \*g : Load double external (two consecutive externals are stacked)
  933. LDF \*f : Load double offsetted (top of stack + \*f yield address)
  934. LPI \*p : Load procedure identifier
  935. GROUP 2 - STORE
  936. STL \*l : Store local or parameter
  937. STE \*g : Store external
  938. SIL \*l : Store into word pointed to by \*l-th local or parameter
  939. STF \*f : Store offsetted
  940. STI \*s : Store indirect \*s bytes (pop address, then data)
  941. STS \*i : Store indirect. \*i-byte integer on top of stack gives object size
  942. SDL \*l : Store double local or parameter
  943. SDE \*g : Store double external
  944. SDF \*f : Store double offsetted
  945. GROUP 3 - INTEGER ARITHMETIC
  946. ADI \*i : Addition (*)
  947. SBI \*i : Subtraction (*)
  948. MLI \*i : Multiplication (*)
  949. DVI \*i : Division (*)
  950. RMI \*i : Remainder (*)
  951. NGI \*i : Negate (two's complement) (*)
  952. SLI \*i : Shift left (*)
  953. SRI \*i : Shift right (*)
  954. GROUP 4 - UNSIGNED ARITHMETIC
  955. ADU \*i : Addition
  956. SBU \*i : Subtraction
  957. MLU \*i : Multiplication
  958. DVU \*i : Division
  959. RMU \*i : Remainder
  960. SLU \*i : Shift left
  961. SRU \*i : Shift right
  962. GROUP 5 - FLOATING POINT ARITHMETIC (Format not defined)
  963. ADF \*i : Floating add (*)
  964. SBF \*i : Floating subtract (*)
  965. MLF \*i : Floating multiply (*)
  966. DVF \*i : Floating divide (*)
  967. NGF \*i : Floating negate (*)
  968. FIF \*i : Floating multiply and split integer and fraction part (*)
  969. FEF \*i : Split floating number in exponent and fraction part (*)
  970. GROUP 6 - POINTER ARITHMETIC
  971. ADP \*f : Add \*c to pointer on top of stack
  972. ADS \*i : Add \*i-byte value and pointer
  973. SBS \*i : Subtract pointers in same fragment and push diff as size \*i integer
  974. GROUP 7 - INCREMENT/DECREMENT/ZERO
  975. INC \*- : Increment top of stack by 1 (*)
  976. INL \*l : Increment local or parameter (*)
  977. INE \*g : Increment external (*)
  978. DEC \*- : Decrement top of stack by 1 (*)
  979. DEL \*l : Decrement local or parameter (*)
  980. DEE \*g : Decrement external (*)
  981. ZRL \*l : Zero local or parameter
  982. ZRE \*g : Zero external
  983. ZRF \*i : Load a floating zero of size \*i
  984. ZER \*i : Load \*i zero bytes
  985. GROUP 8 - CONVERT ( stack: source, source size, dest. size (top) )
  986. CII \*- : Convert integer to integer (*)
  987. CUI \*- : Convert unsigned to integer (*)
  988. CFI \*- : Convert floating to integer (*)
  989. CIF \*- : Convert integer to floating (*)
  990. CUF \*- : Convert unsigned to floating (*)
  991. CFF \*- : Convert floating to floating (*)
  992. CIU \*- : Convert integer to unsigned
  993. CUU \*- : Convert unsigned to unsigned
  994. CFU \*- : Convert floating to unsigned
  995. GROUP 9 - LOGICAL
  996. AND \*i : Boolean and on two groups of \*i bytes
  997. IOR \*i : Boolean inclusive or on two groups of \*i bytes
  998. XOR \*i : Boolean exclusive or on two groups of \*i bytes
  999. COM \*i : Complement (one's complement of top \*i bytes)
  1000. ROL \*i : Rotate left a group of \*i bytes
  1001. ROR \*i : Rotate right a group of \*i bytes
  1002. GROUP 10 - SETS
  1003. INN \*i : Bit test on \*i byte set (bit number on top of stack)
  1004. SET \*i : Create singleton \*i byte set with bit n on (n is top of stack)
  1005. GROUP 11 - ARRAY
  1006. LAR \*i : Load array element, descriptor contains integers of size \*i
  1007. SAR \*i : Store array element
  1008. AAR \*i : Load address of array element
  1009. GROUP 12 - COMPARE
  1010. CMI \*i : Compare \*i byte integers. Push negative, zero, positive for <, = or >
  1011. CMF \*i : Compare \*i byte reals
  1012. CMU \*i : Compare \*i byte unsigneds
  1013. CMS \*i : Compare \*i byte sets. can only be used for equality test.
  1014. CMP \*- : Compare pointers
  1015. TLT \*- : True if less, i.e. iff top of stack < 0
  1016. TLE \*- : True if less or equal, i.e. iff top of stack <= 0
  1017. TEQ \*- : True if equal, i.e. iff top of stack = 0
  1018. TNE \*- : True if not equal, i.e. iff top of stack non zero
  1019. TGE \*- : True if greater or equal, i.e. iff top of stack >= 0
  1020. TGT \*- : True if greater, i.e. iff top of stack > 0
  1021. GROUP 13 - BRANCH
  1022. BRA \*b : Branch unconditionally to label \*b
  1023. BLT \*b : Branch less (pop 2 words, branch if top > second)
  1024. BLE \*b : Branch less or equal
  1025. BEQ \*b : Branch equal
  1026. BNE \*b : Branch not equal
  1027. BGE \*b : Branch greater or equal
  1028. BGT \*b : Branch greater
  1029. ZLT \*b : Branch less than zero (pop 1 word, branch negative)
  1030. ZLE \*b : Branch less or equal to zero
  1031. ZEQ \*b : Branch equal zero
  1032. ZNE \*b : Branch not zero
  1033. ZGE \*b : Branch greater or equal zero
  1034. ZGT \*b : Branch greater than zero
  1035. GROUP 14 - PROCEDURE CALL
  1036. CAI \*- : Call procedure (procedure instance identifier on stack)
  1037. CAL \*p : Call procedure (with name \*p)
  1038. LFR \*s : Load function result
  1039. RET \*z : Return (function result consists of top \*z bytes)
  1040. GROUP 15 - MISCELLANEOUS
  1041. ASP \*f : Adjust the stack pointer by \*f
  1042. ASS \*i : Adjust the stack pointer by \*i-byte integer
  1043. BLM \*z : Block move \*z bytes; first pop destination addr, then source addr
  1044. BLS \*i : Block move, size is in \*i-byte integer on top of stack
  1045. CSA \*i : Case jump; address of jump table at top of stack
  1046. CSB \*i : Table lookup jump; address of jump table at top of stack
  1047. DUP \*s : Duplicate top \*s bytes
  1048. DUS \*i : Duplicate top \*i bytes
  1049. FIL \*g : File name (external 4 := \*g)
  1050. LIM \*- : Load 16 bit ignore mask
  1051. LIN \*n : Line number (external 0 := \*n)
  1052. LNI \*- : Line number increment
  1053. LOR \*r : Load register (0=LB, 1=SP, 2=HP)
  1054. MON \*- : Monitor call
  1055. NOP \*- : No operation
  1056. RCK \*i : Range check; trap on error
  1057. RTT \*- : Return from trap
  1058. SIG \*- : Trap errors to proc nr on top of stack (-2 resets default). Static
  1059. link of procedure is below procedure number. Old values returned
  1060. SIM \*- : Store 16 bit ignore mask
  1061. STR \*r : Store register (0=LB, 1=SP, 2=HP)
  1062. TRP \*- : Cause trap to occur (Error number on stack)
  1063. .fi