The IMP language and compiler P. D. Stephens Edinburgh Regional Computing Centre, University of Edinburgh, The King's Buildings, Mayfield Road, Edinburgh EH9 3JZ The EMAS general purpose time sharing system is notable for being coded entirely in IMP, a high level language, which was developed from Manchester University's Atlas Autocode specifically for system programming. This paper describes the main features of the language and the implementation used for EMAS. (Received June 1973) The development of IMP was an integral part of the EMAS project (Whitfield and Wight, 1973) to write a multi-access operating system for the ICL 4-75 computer. The language was to be based on Atlas Autocode (Brooker, Rohl and Clark, 1966) with sufficient additions to allow all the software to be written in it without resorting to assembly language. The long term intention was to enable large parts of the EMAS system to be transported to future ranges of hardware simply by recompilation. Atlas Autocode (AA) often seems, to those not familiar with this delightful and little known language, a curious starting point. 'Autocode' suggests, incorrectly, a low level language, while 'Atlas' implies an equally misleading machine dependence. In 1966 AA was widely used in Edinburgh University and a compiler (Bratley, Rees, Schofield and Whitfield, 1965) had been written for the University KDF9. This compiler, which was in advance of its time in that it was written entirely in Atlas Autocode, confirmed that AA was free from implementation trouble spots and reasonably suitable for system programming. Further, EMAPS was committed to supporting AA on the multi-access system, so it seemed sensible to economise in compiler writing effort by developing AA as the system programming language. It was the intention to follow the traditions of AA as far as possible and in particular to ensure 1. That keywords continued to be self-explanatory rather than cryptic. 2. That the language remained free of implementation trouble spots. 3. That facilities requiring extensive run time support were not included. 4. That the possibility of mechanical translation of IMP to PL/I should not be excluded. This last intention was designed (in 1966) to ensure that IMP programs and packages could be run at other installations throughout the world. This laudable aim has been invalidated by the limited availability of PL/I compilers particularly on British machines. In spite of being designed for system programming, IMP has been used extensively in Edinburgh for applications and general purpose programming. 1. The IMP language Alphabet The ISO (7-BIT) character set is used: A . . . Z a . . . z 0 . . . 9 + o # / < () = > , . : ; ' ? % @ - & # ! — ~ Names These consist of a letter, optionally followed by more letters and/or digits in any order. Keywords These are underlined as in ALGOL (in this publication bold face type is used), e.g. real. Blocks An ALGOL-like block structure is used. Blocks may be nested to any depth. They may be entered only via begin and left only via end. A program is a block starting with begin and terminating with endofprogram. Types The principal types are real, integer and string with declarations and scope as in ALGOL. Types real and integer can be further defined by byte, short and long, subject to hardware limitations. The length of string variables may vary, subject to a maximum length specified at declaration. This compromise gives most of the advantages of variable length strings without introducing the inefficiency of 'heap' storage. Space for variables is normally obtained from the stack at block entry. If, however, the variables are declared with the prefix own, they are placed in a special area constructed at compile time and allocated at program load time. Initialisation of own variables is permitted. Arithmetic expressions Expressions consist of real and integer variables and constants with the operators [MATH: +/ + - * / ** :MATH] +−∗/∗∗ () in the usual way. For example: given integer i, j; real array a(1: n); real x, y then [MATH: 2x< mo>∗2+i(j1)+a(i1)/3.14 2^x**2 + i(j - 1) + a(i - 1)/3.14 :MATH] 2∗x∗∗2+i∗(j−1)+a(i−1)/3.14 is an expression. The ALGOL integer division operator is available, represented by //. Logical expressions These consist of integer variables and constants and the operators: [MATH: ¬ representing logical not \neg \text{ representing logical not} :MATH] ¬ representing logical not [MATH: !or ! \quad \text{or} :MATH] !or [MATH: !!exclusive or !! \quad \text{exclusive or} :MATH] !!exclusive or & \quad \text{and} [MATH: <<left shift << \quad \text{left shift} :MATH] <>>right shift >> \quad \text{right shift} :MATH] >>right shift For example: given integer i, j, k then (i < < 16)! (j < < 8)! (k & 255) is a valid logical expression. Logical operations have proved very valuable in writing system software. String expressions A string expression consists of string variables and constants