City & Guilds Mnemonic Code

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

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

The 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 1000 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, whilst 1 was the accumulator. 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][lower-alpha 1]

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

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

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:

OpcodeMnemonicOperation
00LDA n,mLoad the data stored in location n+(m) into the accumulator
01ADD n,mAdd the value stored in n+m to the value in the accumulator, A = A + (n+(m))
02SUB n,mSubtract the value at n+m from the value in the accumulator, A = A - (n+(m))
03MLT n,mMultiply the value stored in n+m to the value in the accumulator, A = A x (n+(m))
04DIV n,mDivide 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]

OpcodeMnemonicOperation
10LDAN nLoad the constant 0 through 999 into the accumulator
11ADDN nAdd the value to the accumulator, A = A + n [+(m)]
12SUBN nSubtract the value at n+m from the value in the accumulator, A = A - n [+(m)]
13MLTN nMultiply the value stored in n+m to the value in the accumulator, A = A x n [+(m)]
14DIVN nDivide the value at n+m from the value in the accumulator, A = A / n [+(m)]

Group 2, store value:

OpcodeMnemonicOperation
20STA n,mStore the accumulator's value to location n+(m)

Group 3, test and branch:

OpcodeMnemonicOperation
30JUN n,mJump to n+m (unconditional jump)
31JGR n,mJump to n+m if the accumulator is > 0
32JEQ n,mJump to n+m if the accumulator is 0
33JSR n,mWrite the return address to location 4, and jump to n+(m) (jump to subroutine)
34JST n,mStop 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]

OpcodeMnemonicOperation
30JUN n,mJump to n+m (unconditional jump)
31JEQ n,mJump to n+m if the accumulator is 0
32JNE n,mJump to n+m if the accumulator is not 0
33JLE n,mJump to n+m if the accumulator is <= 0
34JGE n,mJump to n+m if the accumulator is >= 0
35JLT n,mJump to n+m if the accumulator is < 0
36JGR n,mJump to n+m if the accumulator is >= 0
37JSR n,mWrite the return address to location 4, and jump to n+(m) (jump to subroutine)
38JST n,mStop execution, when user presses GO, pick up at n+(m)
39LOP n,mDecrement 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

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

OpcodeMnemonicOperation
40SQT n,mSquare 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.
41EXP n,mExponent of the value in A. Overflows jump to n+(m)
42LGN n,mNatural logarithm of the value in A. Overflows jump to n+(m)
43SINSine of the value in A
44COSCosine of the value in A
45ARCArctangent of the value in A
46ENTInteger part of the value in A

Input/output

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]

OpcodeMnemonicOperation
50RCT n,mRead a single character from punch tape and store it at (n+(m))
51PCT n,mPunch the character at (n+(m)) to tape
52RNT n,mRead a number from the tape into the accumulator
53PNT n,mPunch the number in the accumulator to tape
52PNLPunch a newline character
60RCC n,mRead all the characters on a punch card into memory starting at (n+(m))
61PCC n,mPunch characters starting at (n+(m)) to a card
62RNC n,mRead number on card to (n+(m))
63PNC n,mPunch 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]

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

Other instructions

OpcodeMnemonicOperation
99STOPStop execution

Number formatting

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]

typen and mresults
completen=0, m=0write all the digits in the number including a period at the decimal place
integersn>=1, m=0write n digits of the integer part, ignore any fractional part
mixedn>=1, m<>0write n digits of integer, a period, m digits of fraction
floating pointn=9, m<>0write a leading period, m digits of fraction, "E", and two digits of exponent

Assembler directives

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

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

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

  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

References

Citations

  1. Herbert 2015, p. 20.
  2. Computer, p. 1.
  3. Herbert 2015.
  4. Computer, p. 3.
  5. Computer, p. 7.
  6. ICL, p. 2.6.
  7. Computer, p. 4.
  8. ICL.
  9. Computer, p. 6.
  10. Computer, pp. 6–7.
  11. 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

  • 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.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.