CSCI 431 -- Chapter 2

The Structure and Operation of the Computer


By computer we will mean an integrated set of algorithms and data structures capable of storing a program. This could be A program may be either executed on a

Any computer consists of the six components below. Studying how different languages, and thus how different virtual computers implement these aspects will be a major focus of this course.

The hardware of the computer

Data: typically for a hardware computer this consists of main memory, cache memory and external files. It will also have a number of built-in data types - integers, reals, fixed-length strings. The program itself is also data, known as the machine language representation of the computer.

Operations: typically for a hardware computer, these are very simple operations, such as arithmetic, simple tests (ie >0, =0, <0) and jumping to another memory location

Sequence Control: a physical computer typically steps through operations one after another unless it is instructed to jump to another location

Data Access: typically a hardware computer stores each piece of data, in a particular location, in main memory. Data is accessed by specifying the address of that location.

Storage Management: a conflict occurs because CPU operations typically take place at the nanosecond level, external access at the millisecond. Simple computers execute only one program at a time, thus causing the CPU to wait while slower data operations occur. This may be sped up by multiprogramming - running one program until it initiates a slow data access and then executing a different program until that action is complete; or by moving memory that is likely to be used, to faster (cache) memory.

Operating environment: computers are usually connected to external resources - networks, I/O devices, storage devices.

Computer Organization

Operations: Sequence control how do we decide which instruction to take next.
Note: control sequence changes accomplished by the program address register

Interpreter

Computer states: The dynamic behaviour of an instruction, may be examined by studying how the initial state of a computer, is transformed by a state transition, into a final state. Program execution may be viewed as a sequence of state transitions.

Alternative computer architectures:
The major computer architecture is known as the Von Neumann architecture. These systems have a single CPU, a large memory and a process to transfer data between the memory and the CPU. Other architectures are possible, e.g. Multiprocessors.

Firmware Computers Consider that any program may be implemented in hardware. Therefore any high level language could be implemented as a computer, where the low level machine instructions of the computer were the language. Not often used because a computer designed this way would be more complex, thus more costly, it would also be less flexible when implementing other languages.

A lower level variation of this is microprogramming, where microprogramming is used to specify the commands that a CPU will use. This combination of programmable hardware plus its microprogram is yet another virtual computer.

COMPUTER AS A MULTI-LEVEL MACHINE:

A hierarchy of computers may be pictured, starting with the physical computer; a firmware virtual computer is made up of the physical computer, plus its microprogram; an operating system virtual computer is made up of the firmware virtual computer and the operating system; a C virtual computer is made up of the OS virtual computer, the C compiled program and its run-time library.

At each level the computer is made up of some sort of input and the computer from the previous level. What is data at one level, is program at another. We will see some languages that have a strong separation of program and data, and some (LISP/PROLOG) where there is very little.

Translators and Software-Simulated Computers

More commonly, a language is executed on some preexisting computer using generic lower level machine instructions. This is done via the following techniques

In practise, most languages combine these techniques, first a language is translated into a simpler form. Then the simpler form is combined with a number of run-time support routines, before being executed.

TRANSLATION VS. INTERPRETATION

Translation: program written for level n machine translated to level 1 machine

Interpretation: program written for level n + 1 is executed on level n machine

Examples of Compiled Languages

Examples of Interpreted Languages

What about Java---is it compiled or interpreted???

Virtual Computer

Virtual computers are implemented as some combination of:

Virtual Computers and Language Implementations
Even though languages are defined semmantically, they still leave a range of possibilities for how a virtual computer is implemented. Imagine a language that offers a sin function. How does the virtual computer evaluate it.. by a lookup table, or by calculating an expression?? Differences in language implementations may occur because of

Virtual Computers and Binding Time
Remember that syntax is how a language is written. For example, V: array[0..9] of integer; (pascal) and int V[10] (C) both define an array. Both of these structures have similar semmantics, and could appear similarly in their virtual computer implementations.

In LISP, objects are stored in lists..a different semmantic structure, and a different virtual computer implementation. This course is more concerned with the different structures seen in virtual computers, rather than syntactic differences.

Binding and Binding Time

Binding occurs when some element of a language is given some sort of property. Binding Time refers to when this occurs.

Classes of Binding Time

In general, Interperters perform all bindings dynamically, while compilers perform many bindings statically. Often functional languages have more dynamic bindings than imperative languages.

Importance of Binding time

Early bindings (i.e. at language definition time) are more efficient, but less flexible. Late bindings (i.e. at execution time) are less efficient, but more flexible. i.e. can a record be bound while a program is running, or only at translation time.

A Peak at Chapter 3---Compilers

COMPILATION


Source language

Compiler organization phases

Pass- a run through source code in multiple passes that may be needed to check syntax, etc.

Symbol table- record kept for every identifier. Some compilers keep it for run-time, some not.