$a invert=0; cap=0; capsh=0; und=0; undsh=0 $a line=80; page=0; top=0; bottom=0 $l APM IMP Compiler -- Version 2 $b The IMP compiler translates programs written in the high-level language IMP to M68000 native code. $b The operation of the compiler is very similar to the APM Pascal compiler -- for example, the available options are identical. $b$l0 ! ! ! $t+ produce object file with specified name $b0 (the extension .MOB is added unless present already) $b$t- -OFILE=:N $t+ do not produce object file $b$t- -FORCE $t+ produce object file even if program faulty $a indent=0 $l3 !> !> ! $t+ send listing to specified file $b0 (the extension .LIS is added unless already present) $b$t- -TT $t+ send listing to terminal $b $t- -MAP $t+ output information at end of each procedure, indicating size of code, etc. $b1$t- -LOG $t+ print statistics at end of compilation indicating number of statements, atoms per statement, identifiers per statement, time taken, etc. $l1 !PAGE $t1 {The following may not be available in the standard release} $b$t- -CODE $t+ print hybrid assembly language interpretation of code generated for each statement. This is before address fix-up and branch shortening, and so does not fully reflect the final code $b$t- -DICT $t+ print dictionary entries for identifiers $a indent=0 $b$l3 !> !> ! !> ! ! ! ! !<%OPTION $b Compiler options are generally established at the outset in the command used to call the compiler. However, most of them may also be switched off and on within the program text by means of the directive $b$l0 %OPTION "...." for example %OPTION "-NOWARN-NOLIST" $b The quoted string must consist of a sequence of Option keywords each preceded by a dash (hyphen). $b$l2 Caution: indiscriminate variation of checking options within a program can create considerable confusion for debugging. $b The effect of options is localised to the current procedure or block. $b$l2 !> !<%INCLUDE $b Other files may be included in the source by means of the directive $b$l0 %INCLUDE "...." for example %INCLUDE "GRAPHICS.IMP-NOCHECK" $b The quoted string specifies the name of the file together with any Options to be applied to it. These Options, and any which are specified within the included file itself, are localised to this file. $b Include files may be nested to a maximum of three. $b$l2 !> ! !> ! may be placed in front of a variable or procedure declaration to indicate that the corresponding entity is to be addressed at the location indicated. The may be either an absolute value or a register-relative value. For example: $l0 @16_041234 %byte DEVICE STATUS @16_1BC8 %routine ABANDON (formally equivalent to an %external %spec) @4(A5) %integer USERNO $b Caution: this is a Low-level facility $b$l2 !> ! !> !> ! ! !> ! ! !> ! void identifier is used before a value is assigned to it (warning only) missing forward label or specced identifier does not appear in block (?) missing switch label to which there is an explicit jump has not been specified extra values for too many values for %const or %own array Faulty operand incorrect operand type for machine instruction Wrong size operand is of incorrect size for machine instruction !PAGE Too complex! compiler limitation exceeded (eg no free register) Internal error ! compiler fault Out of reach! %const or literal string, record or array is not within the range of the machine addressing capability Out of reach! call to procedure specified is not within the range of the machine addressing capability In the case of programs which exceed 32k bytes in size, the compiler uses a number of techniques to avoid creating within-program references which breach the M68000 PC-relative addressing limitation of +-32k. There is a possibility in some cases that these do not succeed, leading to an 'out-of-reach' report. If a name is given in the report, it is that of a procedure which is too distant from one of its calls. If no name is given, the problem is access to a constant. $l2 !PAGE Disastrous errors $b These reports relate to compiler limits being exceeded. They all cause compilation to be abandoned. $l0 ** Program too big Total size of the compiled code and constants exceeds the maximum allowed for (see Option -KBYTES) ** Code space exhausted Size of the code for currently open blocks exceeds the maximum allowed for ** Identifiers too big Total length of all current identifiers exceeds the maximum allowed for (see Option -IDENTS) ** Too many identifiers Number of current identifiers exceeds the maximum allowed for (see Option -IDENTS) ** Too many levels Depth of textual nesting of blocks exceeds the maximum permitted (8) ** Too many literals Internal storage space for literals is exhausted ** Input ended There is no %endofprogram or %endoffile statement ** Too many nested includes There are more than three levels of nesting $b$l2 !> ! -ARR Integer arithmetic overflow 1 1 -OVER Real arithmetic overflow 1 2 -OVER Division by zero (integer or real) 1 4 none Trig function error 10 none Assignment value out-of-range 6 1 -CAP Value parameter out-of-range 6 1 -CAP Switch label not catered for taken as at %end [warning issued at compile-time] Name variable NIL 8 1 -ASS Name variable undefined 8 1 -ASS File system error 3 x none Non-numeric character for numeric READ 4 1 End-of-input 9 none $b$l3 !> !> ! ! modes. Immediate and Address register variants of op-codes are selected automatically. By comparison with full Assembler, most of the directives do not apply; assembly-time expression evaluation is restricted; size specification in cases where the size is implicit in the op-code is not in general allowed; the indexed PC-relative mode is not supported, nor is the 'current location counter'. $b The error report 'Faulty operand' indicates use of an invalid operand for the context, but the compiler does not fully check the validity of modes for the particular instruction. $b NB the default 'size' applied is Long (32-bits) rather than Word (16-bits) which is the manufacturer's default. Programmers may choose to make a practice of including the size suffix explicitly for all relevant instructions. $l !PAGE $b The special mnemonics USP (User Stack Pointer), SR (Status Register) and CCR (Condition Code Register) are NOT supported but the relevant effects can be achieved by use of the additional op-codes: $l0 MTCCR for MOVE ,CCR MTSR for MOVE ,SR MFSR for MOVE SR, MTUSP An for MOVE An,USP MFUSP An for MOVE USP,An ATCCR # for AND #,CCR ATSR # for AND #,SR ETCCR # for EOR #,CCR ETSR # for EOR #,SR OTCCR # for OR #,CCR OTSR # for OR #,SR $l !PAGE $b IMP identifiers may also be used as operands for assembly language instructions. The detailed implications of this over the whole range of data types are fairly complex and subject to change. The following cases are reasonably straightforward and stable. Scalar variables or elements of scalar records may be used as operands provided that they are: $l4 declared as own or declared at the outermost level or declared at the current level or declared by means of a fixed-address declaration Variables declared at intermediate levels should not be accessed since they are not necessarily directly addressable. In the case of a %name variable the effective operand is the pointer value (32-bit address) rather than the referenced object. $l !PAGE $b Labels and procedure names may be referenced in the Branch group of instructions, including BSR. The only alternative form of operand for these instructions is immediate (eg *BLT #-4), the value specified being the machine-level displacement. Short and long branches are handled automatically (though the Compiler's CODE listing does not show this). To access a forward label in an assembly language instruction, it is neccesary for the label to have been declared by means of the IMP declaration $%LABEL . $b The registers D0-D3 and A0-A3 may be freely used within assembly sections, but no assumptions can be made about their contents after execution of most IMP statements. Other registers may be used only on the basis that their values are restored before reverting to IMP. In particular this applies to SP. In addition, NOTE WELL that the accessing of local variables depends on SP; if SP is changed, access to such variables in machine instructions becomes a nonsense (though no error report can be made). Similarly, any modification of A4-A6 rules out access to non-local variables. $b Note that any declaration of IMP identifiers which co-incide with the register mnemonics takes precedence. $l2 !> !>