# RTL/2

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/RTL/2
> Markdown URL: https://mediated.wiki/source/RTL/2.md
> Source: https://en.wikipedia.org/wiki/RTL%2F2
> Source revision: 1090768686
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

**RTL/2** (**Real-Time Language**) is a discontinued [high-level programming language](/source/High-level_programming_language) for use in [real-time computing](/source/Real-time_computing), developed at [Imperial Chemical Industries](/source/Imperial_Chemical_Industries), Ltd. (ICI), by [J.G.P. Barnes](/source/John_Barnes_(computer_scientist)). It was originally used internally in ICI but was distributed by SPL International in 1974.[1] It was based on concepts from [ALGOL 68](/source/ALGOL_68), and intended to be small and simple.[2][3][4] RTL/2 was standardised in 1980 by the [British Standards Institution](/source/British_Standards_Institution).[5]

## Language overview

The [data types](/source/Data_type) in RTL/2 were [strongly typed](/source/Strong_and_weak_typing), with separate [compiling](/source/Compiler). The [compilation units](/source/Translation_unit_(programming)) contained one or more items named *bricks*, i.e.:

- Procedure bricks
- Data bricks
- Stack bricks

A procedure brick was a [procedure](/source/Subroutine), which may or may not return a (scalar) value, have (scalar) parameters, or have local (scalar) [variables](/source/Variable_(computer_science)). The entry mechanism and implementation of [local variables](/source/Local_variable) was [reentrant](/source/Reentrancy_(computing)). Non-scalar data could only be accessed via reference (so-called REF variables were considered scalar).

A data brick was a named static collection of scalars, arrays and records. There was no heap or [garbage collection](/source/Garbage_collection_(computer_science)), so programmers had to implement [memory management](/source/Memory_management) manually.

A [stack](/source/Stack_(abstract_data_type)) brick was an area of storage reserved for running all the procedures of a single process and contained the call stack, local variables and other housekeeping items. The extent to which stack bricks were used varied depending on the host environment in which RTL/2 programs ran.

Access to the host environment of an RTL/2 program was provided via special procedure and data bricks called *SVC procedures* and *SVC data*. These were accessible in RTL/2 but implemented in some other language in the host environment.

## Hello World

TITLE Hello World;

LET NL=10;

EXT PROC(REF ARRAY BYTE) TWRT;

ENT PROC RRJOB() INT;
TWRT("Hello World#NL#");
RETURN(1);
ENDPROC;

## Embedded assembly

RTL/2 compiles to [assembly language](/source/Assembly_language) and provides the CODE statement to allow including assembly language in RTL/2 [source code](/source/Source_code). This is only available when compiled with a [systems programming](/source/Systems_programming) option (CN:F)

The CODE statement takes two operands: the number of bytes used by the code insert and the number of bytes of stack used.

Within code statements two trip characters are used to access RTL/2 variables. These vary between different [operating systems](/source/Operating_system). On a [Digital Equipment Corporation](/source/Digital_Equipment_Corporation) (DEC) [PDP-11](/source/PDP-11) running RSX-11M, and a [VAX](/source/VAX) running [VMS](/source/OpenVMS), the trip characters are * and /.

While the specifics varied by operating system the following is an example of a code insert on VAX/VMS:

CODE 6,0;
JMP CODE_ENT ; This code insert can be set to a fixed length as it jumps to a new psect.
; this method is especially useful on systems such as VMS where the length of
; instructions is variable
.SAVE_PSECT ; Save current program section
.PSECT ASMB_CODE,EXE,NOWRT,LONG
CODE_ENT:
MOVL *PARAM1(AP),*COUNTER/MYDATA
JMP CODE_EX
.RESTORE_PSECT
CODE_EX:
*RTL

This code insert moves the value of a variable passed into the RTL/2 procedure into a variable named COUNTER in a data brick named MYDATA.

## Reserved words

- ABS
- AND
- ARRAY
- BIN
- BLOCK
- BY
- BYTE
- CODE
- DATA
- DO
- ELSE
- ELSEIF
- END
- ENDBLOCK
- ENDDATA
- ENDPROC
- ENT
- EXT
- FOR
- FRAC
- GOTO
- HEX
- IF
- INT
- LABEL
- LAND
- LENGTH
- LET
- LOR
- MOD
- NEV
- NOT
- OCT
- OF
- OPTION
- OR
- PROC
- REAL
- REF
- REP
- RETURN
- RTL
- SHA
- SHL
- SLA
- SLL
- SRA
- SRL
- STACK
- SVC
- SWITCH
- THEN
- TITLE
- TO
- VAL
- WHILE

## References

1. Barnes, J.G.P. (September 1980). "The Standardisation of RTL/2". *Software: Practice and Experience*. **10** (9): 707–719. Wyley. [doi:10.1002/spe.4380100904](https://doi.org/10.1002/spe.4380100904). [S2CID 5050804](https://api.semanticscholar.org/CorpusID:5050804)

1. RTL/2 Language Specification

1. ["The Encyclopedia of Computer Languages"](https://web.archive.org/web/20110310112048/http://hopl.murdoch.edu.au/showlanguage2.prx?exp=596). Archived from [the original](http://hopl.murdoch.edu.au/showlanguage2.prx?exp=596#_jmp0_) on 10 March 2011.

1. Barnes, J.G.P. (1 January 1976). *RTL/2 design and philosophy*. Heyden. ISBN 978-0855012243.

1. ["BS 5904:1980: Specification for computer programming language RTL/2"](https://shop.bsigroup.com/ProductDetail/?pid=000000000000133906). *British Standards Institution*. 30 September 1980. ISBN 978-0580114410.

### SPL documentation

SPL published a range of documentation for RTL/2. Each such document was assigned a reference number. The following is an incomplete list.

RTL/2 Ref 1 – RTL/2 Language Specification RTL/2 Ref 2 – Introduction to RTL/2 RTL/2 Ref 3 – RTL/2 Training Manual RTL/2 Ref 4 – System Standards RTL/2 Ref 5 – Stream I/O RTL/2 Ref 18 – Hints on writing RTL/2 Programs RTL/2 Ref 26 – Language Reference Card RTL/2 Ref 39 – Run time environment on the PDP-11 RTL/2 Ref 63 – User Manual for the PDP-11 under RSX-11M RTL/2 Ref 107 – VAX/VMS RTL/2 User Manual RTL/2 REF 130 – The RTL/2 32-bit run time environment on the VAX

---
Adapted from the Wikipedia article [RTL/2](https://en.wikipedia.org/wiki/RTL%2F2) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/RTL%2F2?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
