Computer Execution, SAL

Tom Kelliher, CS 220

Sept. 15, 1997

Announcements

Assignment

Read 2.4--2.6.

Computer Execution

How is a program executed?

How does it look?

Where does it reside?

Assembly Language

Similar to machine language.

consider HLL code:

a = 2 * b + c;
In assembly language, this might appear:
mult temp, b, 2
add a, temp, c
What do we see here:
  1. HLL, assembly statement correspondence.

  2. Opcode corresponding to machine instructions.

  3. Labels referring to memory locations.

Another example. HLL:

if (a == b)
   c = d;
else
   c = e;
Assembly:
if:      bne a, b, else
         add c, d, 0
         b endif
else:    add c, e, 0
endif:

Classes of instructions:

  1. Arithmetic, logic.

  2. Control: conditional branch, unconditional branch, procedure call/return, interrupt, machine control.

  3. Data transfer: memory load/store, I/O.

Model of a Computer

Instruction Fetch/Execute Cycle

Machine/assembly instructions are distinct and are executed ``individually.''

Program counter (PC): a register holding the address of the next instruction to be executed.

The cycle:

  1. Fetch (read) the instruction pointed to by the PC.

  2. Decode the instruction and increment the PC. (By how much?)

  3. Fetch operands.

  4. Execute.

  5. Store (write) results.

How is this modified for a conditional branch?

Modifications for modern CPUs:

  1. Pipelining.

  2. Multiple-Issue.

  3. Out of order execution.

SAL

With what must a programming language provide us?

  1. Primitive data types.

  2. Sequential execution. Implicit in most instructions.

  3. Conditional execution. Conditional branches.

  4. Iterative execution. Conditional and unconditional branches.

  5. I/O. I/O instructions.

Variable Declaration

Assembler directives.

Declared in a .data segment. Example:

         .data
foo:     .word    345
bar:     .byte    'c'
pi:      .float   3.14159

  1. Label, value optional.

  2. Why would label be optional?

  3. .word

  4. .byte

  5. .float

Arithmetic Instructions

Instructions go into a .text segment. Execution begins with the instruction labeled __start.

Example:

add a, b, c

  1. Opcode.

  2. Destination, source operands.

  3. 3-address architecture.

First set of AL instructions:

  1. move --- 2 address.

  2. add, sub, mul, div, rem --- 3 address.

  3. Integer division, remainder. Arithmetic rules.



Thomas P. Kelliher
Sun Sep 14 17:26:01 EDT 1997
Tom Kelliher