Jump to content

City & Guilds Mnemonic Code

From Wikipedia, the free encyclopedia

The City & Guilds Mnemonic Code and its associated City & Guilds Computer was a specification for an assembler language and a virtual computer system that ran it. It was introduced in 1964 by the City and Guilds of London Institute and used as the basis for a number of computer programming and administration courses. The computer model was deliberately very simple, and operational systems were implemented as interpreters on a number of mainframe computers like the ICL 1900 series and Elliot 900 family. An updated version was released in 1968.

History

[edit]

The City and Guilds of London Institute (C&G) has been offering a wide variety of vocational and apprenticeship programs since the late 19th century. In the early 1960s, the first computer systems were beginning to rapidly proliferate in large companies, and C&G decided to introduce a series of programs on computer operation and programming.[1]

The City & Guilds Mnemonic Code addressed the problem of widespread incompatibility across platforms by introducing a single new assembler language that could then be interpreted in a virtual machine on any sufficiently powerful platform. The system was deliberately simplified to make the number of machines that could run it as large as possible. It also added a number of features one would not normally associate with assembler, including the standard data format being floating point and including a number of features for advanced mathematics and string handling that would normally be expected in a high level language like BASIC.[1]

The first release was in 1964, and used in two courses, Basic and Advanced Certificates for Computer Personnel. The system was updated in 1968 as the Revised Mnemonic Code, at which time the Basic course became the Certificate in Computer Programming and Information Processing.[1]

Description

[edit]

The virtual computer was an oddity in that its basic data type was the floating point number,[2] as opposed to the majority of real-world machines which used binary integers, or for business-oriented machines of the era, binary coded decimal. In addition to the low-level commands found in most assemblers, like loading data from memory or bit shifting, C&G also included multiplication and division, as well as a number of more advanced features like exponents and trigonometric functions. A memory location could alternately hold one character.[2]

The computer was defined to have a main memory of 1,000 words. The first ten addresses could be used as index registers but also had special meanings. Location zero was permanently set to the value zero, while 1 was the accumulator and 4 held the return address during subroutine calls. In the revised edition, 5 was used with the LOP instruction and 6 and 7 were used to specify the format when converting from characters to numbers using the CNC instruction.[2][3]

The machine was an accumulator design. Most instructions took two operands pointing into the main memory, referred to as n and m. n was normally a 12-bit value 0 through 999, while m selected one of the registers, 0 through 9. The value in that register was added to n to produce a complete address. For instance, the ADD instruction read the two operands, added the value in the selected register m to the constant value n, and then accessed the value at the resulting memory location, referred to as C.[4]

In the documentation, if the value in question was read from a memory location it was indicated in parens, so most instructions were of the form n+(m), meaning that the value in the register/memory location m was added to the constant value n. Addition performed the operation A = A + (n+(m)), meaning the value in register m was added to the constant value n, and then the value in the resulting memory location, (n+(m)), was added to the value already in the accumulator.[3]

The system was created before ASCII had been standardized, and, as was typical for machines of the era, used its own custom character set. This held 0 to 9 in locations 0 to 9, A to Z in 10 through 35, and then a number of symbols for a total of 64 characters.[5][6][a]

The system lacked any facility for including code comments. It also lacked symbolic labels, so if the program added or removed lines, the programmer had to manually update the locations of branches.[3]

Instructions

[edit]

The instructions in the Mnemonic Code can be broken into three broad categories, basic math and logic operations that closely mirror most assembler languages, additional mathematical operations, and input/output operations. One curious addition is the "Q", for "query", which could be added to the front of any instruction. When Q was encountered, the interpreter would run the instruction and then output debugging information to the printer.[3]

The instructions, depending on the version, were stored internally in the format:

FF [Q] nnn m

FF, the "order number", was the numerical instruction opcode. Q indicated the query function, and nnn and m were three-digit and one-digit values for n and m. Numbers were entered in decimal format.[3]

Basic operations

[edit]

The system broke down its basic arithmetic and logical operations into several groups for organizational purposes. Unless otherwise specified, the lists are from the Elliot 903 documentation.[7]

Group 0, accumulator/memory operations:

Opcode Mnemonic Operation
00 LDA n,m Load the data stored in location n+(m) into the accumulator
01 ADD n,m Add the value stored in n+m to the value in the accumulator, A = A + (n+(m))
02 SUB n,m Subtract the value at n+m from the value in the accumulator, A = A – (n+(m))
03 MLT n,m Multiply the value stored in n+m to the value in the accumulator, A = A x (n+(m))
04 DIV n,m Divide the value at n+m from the value in the accumulator, A = A / (n+(m))

Group 1, accumulator/constant operations, with a single operand holding an integer value. In the original specification only n was used, in the 1968 revision, m can be optionally supplied and its value added to the constant in n.[3]

Opcode Mnemonic Operation
10 LDAN n Load the constant 0 through 999 into the accumulator
11 ADDN n Add the value to the accumulator, A = A + n [+(m)]
12 SUBN n Subtract the value at n+m from the value in the accumulator, A = A – n [+(m)]
13 MLTN n Multiply the value stored in n+m to the value in the accumulator, A = A x n [+(m)]
14 DIVN n Divide the value at n+m from the value in the accumulator, A = A / n [+(m)]

Group 2, store value:

Opcode Mnemonic Operation
20 STA n,m Store the accumulator's value to location n+(m)

Group 3, test and branch:

Opcode Mnemonic Operation
30 JUN n,m Jump to n+m (unconditional jump)
31 JGR n,m Jump to n+m if the accumulator is > 0
32 JEQ n,m Jump to n+m if the accumulator is 0
33 JSR n,m Write the return address to location 4, and jump to n+(m) (jump to subroutine)
34 JST n,m Stop execution, when user presses GO, pick up at n+(m)

The Revised edition changed some of the codes and added new ones. The list in this section is from the ICL documentation:[8]

Opcode Mnemonic Operation
30 JUN n,m Jump to n+m (unconditional jump)
31 JEQ n,m Jump to n+m if the accumulator is 0
32 JNE n,m Jump to n+m if the accumulator is not 0
33 JLE n,m Jump to n+m if the accumulator is <= 0
34 JGE n,m Jump to n+m if the accumulator is >= 0
35 JLT n,m Jump to n+m if the accumulator is < 0
36 JGR n,m Jump to n+m if the accumulator is >= 0
37 JSR n,m Write the return address to location 4, and jump to n+(m) (jump to subroutine)
38 JST n,m Stop execution, when user presses GO, pick up at n+(m)
39 LOP n,m Decrement the value in register 5, then jump to n+(m) if the value > 0

The LOP instruction is used to implement loops; by placing the number of iterations in register 5, LOP will decrement the value each time and then jump back to the top of the loop.[8]

Extended math

[edit]

Group 4 are a set of standard math functions:[9]

Opcode Mnemonic Operation
40 SQT n,m Square root of the value in A. If n+(m) is non-zero, an error will leave A unchanged and jump to that location. If n+(m) is zero, errors cause execution to stop.
41 EXP n,m Exponent of the value in A. Overflows jump to n+(m)
42 LGN n,m Natural logarithm of the value in A. Overflows jump to n+(m)
43 SIN Sine of the value in A
44 COS Cosine of the value in A
45 ARC Arctangent of the value in A
46 ENT Integer part of the value in A

Input/output

[edit]

Group 5, 6 and 7 are the input/output instructions. There are significant differences between the two known versions, ICL and Elliot, but it is not clear whether these are differences due to the Elliot version being the earlier specification, or whether it is due to the machine lacking tape and disk support and thus simply removing instructions related to those devices. The result is a relatively limited set of functions:[10][3]

Opcode Mnemonic Operation
50 RCT n,m Read a single character from punch tape and store it at (n+(m))
51 PCT n,m Punch the character at (n+(m)) to tape
52 RNT n,m Read a number from the tape into the accumulator
53 PNT n,m Punch the number in the accumulator to tape
52 PNL Punch a newline character
60 RCC n,m Read all the characters on a punch card into memory starting at (n+(m))
61 PCC n,m Punch characters starting at (n+(m)) to a card
62 RNC n,m Read number on card to (n+(m))
63 PNC n,m Punch number at (n+(m)) to card

In contrast, the ICL version, which corresponds to the 1968 specification, is much more flexible. Its Computer had a single input and single output channel that could be connected to different devices. There were five devices defined, 10 was the paper tape reader, 30 was the card reader, 50 was magnetic tape, 60 was a disk pack, and 80 was a printer.[11] To use one of the devices, the ARD n, m or AWD n, m instruction was called, for read or write respectively, with the desired device number in (n+(m)).[12]

Once opened, the devices could be read and written using the various I/O instructions. These included separate instructions for numbers and characters, instructions to convert between the two, and various other instructions for particular operations like outputting a line feed or rewinding a tape.[11] A key feature was the concept of a "block", a group of related data that was read all at once. This was normally used to read and write character strings in a single instruction. The block ended with the £ character, known as the block character.[13][3]

Opcode Mnemonic Operation
50 ARD n,m Allocate input to device number (n+(m))
51 AWD n,m Allocate output to device number (n+(m))
52 RNA n,m Read number from the input device into A, jump to n+(m) on any error
53 WNA n,m Write the number in A to the output device. n and m holds numbers that defines the format to write (see below)
60 RCH n,m Read one character and store it in n+(m)
61 WCH n,m Write one character at (n+(m)), this may be the new line character
62 RNB n,m Read characters into memory starting at n+(m), stopping when the block character is seen
63 WNB n,m Write a block of characters from memory starting at n+(m)
64 WNL n,m Write a sequence of n+(m) newline characters
65 WSS n,m Write a sequence of n+(m) space characters
66 CNN n,m Convert the string at n+(m) into a number in A
67 CNC n,m Convert the number in A to a string at n+(m)
70 ACB n,m Access block number n+(m). Normally used with hard disks, with other devices is moves forward n+(m) blocks
71 BSP n,m Backspace to block number n+(m). Only legal on hard disks
72 RWD Rewind. Only legal on magnetic tape drives

Other instructions

[edit]
Opcode Mnemonic Operation
99 STOP Stop execution

Number formatting

[edit]

As a major goal of the system was to read and write data to various real-world devices, the Code included a formatting system similar to printf format strings to ease the task of outputting readable text. The format is stored as a value in memory, at n+(m) for most instructions, or in locations 6 and 7 for the CNC instruction, which uses n+(m) to define the output location. There are four basic formats, all of which begin with a leading space and plus or minus sign:[14]

type n and m results
complete n=0, m=0 write all the digits in the number including a period at the decimal place
integers n>=1, m=0 write n digits of the integer part, ignore any fractional part
mixed n>=1, m<>0 write n digits of integer, a period, m digits of fraction
floating point n=9, m<>0 write a leading period, m digits of fraction, "E", and two digits of exponent

Assembler directives

[edit]

In addition to the machine instructions, the language also included a small number of directives:[15][16][3]

(TITLE)
prints the following line to the output device
(STORE n)
sets the starting location of the following code. Several STOREs can be used in a single program
(WAIT)
stops execution and waits for a GO instruction from the operator
(EXECUTE n)
indicates the end of the program code and sets the initial program counter location when the program is run

Operating environment

[edit]

In addition to the Mnemonic Code, the Computer also defined a basic operating environment, like the BASIC language. This included LOAD and SAVE, ON to redirect the input or output device, and GO to start execution.[17]

Example

[edit]

This example, from Herbert, calculates and prints PI. Written for the Elliot 903, this uses the earlier PNT I/O command, which prints to the punch tape.[18]

(TITLE)
 SIMPLE TEST
(STORE 12)
 LDAN 1
 ARC 16
 MLTN 4
 PNT 1,6
 JST
(EXECUTE 12)

When run, with the GO command, this program will produce:

SIMPLE TEST
3.141593

Notes

[edit]
  1. ^ The ICL documentation uses section numbers throughout, but some pages also have a page number in the header. Page numbers are used where available, sections otherwise.

See also

[edit]

References

[edit]

Citations

[edit]
  1. ^ a b c Herbert 2015, p. 20.
  2. ^ a b c Computer, p. 1.
  3. ^ a b c d e f g h i Herbert 2015.
  4. ^ Computer, p. 3.
  5. ^ Computer, p. 7.
  6. ^ ICL, p. 2.6.
  7. ^ Computer, p. 4.
  8. ^ a b ICL.
  9. ^ Computer, p. 6.
  10. ^ Computer, pp. 6–7.
  11. ^ a b ICL, p. 13.
  12. ^ ICL, p. 11.
  13. ^ ICL, p. 5.0.
  14. ^ ICL, p. 6.1.
  15. ^ ICL, p. 2.8.
  16. ^ Computer, pp. 2–3.
  17. ^ ICL, p. 13.0.
  18. ^ Herbert 2015, p. 25.

Bibliography

[edit]
  • Herbert, Andrew (Autumn 2015). "City and Guilds Mnemonic Code" (PDF). Computer Resurrection: The Journal of the Computer Conservation Society (71): 20–27. ISSN 0958-7403.
  • City & Guilds Mnemonic Code. ICL.
  • The City & Guilds Computer (PDF). ICL.
[edit]