Lecture 1 - Random Access Machines | CS 281, Papers of Computer Science

Material Type: Paper; Class: Systems Architecture; Subject: Computer Science; University: Drexel University; Term: Unknown 1989;

Typology: Papers

Pre 2010

Uploaded on 08/19/2009

koofers-user-euc
koofers-user-euc 🇺🇸

10 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lec 1 Systems Architecture I 1
Systems Architecture I
Lecture 1: Random Access Machines
Jeremy R. Johnson
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Lecture 1 - Random Access Machines | CS 281 and more Papers Computer Science in PDF only on Docsity!

Systems Architecture I

Lecture 1: Random Access Machines

Jeremy R. Johnson

Introduction

  • Objective: To develop a simple model of computation that

provides insight into how a program executes on a computer.

  • A Random Access Machine (RAM) is an abstract model of

computation that resembles a simple idealized computer. It is

equivalent in computational power to a Turing machine (can

perform any computation). Despite its simplicity it provides

some intuition as to how a program executes on a computer.

A Random Access Machine

Control Unit

AC

Program

Memory

AC = accumulator register

Instruction Set

  • LDA X; Load the AC with the contents of memory address X
  • LDI X; Load the AC indirectly with the contents of address X
  • STA X; Store the contents of the AC at memory address X
  • STI X; Store the contents of the AC indirectly at address X
  • ADD X; Add the contents of address X to the contents of the AC
  • SUB X; Subtract the contents of address X from the AC
  • JMP X; Jump to the instruction labeled X (unconditional jump)
  • JMZ X; Jump to the instruction labeled X if the AC contains 0
  • JMN X; Jump to the instruction labeled X if the contents of the AC
  • ; is negative
  • HLT ; Halt execution

Sample RAM Program

**1. LDI 3; get i-th entry from A

  1. ADD 4; add offset to compute index j
  2. STA 5; store index j
  3. LDI 5; get j-th entry from B
  4. JMZ 9; if entry 0, go to 9
  5. LDA 3; if entry 1, get index i
  6. STA 2; and store it at 2.
  7. HLT ; stop execution
  8. LDA 1; get constant 1
  9. STI 5; and store it in B
  10. LDA 3; get index i
  11. SUB 4; subtract limit
  12. JMZ 8; if i = limit, stop
  13. LDA 3; get index i again
  14. ADD 1; increment i
  15. STA 3; store new value of i
  16. JMP 1;**

AC

Memory

1 constant

2 0 answer

3 6 Index i

4 9 Limit of A

5 0 Index j

A

B

Exercises

  • Modify STOR so that when a computation finishes and the

input sequence contained a duplicate integer, we know what

that integer was.

  • Modify STOR so that it uses array indexing when accessing

the array A instead of pointer arithmetic (i.e. the index into A

should be an array index, starting with 1, rather than an

address of a location in the array).

  • Write a RAL program which takes two input integers at

addresses 1 and 2 and multiplies them storing the result at

address 4.