170 likes | 233 Views
This lecture demonstrates the execution of a program in the tiny VN machine using assembly language. It showcases the fetch and execute cycles, highlighting the Assembly Language programs' execution steps and memory processes. Through examples and cycles, the session delves into the Tiny VN Computer Instruction Set Architecture (ISA) for program execution scenarios.
E N D
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 tiny VN Computer Instruction Set Architecture (ISA). For the first instruction in the following example we will show The fetch and execution cycles for the first instruction
Data Memory Program Memory • IN < 5 > “18” • OUT < 9 > • STORE < 0001 > • IN < 5 > “4” • OUT < 9 > • STORE < 0004 > • LOAD < 0001 > • ADD < 0004 > • OUT < 9 > • STORE < 0002 > • END 000 001 002 003 004 005 006 007 008 009 Assembly Language programs 20 PC C P U IR A 9 5 7 ....... Keyboard Printer Screen
Data Memory Program Memory FETCH CYCLE 1.- Fetch instruction from memory to IR 2.- PC PC + 1 • IN < 5 > “18” • OUT < 9 > • STORE < 0001 > • IN < 5 > “4” • OUT < 9 > • STORE < 0004 > • LOAD < 0001 > • ADD < 0004 > • OUT < 9 > • STORE < 0002 > • END 000 001 002 003 004 005 006 007 008 009 Assembly Language programs 21 PC C P U IN < 5 > IR A 9 5 7 ....... Keyboard Printer “type in 18” Screen
EXECUTION CYCLE (The computer reads in the typed value (18) and saves it in A) Data Memory Program Memory • IN < 5 > “18” • OUT < 9 > • STORE < 0001 > • IN < 5 > “4” • OUT < 9 > • STORE < 0004 > • LOAD < 0001 > • ADD < 0004 > • OUT < 9 > • STORE < 0002 > • END 000 001 002 003 004 005 006 007 008 009 Assembly Language programs 21 PC C P U IN < 5 > IR 18 A 9 5 7 ....... Keyboard Printer Screen
Data Memory FETCH CYCLE 1.- Fetch instruction from memory to IR 2.- PC PC + 1 Program Memory • IN < 5 > “18” • OUT < 9 > • STORE < 0001 > • IN < 5 > “4” • OUT < 9 > • STORE < 0004 > • LOAD < 0001 > • ADD < 0004 > • OUT < 9 > • STORE < 0002 > • END 000 001 002 003 004 005 006 007 008 009 Assembly Language programs 22 PC C P U OUT < 9 > IR 18 A 9 5 7 ....... Keyboard Printer Screen
EXECUTION CYCLE (The computer displays the contents of A on the screen) Data Memory Program Memory • IN < 5 > “18” • OUT < 9 > • STORE < 0001 > • IN < 5 > “4” • OUT < 9 > • STORE < 0004 > • LOAD < 0001 > • ADD < 0004 > • OUT < 9 > • STORE < 0002 > • END 000 001 002 003 004 005 006 007 008 009 Assembly Language programs 22 PC C P U OUT < 9 > IR 18 A 9 5 7 ....... 18 Keyboard Printer Screen
So far we have shown the execution of each instruction describing the instruction cycle, which has two steps: Fetch and Execute. 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.
Data Memory Program Memory • IN < 5 > “18” • OUT < 9 > • STORE < 0001 > • IN < 5 > “4” • OUT < 9 > • STORE < 0004 > • LOAD < 0001 > • ADD < 0004 > • OUT < 9 > • STORE < 0002 > • END 000 001 002 003 004 005 006 007 008 009 18 Assembly Language programs 23 PC C P U STORE < 0001 > IR 18 A 9 5 7 ....... 18 Keyboard Printer Screen
Data Memory Program Memory • IN < 5 > “18” • OUT < 9 > • STORE < 0001 > • IN < 5 > “4” • OUT < 9 > • STORE < 0004 > • LOAD < 0001 > • ADD < 0004 > • OUT < 9 > • STORE < 0002 > • END 000 001 002 003 004 005 006 007 008 009 18 Assembly Language programs 24 PC C P U IN < 5 > IR 4 A 9 5 7 ....... 18 Keyboard Printer Screen
Data Memory Program Memory • IN < 5 > “18” • OUT < 9 > • STORE < 0001 > • IN < 5 > “4” • OUT < 9 > • STORE < 0004 > • LOAD < 0001 > • ADD < 0004 > • OUT < 9 > • STORE < 0002 > • END 000 001 002 003 004 005 006 007 008 009 18 Assembly Language programs 25 PC C P U OUT < 9 > IR 4 A 9 5 7 ....... 4 18 Keyboard Printer Screen
Data Memory Program Memory • IN < 5 > “18” • OUT < 9 > • STORE < 0001 > • IN < 5 > “4” • OUT < 9 > • STORE < 0004 > • LOAD < 0001 > • ADD < 0004 > • OUT < 9 > • STORE < 0002 > • END 000 001 002 003 004 005 006 007 008 009 18 Assembly Language programs 4 26 PC C P U STORE < 0004 > IR 4 A 9 5 7 ....... 4 18 Keyboard Printer Screen
Data Memory Program Memory • IN < 5 > “18” • OUT < 9 > • STORE < 0001 > • IN < 5 > “4” • OUT < 9 > • STORE < 0004 > • LOAD < 0001 > • ADD < 0004 > • OUT < 9 > • STORE < 0002 > • END 000 001 002 003 004 005 006 007 008 009 18 Assembly Language programs 4 27 PC C P U LOAD < 0001 > IR 18 A 9 5 7 ....... 4 18 Keyboard Printer Screen
Data Memory Program Memory • IN < 5 > “18” • OUT < 9 > • STORE < 0001 > • IN < 5 > “4” • OUT < 9 > • STORE < 0004 > • LOAD < 0001 > • ADD < 0004 > • OUT < 9 > • STORE < 0002 > • END 000 001 002 003 004 005 006 007 008 009 18 Assembly Language programs 4 28 PC C P U ADD < 0004 > IR 22 A 9 5 7 ....... 4 18 Keyboard Printer Screen
Data Memory Program Memory • IN < 5 > “18” • OUT < 9 > • STORE < 0001 > • IN < 5 > “4” • OUT < 9 > • STORE < 0004 > • LOAD < 0001 > • ADD < 0004 > • OUT < 9 > • STORE < 0002 > • END 000 001 002 003 004 005 006 007 008 009 18 Assembly Language programs 4 29 PC C P U OUT < 0009 > IR 22 A 9 5 7 ....... 22 4 18 Keyboard Printer Screen
Data Memory Program Memory • IN < 5 > “18” • OUT < 9 > • STORE < 0001 > • IN < 5 > “4” • OUT < 9 > • STORE < 0004 > • LOAD < 0001 > • ADD < 0004 > • OUT < 9 > • STORE < 0002 > • END 000 001 002 003 004 005 006 007 008 009 18 22 Assembly Language programs 4 30 PC C P U STORE < 0002 > IR 22 A 9 5 7 ....... 22 4 18 Keyboard Printer Screen
Data Memory Program Memory Program ends and machine stops the execution of instructions • IN < 5 > “18” • OUT < 9 > • STORE < 0001 > • IN < 5 > “4” • OUT < 9 > • STORE < 0004 > • LOAD < 0001 > • ADD < 0004 > • OUT < 9 > • STORE < 0002 > • END 000 001 002 003 004 005 006 007 008 009 18 22 Assembly Language programs 4 31 PC C P U END IR 22 A 9 5 7 ....... 22 4 18 Keyboard Printer Screen