1 / 9

SCI 199 Y Tutorial Sept. 14, 2009

SCI 199 Y Tutorial Sept. 14, 2009. Phillipa Gill phillipa@cs.toronto.edu. Von Neumann Architecture. Data. OS. Programs. Memory. Control Unit. Arithmetic Logic Unit. Accumulator. Input. Output. General Purpose Machines. As opposed to fixed purpose

admon
Télécharger la présentation

SCI 199 Y Tutorial Sept. 14, 2009

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SCI 199 YTutorial Sept. 14, 2009 Phillipa Gill phillipa@cs.toronto.edu

  2. Von Neumann Architecture Data OS Programs Memory Control Unit Arithmetic Logic Unit Accumulator Input Output

  3. General Purpose Machines • As opposed to fixed purpose • E.g., your calculator is not a word processor or gaming console • Machine can be used to solve problems using programs stored in memory

  4. Example Program: Problem • Problem: • Input: a value X, a list A with length N • Output: • the position in the list where X resides if X is in the list. • 0 otherwise. • Example: A = 2,4,6,5,10 if X is 6 this program will return 3

  5. Example Program: Code ANSWER=0 I=1 WHILE ANSWER = 0 and I <= N IF X=A(I) then ANSWER = I I=I+1 ENDWHILE OUTPUT ANSWER

  6. Example Program: Memory

  7. Example Program: Memory (2) • Write-constant-into-memory 0,1003 % set ANSWER=0 • Write-constant-into-memory 1,1002 % set I=1 • Get-memory 1001 %put N into accumulator • Subtract-memory 1002 % compute N-I • Conditional-jump-on-negative 16 %if N-I was negative • Get-memory 2000 % get value of A(I) • Subtract-memory 1000 % compute A(I) – X • Conditional-jump-on-zero 14 % if A(I)-X=0 • Get-memory 6 % load word 6 into memory • Add-constant 1 % increment address in word 6 • Get-memory 1002 % load I

  8. Example Program: Memory (3) • Get-memory 6 % load word 6 into memory • Add-constant 1 % increment address in word 6 • Get-memory 1002 % load I • Add-constant 1 % increment I • Jump 6 % go back to start of loop • Get-memory 1002 % get value of I • Put-memory 1003 %put this value into 1003 (answer) • Output 1003 % output answer

  9. Issues • Code can modify itself! • Get-memory 6 % load word 6 into memory • Add-constant 1 % increment address in word 6 • The above code changes the statement: • Get-memory 2000 into Get-memory 2001 • Why is this a bad idea? • Recent developments have tried to fix this

More Related