BASIC BASIC was first developed on 1964. It stands for Beginner's All-purpose Symbolic Instruction Code, and was designed in such a way that it be easy to learn. Of the more common programming languages, it most closely resembles FORTRAN. The differences are that it has a sequence number preceding every statement, I/O statements are simpler, arithmetic is less accurate (no double precision, and most BASICs give only 6 or 7 figure accuracy), parameters cannot be passed to subroutines, and function definition facilities are so rudimentary as to be almost useless. Its one improvement on most other programming languages (other than being easier to learn) is that there are more powerful string handling statements. BASIC, however, has found a niche as the main programming language for microcomputers. Because of its increased use, there have been several attempts to improve it. There have been a number of implementations of 'structured BASICS', notably BBC BASIC and COMAL. These have better subroutine facilities and structured statements (IF..THEN..ELSE and WHILE, etc.). PASCAL Pascal was first developed in 1973. It was named after the mathematician, Blaise Pascal. It is an ALGOL-like language. Routines typically consist of data declarations, followed by declarations of subroutines used inside the routine, followed by the code of that routine. Routines can either be functions, which return a value, or procedures, which are executed for their side effects. Data types provided are integer, real, character, boolean and enumeration (named integer), and data structures provided are array, set (bit array), record (collection of items of possibly different types in the same structure) and file. Also, pointers to other data structures can be used. Complex data structures can be built from the fundamental data structures described above. The statement types provided in Pascal include 1) compund statement begin a; b; c end; with s do begin a := 1; b := true; c := 'x' end; 2) loops, e.g. for i := 1 to 10 do a[i] := 0; while not eof(infile) do begin write(c); read(infile, c) end; repeat a; read(c) until c = quit; 3) conditional statements if a then b else c; case i of 1: f1; 2: f2; 3: f3; else f0 end; PROLOG This programming language, like LISP, was developed in 1973 from a branch of mathematics (predicate calculus), rather than on a particular machine architecture or previously developed programming language. Prolog stands for 'programming in logic'. The reasons behind its development are as follows: 1) it is possible to express many statements about the real world in predicate calculus: "Clyde is a white elephant." becomes white(clyde) and elephant(clyde). "African elephants have big ears." becomes forall(X): exist(Y): (african(X) and elephant(X) => have(X, Y) and big(Y) and ears(Y)) 2) It is possible to prove theorems expressed in predicate calculus by means of a simple algorithm (called resolution). Prolog programs are statements in predicate calculus, and a Prolog interpreter is a theorem prover. Prolog has some similarities to LISP, but to very few other programming languages. Its main application at present is as an implementation language for expert systems. It is the programming language used in Edinburgh University's Department of Artificial Intelligence, and has been adopted as the main programming language of Japan's 5th Generation computing programme, but it has not displaced LISP in AI research centres in the United States. I have selected the seven programming languages described above because they are (with the exception of LISP and Prolog) widely used. LISP and Prolog will be used more often as the demand for smarter programs increases. All of the programming languages described above are substantially different from one another, with the exceptions of ALGOL and Pascal. All of these languages (except perhaps, BASIC) have influenced hardware design. For each type of application, certain programming languages are more suitable or more frequently used than others, e.g. Commercial Data Processing: COBOL, RPG. Scientific Programming: FORTRAN. Real-time systems: Ada, RTL2, Assembler. Operating Systems, Compilers: C, ALGOL, Pascal. Artificial Intelligence: LISP, Prolog. Teaching Computer Programming: Pascal, LOGO, BASIC. IMPROVEMENTS WITHIN THE VON-NEUMANN FRAMEWORK The design of a simple von-Neumann processor has been described in previous lectures; what follows are some improvements which could be made. Microcoded Instruction Set After an instruction is fetched from memory, it is used as an index into an array of bit arrays (usually called a nano-ROM). Each array element (a bit array) determines which transmission gates are open during the execute part of the particular instruction's fetch-execute cycle. If a bit is ON, the gate is open, otherwise it is closed. The advantage of having a microcoded instruction set is that it is possible to change the instruction set without redesigning the processor, simply by changing the nano-ROM. ___ ! ! ! ! ! ! ! ! !--!-!-!-!-!-!-!- ------ ____!De !--!-!-!-!-!-!-!- ! IR !____!co !--!-!-!-!-!-!-!- nano-ROM ------ !der!--!-!-!-!-!-!-!- Instruction !___!--!-!-!-!-!-!-!- register ! ! ! ! ! ! ! Outputs from nano-ROM -- to transmission gates Pseudo-registers These are the outputs of logic gates (such as AND, OR, ADD). The inputs to these logic gates are the contents of pairs of registers. Using a pseudo-register as an operand in an instruction allows an operation to be performed which would otherwise require two or more instructions, e.g. ___ ! A !__ ___ !___! !__! ! ___ __! + !--- APLUSB ! B !__! !___! !___! m[x] := aplusb ;store a+b in location x instead of a := a + b m[x] := a a := a - b Instruction Pipelining This means fetching several instructions from memory during the same access, eliminating the instruction fetch operation for most instructions. This results in much faster execution of straight-line code, but much slower execution of branch instructions (because the instructions ahead of the branch need to be purged as they should not be executed, and the instructions at the branch destination need to be fetched). Caching Cache memory is memory with a faster fetch time than ordinary memory. If the most frequently accessed data is held in cache memory, then data access is speeded up. IMPROVEMENTS TO THE VON-NEUMANN ARCHITECTURE These are extensions to the basic von-Neumann architecture described in the previous lecture, but not departures from it. Array Processing In scientific programming, it is often necessary to perform the same operation on each element of a large array. This is done by having an array of processors, and performing each operation on a separate processor in parallel. This is often described in the literature as SIMD (single instruction, multiple data). Machines which use this include the Cray 1 and Cray 2, and ICL DAP. Processor Pipelining This is not to be confused with instruction pipelining described above. Several processors are connected in series, and the output of one processor becomes the input of the next processor in the series.