CSE100 Lecture03 Machines, Instructions, and Programs Introduction to Computer Systems

Similar documents
Computer Organization II CMSC 3833 Lecture 33

Department of Computer and Mathematical Sciences. Lab 4: Introduction to MARIE

Notes: The Marie Simulator

Computer Systems and Networks. ECPE 170 Jeff Shafer University of the Pacific. Introduc>on to MARIE

2.2 THE MARIE Instruction Set Architecture

Problem Points Your Points Total 80

CC312: Computer Organization

The MARIE Architecture

CS311 Lecture: The Architecture of a Simple Computer

Chapter 4. MARIE: An Introduction to a Simple Computer. Chapter 4 Objectives. 4.1 Introduction. 4.2 CPU Basics

CMSC 3833 Lecture 37

Computer Architecture. CSE 1019Y Week 16. Introduc>on to MARIE

Computer Systems and Networks. ECPE 170 Jeff Shafer University of the Pacific. MARIE Simulator

CDA 3103 Computer Organization Homework #7 Solution Set

Chapter 4. MARIE: An Introduction to a Simple Computer

MARIE: An Introduction to a Simple Computer

SCRAM Introduction. Philipp Koehn. 19 February 2018

MARIE: An Introduction to a Simple Computer

Chapter 4. Chapter 4 Objectives. MARIE: An Introduction to a Simple Computer

Chapter 4. Chapter 4 Objectives

CPU ARCHITECTURE. QUESTION 1 Explain how the width of the data bus and system clock speed affect the performance of a computer system.

General purpose registers These are memory units within the CPU designed to hold temporary data.

Laboratory. Low-Level. Languages. Objective. References. Study simple machine language and assembly language programs.

Computer Architecture 2/26/01 Lecture #

a number of pencil-and-paper(-and-calculator) questions two Intel assembly programming questions

Little Man Computer (LMC)

CPU Structure and Function

Computer architecture Assignment 3

Introduction to CPU architecture using the M6800 microprocessor

COMARCH. COMPUTER ARCHITECTURE TERM 3 SY COMPUTER ENGINEERING DE LA SALLE UNIVERSITY Quiz 1

IS1200/IS1500. Lab 5 Processor Design v1.0

Chapter 2 Instruction Set Architecture

William Stallings Computer Organization and Architecture

Control Unit Implementation

Instruc=on Set Architecture

Assembly Language: Overview!

Introduction to Computers - Chapter 4

CHAPTER 4 MARIE: An Introduction to a Simple Computer

Running Applications

William Stallings Computer Organization and Architecture. Chapter 11 CPU Structure and Function

Computer Organization

CPU. Fall 2003 CSE 207 Digital Design Project #4 R0 R1 R2 R3 R4 R5 R6 R7 PC STATUS IR. Control Logic RAM MAR MDR. Internal Processor Bus

UNIT 8C Computer Organization: The Machine s Language. von Neumann Architecture

CPU Structure and Function. Chapter 12, William Stallings Computer Organization and Architecture 7 th Edition

CPU Structure and Function

DC57 COMPUTER ORGANIZATION JUNE 2013

Micro-Operations. execution of a sequence of steps, i.e., cycles

Block diagram view. Datapath = functional units + registers

Hardware Revision. AQA Computing AS-Level COMP2. 63 minutes. 60 marks. Page 1 of 24

Class Notes. Dr.C.N.Zhang. Department of Computer Science. University of Regina. Regina, SK, Canada, S4S 0A2

C++ to assembly to machine code

William Stallings Computer Organization and Architecture

Microprogrammed Control Approach

Suggested Readings! Recap: Pipelining improves throughput! Processor comparison! Lecture 17" Short Pipelining Review! ! Readings!

Fundamentals of Computer Architecture. 8. Bringing It All Together The Hardware Engineer s Perspective

Why learn Computer Programming? Computer-based problem solving in Science and Engineering. Why learn Fortran? Elementary Computer Organization

A3 Computer Architecture

Computer Organization. Structure of a Computer. Registers. Register Transfer. Register Files. Memories

Programming Level A.R. Hurson Department of Computer Science Missouri University of Science & Technology Rolla, Missouri

A B C ((NOT A) AND B) OR C

Computer Architecture and Organization: L06: Instruction Cycle

Instruction-set Design Issues: what is the ML instruction format(s) ML instruction Opcode Dest. Operand Source Operand 1...


Machine code. Nils Jansen December 12, 2017

Introduction to Programming

Computer Organization and Architecture, Pt. 2

Teaching London Computing

Assembly Language Programming of 8085

The Assembly Language of the Boz 5

Computer Architecture

Chapter 9 Computer Design Basics

ADD R3, R4, #5 LDR R3, R4, #5

Blog -

MARIE: An Introduction to a Simple Computer

THE MICROPROCESSOR Von Neumann s Architecture Model

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University

20/08/14. Computer Systems 1. Instruction Processing: FETCH. Instruction Processing: DECODE

This simulated machine consists of four registers that will be represented in your software with four global variables.

CS 24: INTRODUCTION TO. Spring 2018 Lecture 3 COMPUTING SYSTEMS

Unit II Basic Computer Organization

There are four registers involved in the fetch cycle: MAR, MBR, PC, and IR.

Module 5 - CPU Design

Assembly Language Fundamentals

COSC121: Computer Systems: Review

The CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram:

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

Chapter 12. CPU Structure and Function. Yonsei University

CSC 2400: Computer Systems. Towards the Hardware: Machine-Level Representation of Programs

Basic Computer Organization and Design Part 2/3

PSIM: Processor SIMulator (version 4.2)

Second Part of the Course

Micro-programmed Control Ch 15

CHAPTER 5 Basic Organization and Design Outline Instruction Codes Computer Registers Computer Instructions Timing and Control Instruction Cycle

Introduction to MiniSim A Simple von Neumann Machine

Machine Instructions vs. Micro-instructions. Micro-programmed Control Ch 15. Machine Instructions vs. Micro-instructions (2) Hardwired Control (4)

Micro-programmed Control Ch 15

Binghamton University. CS-140 Fall Pippin

Chapter 4. MARIE: An Introduction to a Simple Computer 4.8 MARIE 4.8 MARIE A Discussion on Decoding

ECE 486/586. Computer Architecture. Lecture # 7

CSC 8400: Computer Systems. Machine-Level Representation of Programs

Transcription:

Machines, Instructions, and Introduction to Computer Systems M.A. Computer Science and Engineering Bangladesh University of Engineering and Technology Dhaka 1000, Bangladesh CSE, BUET, 2009

MARIE Machine MARIE Description MARIE Instruction Set MARIE: An Example Machine MARIE Simulator A really-inituitive and easy-to-use simulated computer. It helps quickly understand how computers really work The architecture has various fundamental features. MARIE Architecture

MARIE Machine MARIE Description MARIE Instruction Set MARIE Inside Details MainMemory holds data and program both. MARIE has 12-bit memory addresses meaning 2 12 locations. Each location contains 16-bit data; all data are signed meaning the range is -32768 to +32767. InstructionSet contains only 13 instructions. All instructions run in the memory operand mode. So each instruction has a 16-bit op-code 4 bits for the instruction code and 12 bits for the memory address. IntructionRegister (IR) internally holds the current instruction op-code being exectued by the computer. ProgramCounter (PC) internally holds the memory address of the next instruction to be executed. MemoryAddressRegister (MAR) internally holds the address of the memory location to be read from or written into.

MARIE Machine MARIE Description MARIE Instruction Set MARIE Inside Details... MemoryBufferRegister (MBR) internally holds the data value to be written into the memory or the data value read from the memory. Accumulator (AC) holds the data value to be operated on. This register is available to the user during programming. Input (IN) holds the data value to be read from an input port/device. This register is available to the user during programming. Output (OUT) holds the data value to be written to an output port/device. This register is available to the user during programming. ControlUnit is responsible for sending necessary (read/write) signals timely to the memory and the registers. The signals depend on the current instruction in the IR.

MARIE Machine MARIE Description MARIE Instruction Set MARIE Instruction Set Mnemonic Hex Description Clear A Put all zeros in AC Add X 3 Add the value of address X to AC AddI X B Add indirect: Use the value at X as the address of the data operand to add to AC Subt X 4 Subtract the value of address X from AC Input 5 Input a value from the keyboard into AC Output 6 Output the value in AC to the display Load X 1 Load the value of address X into AC Store X 2 Store the value of AC at address X Halt 7 Terminate program

MARIE Machine MARIE Description MARIE Instruction Set MARIE Instruction Set... Mnemonic Hex Description Jump X 9 Load the value of X into PC JumpI X C Use X s value as the address to jump to JnS X 0 Store the PC at X and jump to X+1 Skipcond X 8 Skip next instruction on condition. Bits 10 and 11 of X specify the condition. If the two bits are 00, this translates to skip if the AC is negative. If the two bits are 01, this means skip if the AC is equal to 0. Finally, if the two bits are 10, this translates to skip if the AC is greater than 0. For example, Skipcond 800 if AC > 0, Skipcond 400 if AC = 0, and Skipcond 000 if AC < 0

MARIE Assembly Program MARIE Executable Program MARIE Programming MARIE Assembly Program ORG 100 /Program will start at memory address 100 If, Load X /Load the first value Subt Y /Subtract the value of Y, store result in AC Skipcond 400 /If AC=0, skip the next instruction Jump Else /Jump to Else part if AC is not equal to 0 Then, Load X /Reload X so it can be doubled Add X /Double X Store X /Store the new value Jump Endif /Skip over the false, or else, part to end of if Else, Load Y /Start the else part by loading Y Subt X /Subtract X from Y Store Y /Store Y-X in Y Endif, Halt /Terminate program (it doesn t do much!) X, Dec 12 /Value of the variable X Y, Dec 20 /Value of the variable Y END

MARIE Assembly Program MARIE Executable Program MARIE Programming MARIE Object/Executable Program ORG 100 /Program will start at memory address 100 100 110C If, LOAD X /Load the first value 101 410D SUBT Y /Subtract the value of Y, store result in AC 102 8400 SKIPCOND 400 /If AC=0, skip the next instruction 103 9108 JUMP Else /Jump to Else part if AC is not equal to 0 104 110C Then, LOAD X /Reload X so it can be doubled 105 310C ADD X /Double X 106 210C STORE X /Store the new value 107 910B JUMP Endif /Skip over the false, or else, part to end of if 108 110D Else, LOAD Y /Start the else part by loading Y 109 410C SUBT X /Subtract X from Y 10A 210D STORE Y /Store Y-X in Y 10B 7000 Endif, HALT /Terminate program (it doesn t do much!) 10C 000C X DEC 12 /Value of the variable X 10D 0014 Y DEC 20 /Value of the variable Y END

MARIE Assembly Program MARIE Executable Program MARIE Programming Programming for MARIE Machines How to write programs? Write the assembly program using the mnemonics. Translate the assembly program into op-codes (numbers). How to obtain a translator program? Initially there is no translator/assembler program.. Your first program should be a small assembler. Translate the assembler program completely manually. This time write probably a large assembler program. Assemble the large assembler using the small assembler.

MARIE Assembly Program MARIE Executable Program MARIE Programming High Level Programming for MARIE A High Level Program X = 5 Y = 7 Z = X + Y A Low Level Program Load X X, Dec 5 Add Y Y, Dec 7 Store Z Z, Dec 0 High Level to Executable Write a high level program; which is easier than writing an assembly program. Currently no high level language exists. Using a compiler program, compile the high level program into an assembly program. Currently no compiler exists. Using an assembler program, assemble the assembly program into an executable program. Currently an assembler exists.

MARIE Program Execution Running vs Tracing MARIE Program Execution Program Loading for Execution? The executable program is copied to the memory at the memory location specified in the assembly program. Register PC is set with the first memory address of the program and the system clock starts running. How instructions are executed by the Control Unit? The instruction at the memory location determined by the current value of the PC is fetched to IR. The value of the IR is then decoded and the meaning of the instruction is understood.

MARIE Program Execution Running vs Tracing MARIE Program Execution... How instructions are executed by the Control Unit?... The value of the PC is incremented so that it now holds the address where the next instruction will be fetched from. Depending on the instruction in the IR, other read and write signals are sent to the registers to have the desired result. When the current instruction execution is finished, the next cycle begins which fetch, decode, and execute the next instruction in the memory. This continues until the HALT instruction is executed.

MARIE Program Execution Running vs Tracing Program Execution: Running vs Tracing Running vs Tracing a Program Running means executing all instructions at one time. Tracing means executing only one instruction at a time. Tracing or Single Stepping for Debugging) Assemble can detect only syntactical bugs or mistakes. For semantical bugs, we need to trace the program. An example semantical bug is Subt X instead of Add X. To catch this bug, we need to examine values of the registers and memory addresses after every instruction.