18
From: http://www.obsolyte.com/sgi_indigo2/

From: . From:

  • View
    223

  • Download
    1

Embed Size (px)

Citation preview

From: http://www.obsolyte.com/sgi_indigo2/

From: http://www.obsolyte.com/sgi_indigo2/

From: http://www.silicon-impact.de/gallery/albums/SGI-Indy-Components/Indy_CPU_bottom_view.jpg

From http://www.vaughns-1-pagers.com/computer/pc-block-diagram.htm

From: http://www.research.ibm.com/journal/rd/483/slege8.jpg

The CPUMemory Registers

Register 0

Register 1

Register 2

Register 3

Instruction Register

Instr. Pointer (IP)

Arithmetic/LogicUnit

Control Unit(State Machine)

Memory Access

Fetch/Execute Cycle

• At each tick of the clock– Read the Instruction pointer– Go to that address in RAM (Memory)– Fetch the contents of that location to the instruction register– Execute the instruction stored in the instruction register

• This instruction may require using the A/LU to operate on information in registers

• This instruction may involve information from registers, RAM, disk, CD, …

• This instruction may change the address in the instruction pointer. It it doesn’t, the instruction pointer is increased by 1 when the execution is done.

Simple Code

• Copy the value in Memory Location XXX to Register 0

• Move the value in Memory Location YYY to Register 1

• Add the Values in Registers 0 and 1 and store the result in Register 2

• Copy the Value in Register 2 to Memory Location ZZZ

Simple Code

• Copy the value in Memory Location XXX to Register 0 mv XXX R0

• Copy the value in Memory Location YYY to Register 1 mv YYY R1

• Add the Values in Registers 0 and 1 (result is put in the accumulator) add R0 R1

• Copy the Value in the accumulator to Register 2 cop acc R2

• Copy the Value in Register 2 to Memory Location ZZZ sto R2 ZZZ

Simple Code (the actual code)

mv XXX R0

mv YYY R1

add R0 R1

cop acc R2

sto R2 ZZZ

0001 00000001 10000000

0001 00000010 10000001

0010 10000000 10000001

0011 11000000 10000010

0100 10000010 00000011

Mneumonic (assembler) Machine level

Coding in Algebraic Fashion

• A, B, and C are integers; want to add A to B and store the result as C.

• C = A + B

Enhancements

• A programming language that can only do arithmetic operations is limited– Need to be able to process text as well as

numbers– Need to be able to structure data– Need to be able to make decisions

• IF (a certain condition) do something ELSE do something else;

A very simple program

int fact, i, n ;

fact = 1;

i = 1;

loop: i = i+1;

if (i > n) go to end:

fact = fact * i;

go to loop;

end: ….

Next steps

• A compiler is a program that translates a program into machine language.

• A compiled program is then loaded into machine memory and executed.

Next steps (Code)

• A compiler is a program that translates a program into machine language. The compiler enforces code. A compiler will only compile programs that have a structure valid in the defined language.

• A compiled program is then loaded into machine memory and executed. The machine architecture defines a code in which the machine language of the program must be written.

• The machine architecture also determines a code (via the hardware) that tells which machine languages instructions are done most efficiently.

Historical context

• Machine language – the 1950’s• First compilers –Fortran (1957), Algol (1958,

1960) Another example of code• Higher level languages – Pascal, C (early 70’s)• The present Further examples of code

– Toolkits and Programming Environments (Visual Studio .NET from Microsoft)

– Secure languages (Java from Sun Microsystems)

Toolkits

• To build a large program, programming has to begin at a higher level– String processing– User interface toolkits– Debugging tools– Shared libraries

Toolkits as code

• To build a large program, programming has to begin at a higher level– String processing

• Font libraries define how things are displayed

– User interface toolkits• The Microsoft/Apple Interface defines interaction

– File/Edit/… menus – (Cut,Copy,Paste, Undo)

– Debugging tools– Shared libraries

• If I write a library that can do most of the things you need to make one aspect of your program work, you will be inclined to use it rather than writing it yourself.

• Open source issues arise here.