COP 2500 Concepts in Computer Science Spring 2012

  • Slides: 18
Download presentation
COP 2500 Concepts in Computer Science Spring 2012 Instructor Euripides Montagne Teaching assistants Sarah

COP 2500 Concepts in Computer Science Spring 2012 Instructor Euripides Montagne Teaching assistants Sarah Loewy Bo Kang Introduction-1

Assembly Language programs In this lecture we will show the execution of a program

Assembly Language programs In this lecture we will show the execution of a program in the tiny VN machine. The program is written using the assembly language of the tiny VN computer. We will also refer to the assembly language as the Instruction Set Architecture (ISA). For the first instruction in the following example we will show The fetch and execution cycles for the first instruction Introduction-2

Assembly Language programs Data Memory Program Memory 000 20 IN < 5 > “

Assembly Language programs Data Memory Program Memory 000 20 IN < 5 > “ 18” 001 21 OUT < 9 > 002 22 STORE < 0001 > 003 23 IN < 5 > “ 4” 004 20 PC 005 C 006 P IR U 007 A 008 24 OUT < 9 > 25 STORE < 0004 > 26 LOAD < 0001 > 27 ADD < 0004 > 28 OUT < 9 > 009 29 STORE < 0002 > 30 END 9 5 . . . . Keyboard Screen 7 Printer Introduction-3

Assembly Language programs Data Memory Program Memory FETCH CYCLE 000 1. - Fetch instruction

Assembly Language programs Data Memory Program Memory FETCH CYCLE 000 1. - Fetch instruction from memory to IR 001 2. - PC + 1 20 IN < 5 > “ 18” 21 OUT < 9 > 002 22 STORE < 0001 > 003 23 IN < 5 > “ 4” 004 21 PC 005 C 006 P IN < 5 > IR U 007 A 008 24 OUT < 9 > 25 STORE < 0004 > 26 LOAD < 0001 > 27 ADD < 0004 > 28 OUT < 9 > 009 29 STORE < 0002 > 30 END 9 5 . . . . Keyboard Screen “type in 18” 7 Printer Introduction-4

Assembly Language programs Data Memory 000 EXECUTION CYCLE (The computer reads in the typed

Assembly Language programs Data Memory 000 EXECUTION CYCLE (The computer reads in the typed value (18) and saves it in A) Program Memory 20 IN < 5 > “ 18” 001 21 OUT < 9 > 002 22 STORE < 0001 > 003 23 IN < 5 > “ 4” 004 21 PC 005 C 006 P IN < 5 > IR U 007 18 008 A 24 OUT < 9 > 25 STORE < 0004 > 26 LOAD < 0001 > 27 ADD < 0004 > 28 OUT < 9 > 009 29 STORE < 0002 > 30 END 9 5 . . . . Keyboard Screen 7 Printer Introduction-5

Assembly Language programs Data Memory 000 001 Program Memory FETCH CYCLE 1. - Fetch

Assembly Language programs Data Memory 000 001 Program Memory FETCH CYCLE 1. - Fetch instruction from memory to IR 20 IN < 5 > “ 18” 2. - PC + 1 21 OUT < 9 > 002 22 STORE < 0001 > 003 23 IN < 5 > “ 4” 004 22 PC 005 C 006 P OUT < 9 > IR U 007 18 008 A 24 OUT < 9 > 25 STORE < 0004 > 26 LOAD < 0001 > 27 ADD < 0004 > 28 OUT < 9 > 009 29 STORE < 0002 > 30 END 9 5 . . . . Keyboard Screen 7 Printer Introduction-6

Assembly Language programs EXECUTION CYCLE Data Memory (The computer displays the 000 contents of

Assembly Language programs EXECUTION CYCLE Data Memory (The computer displays the 000 contents of A on the screen) Program Memory 20 IN < 5 > “ 18” 001 21 OUT < 9 > 002 22 STORE < 0001 > 003 23 IN < 5 > “ 4” 004 22 PC 005 C 006 P OUT < 9 > IR U 007 18 008 A 24 OUT < 9 > 25 STORE < 0004 > 26 LOAD < 0001 > 27 ADD < 0004 > 28 OUT < 9 > 009 29 STORE < 0002 > 30 END 9 18 5 . . . . Keyboard Screen 7 Printer Introduction-7

So far we have shown the execution of each instruction describing the instruction cycle,

So far we have shown the execution of each instruction describing the instruction cycle, which has two steps. From now on, we will show the state of the machine after executing each instruction. The instruction being executed will be highlighted in red. PC will point to the next instruction. Introduction-8

Assembly Language programs Data Memory Program Memory 20 IN < 5 > “ 18”

Assembly Language programs Data Memory Program Memory 20 IN < 5 > “ 18” 000 001 18 21 OUT < 9 > 002 22 STORE < 0001 > 003 23 IN < 5 > “ 4” 004 23 PC 005 C 006 STORE < 0001 > IR P U 18 A 007 008 009 24 OUT < 9 > 25 STORE < 0004 > 26 LOAD < 0001 > 27 ADD < 0004 > 28 OUT < 9 > 29 STORE < 0002 > 30 END 9 18 5 . . . . Keyboard Screen 7 Printer Introduction-9

Assembly Language programs Data Memory Program Memory 20 IN < 5 > “ 18”

Assembly Language programs Data Memory Program Memory 20 IN < 5 > “ 18” 000 001 18 21 OUT < 9 > 002 22 STORE < 0001 > 003 23 IN < 5 > “ 4” 004 24 PC 005 C 006 IR P U IN < 5 > 007 4 008 A 24 OUT < 9 > 25 STORE < 0004 > 26 LOAD < 0001 > 27 ADD < 0004 > 28 OUT < 9 > 009 29 STORE < 0002 > 30 END 9 18 5 . . . . Keyboard Screen 7 Printer Introduction-10

Assembly Language programs Data Memory Program Memory 20 IN < 5 > “ 18”

Assembly Language programs Data Memory Program Memory 20 IN < 5 > “ 18” 000 001 18 21 OUT < 9 > 002 22 STORE < 0001 > 003 23 IN < 5 > “ 4” 004 25 PC 005 C 006 IR P U OUT < 9 > 007 4 008 A 24 OUT < 9 > 25 STORE < 0004 > 26 LOAD < 0001 > 27 ADD < 0004 > 28 OUT < 9 > 009 29 STORE < 0002 > 30 END 9 4 18 Screen 5 . . . . Keyboard 7 Printer Introduction-11

Assembly Language programs Data Memory Program Memory 20 IN < 5 > “ 18”

Assembly Language programs Data Memory Program Memory 20 IN < 5 > “ 18” 000 001 18 21 OUT < 9 > 002 22 STORE < 0001 > 003 23 IN < 5 > “ 4” 004 4 26 PC 005 C 006 STORE < 0004 > IR P U 4 A 007 008 009 24 OUT < 9 > 25 STORE < 0004 > 26 LOAD < 0001 > 27 ADD < 0004 > 28 OUT < 9 > 29 STORE < 0002 > 30 END 9 4 18 Screen 5 . . . . Keyboard 7 Printer Introduction-12

Assembly Language programs Data Memory Program Memory 20 IN < 5 > “ 18”

Assembly Language programs Data Memory Program Memory 20 IN < 5 > “ 18” 000 001 18 21 OUT < 9 > 002 22 STORE < 0001 > 003 23 IN < 5 > “ 4” 004 4 27 PC 005 C 006 IR P U LOAD < 0001 > 007 18 008 A 24 OUT < 9 > 25 STORE < 0004 > 26 LOAD < 0001 > 27 ADD < 0004 > 28 OUT < 9 > 009 29 STORE < 0002 > 30 END 9 4 18 Screen 5 . . . . Keyboard 7 Printer Introduction-13

Assembly Language programs Data Memory Program Memory 20 IN < 5 > “ 18”

Assembly Language programs Data Memory Program Memory 20 IN < 5 > “ 18” 000 001 18 21 OUT < 9 > 002 22 STORE < 0001 > 003 23 IN < 5 > “ 4” 004 4 28 PC 005 C 006 IR P U ADD < 0004 > 007 22 008 A 24 OUT < 9 > 25 STORE < 0004 > 26 LOAD < 0001 > 27 ADD < 0004 > 28 OUT < 9 > 009 29 STORE < 0002 > 30 END 9 4 18 Screen 5 . . . . Keyboard 7 Printer Introduction-14

Assembly Language programs Data Memory Program Memory 20 IN < 5 > “ 18”

Assembly Language programs Data Memory Program Memory 20 IN < 5 > “ 18” 000 001 18 21 OUT < 9 > 002 22 STORE < 0001 > 003 23 IN < 5 > “ 4” 004 4 29 PC 005 C 006 IR P U OUT < 0009 > 007 22 008 A 24 OUT < 9 > 25 STORE < 0004 > 26 LOAD < 0001 > 27 ADD < 0004 > 28 OUT < 9 > 009 29 STORE < 0002 > 30 END 9 22 4 18 Screen 5 . . . . Keyboard 7 Printer Introduction-15

Assembly Language programs Data Memory Program Memory 20 IN < 5 > “ 18”

Assembly Language programs Data Memory Program Memory 20 IN < 5 > “ 18” 000 001 18 21 OUT < 9 > 002 22 22 STORE < 0001 > 003 004 23 IN < 5 > “ 4” 4 30 PC 005 C 006 STORE < 0002 > IR P U 22 A 007 008 009 24 OUT < 9 > 25 STORE < 0004 > 26 LOAD < 0001 > 27 ADD < 0004 > 28 OUT < 9 > 29 STORE < 0002 > 30 END 9 22 4 18 Screen 5 . . . . Keyboard 7 Printer Introduction-16

Assembly Language programs Data Memory Program ends and machine stops the execution of instructions

Assembly Language programs Data Memory Program ends and machine stops the execution of instructions 000 Program Memory 20 IN < 5 > “ 18” 001 18 21 OUT < 9 > 002 22 22 STORE < 0001 > 003 004 23 IN < 5 > “ 4” 4 31 PC 005 C 006 IR P U END 007 22 008 A 24 OUT < 9 > 25 STORE < 0004 > 26 LOAD < 0001 > 27 ADD < 0004 > 28 OUT < 9 > 009 29 STORE < 0002 > 30 END 9 22 4 18 Screen 5 . . . . Keyboard 7 Printer Introduction-17

COP 2500 Concepts in Computer Science Fall 2011 Euripides Montagne Introduction-18

COP 2500 Concepts in Computer Science Fall 2011 Euripides Montagne Introduction-18