Högnivåspråk och översättning

Similar documents
CPU Structure and Function

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

CPU Structure and Function

1. Fundamental Concepts

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)

Author : Dalbir Singh, Computer Science Deptt. CPU Structure and Functions. 1. Processor Organization

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

Control unit. Input/output devices provide a means for us to make use of a computer system. Computer System. Computer.

Module 5 - CPU Design

William Stallings Computer Organization and Architecture

Processing Unit CS206T

UNIT- 5. Chapter 12 Processor Structure and Function

Lecture 4: RISC Computers

Low-Level Languages. Computer Programs and Programming Languages

DC57 COMPUTER ORGANIZATION JUNE 2013

COP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher

COS 140: Foundations of Computer Science

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

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

8/16/12. Computer Organization. Architecture. Computer Organization. Computer Basics

Lecture 4: RISC Computers

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

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

Chapter 14 - Processor Structure and Function

Digital System Design Using Verilog. - Processing Unit Design

Chapter 12. CPU Structure and Function. Yonsei University

The Stored Program Computer

Computer Organization and Technology Processor and System Structures

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

CS2303 C14 Systems Programming Concepts. Bob Kinicki

Lecture 1: CS2400 Introduction to Computer Science

Discovering Computers 2008

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

Lecture 5: Instruction Pipelining. Pipeline hazards. Sequential execution of an N-stage task: N Task 2

CSE 410. Operating Systems

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

Principles of Programming Languages. Lecture Outline

Registers. Registers

CS 333 Introduction to Operating Systems. Class 1 - Introduction to OS-related Hardware and Software

CSC180: Lecture 2. Wael Aboulsaadat.

Chapter 1. Preview. Reason for Studying OPL. Language Evaluation Criteria. Programming Domains

Mismatch of CPU and MM Speeds

Programming 1. Lecture 1 COP 3014 Fall August 28, 2017

Chapter 16. Control Unit Operation. Yonsei University

Computer Software: Introduction

Hardware Level Organization

William Stallings Computer Organization and Architecture

Lecture 2: Memory Systems

Compiling and Interpreting Programming. Overview of Compilers and Interpreters

Introduction to CPU architecture using the M6800 microprocessor

Notes: The Marie Simulator

Chapter 11 Introduction to Programming in C

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

Programming 1 - Honors

Lecture1: introduction. Outline: History overview Central processing unite Register set Special purpose address registers Datapath Control unit

UNIT I. Pune Vidyarthi Griha s COLLEGE OF ENGINEERING, NASHIK-4. 1

Compilation I. Hwansoo Han

Outcomes. Lecture 13 - Introduction to the Central Processing Unit (CPU) Central Processing UNIT (CPU) or Processor

CS 333 Introduction to Operating Systems. Class 1 - Introduction to OS-related Hardware and Software

CS501_Current Mid term whole paper Solved with references by MASOOM FAIRY

Basics of Microprocessor

The Microarchitecture Level

Chapter Twelve. Systems Design and Development

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 12 Processor Structure and Function

Problem Solving and Program Design - Chapter 1. Cory L. Strope

Chapter 05: Basic Processing Units Control Unit Design. Lesson 15: Microinstructions

Chapter 3:: Names, Scopes, and Bindings (cont.)

General Concepts. Abstraction Computational Paradigms Implementation Application Domains Influence on Success Influences on Design

Programs are: CMPSCI 105/119/120: Programming, Flowchar<ng, and Running Program Flowcharts

AS/A Level Computing Syllabus 2011

Basic Concepts COE 205. Computer Organization and Assembly Language Dr. Aiman El-Maleh

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

Computer Organization II CMSC 3833 Lecture 33


1.3 Data processing; data storage; data movement; and control.

Computer Architecture Lecture No.10,11

SCRAM Introduction. Philipp Koehn. 19 February 2018

Discovering Computers Chapter 13 Programming Languages and Program Development

Borland 105, 278, 361, 1135 Bounded array Branch instruction 7 break statement 170 BTree 873 Building a project 117 Built in data types 126

Chapter 13. The ISA of a simplified DLX Why use abstractions?

Computer Organization & Assembly Language Programming

Micro-programmed Control Ch 15

A Set Of Machine Language Instructions For A Program Is Called Source Code >>>CLICK HERE<<<

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

Micro-programmed Control Ch 15

Computer Architecture and Organization (CS-507)

Main Points of the Computer Organization and System Software Module

MICROPROGRAMMED CONTROL

Practical Malware Analysis

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

What is Computer Architecture?

Organization of Programming Languages (CSE452) Why are there so many programming languages? What makes a language successful?

Instruction Set Architecture

ASSEMBLY LANGUAGE MACHINE ORGANIZATION

Chapter 3:: Names, Scopes, and Bindings (cont.)

Lecture 09. Ada to Software Engineering. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)

Chapter 1. Preliminaries

Lecture 8: RISC & Parallel Computers. Parallel computers

BITG 1113: Introduction To Computers And Programming Language LECTURE 1 LECTURE 1 1

What Are The Main Differences Between Program Counter Pc And Instruction Register Ir

Transcription:

Föreläsning 6 Maskinära programmering Högnivåspråk och översättning Processenhetens struktur Zebo Peng, IDA, LiTH 1 Machine Codes Machine codes [maskinkod] are instructions a computer can execute directly. Different computer types have different machine codes. All information in machines codes is given in binary format. 0 Ex. Machine code 1 0 1 1 0 0 1 0 1 0 1 1 0 0 1 0 MOVE R2 Address of X Zebo Peng, IDA, LiTH 2 1

Assembly Languages An assembly language uses symbolic names to represent operation codes, operand addresses, and instruction addresses: 0 Each instruction of the machine instruction set is represented by an operation identifier. 0 Reference to an operand is expressed by a symbolic address. 0 The next instruction address when a jump occurs is also expressed by a symbolic address. Assembly code MOVE R2 X Different computer types have different assembly codes. Zebo Peng, IDA, LiTH 3 Assembling Before an assembly program can be executed, it must be translated into machine codes. This translation is done by a program called an assembler [assemblator]. Assembly program Assembler Machine codes Zebo Peng, IDA, LiTH 4 2

The Assembling Tasks Translate the operation identifiers into their corresponding binary codes. Assign the symbolic addresses physical memory addresses (or logical addresses, relative addresses). Perform macro expansion. 0 A macro is a sequence of instructions which is defined once and used at any place where the sequences should execute. 0 Macro expansion places the machine code sequences at each place the macro is used. Handle subroutine calls. Zebo Peng, IDA, LiTH 5 Macro definition: DIV X Y : Macro vs. Subroutine Subroutine definition: DIV X Y : Macro usage: Subroutine usage: DIV 120 60; DIV 121 60; DIV 120 60; DIV 121 60; Machine codes: Machine codes: Sub1 120 60; Sub1 120 60; Zebo Peng, IDA, LiTH 6 3

High-Level Languages Application programs are typically written in a highlevel language which has instructions much more powerful than assembly instructions. A high-level language is not related to the architecture of any computer, while machine and assembly languages are machine dependent. It takes shorter time to program in a high-level language, but it generates also less efficient codes. The translation of a high-level language program to its machine codes can be done by a compiler or an interpreter. Zebo Peng, IDA, LiTH 7 High-Level Language Examples C++ C Fortran Java Pascal Ada Prolog Lisp Simula Smalltalk Basic Cobol Zebo Peng, IDA, LiTH 8 4

Compilation [ [Kompilering] A program is translated into machine codes before execution starts. HL language program Compiler Machine codes Input data Execution Output data Zebo Peng, IDA, LiTH 9 Objectives of a Compiler It should produce machine codes which are as efficient as possible during execution. The compiler itself should be efficient and take little memory space. It should provide the user with as accurate diagnosis information as possible. Zebo Peng, IDA, LiTH 10 5

Different Types of Compilers An optimizing compiler [optimerande kompilator] puts in very much time to generate as efficient machine codes as possible. 0 Used usually when the development and test of a program is finished, and the final machine codes are to be generated. A test compiler [testkompilatorn] compiles quickly and generates codes which are not efficient. 0 Used when a program is tested. A course compiler [kurskompilator] puts in time to find all possible bugs and generate meaningful debug information. 0 Used in education. Zebo Peng, IDA, LiTH 11 Interpretation [ [Interpretering] An interpreted program is not translated into machine codes. Rather the instructions of the program are executed by the interpreter. The interpreter reads the program instructions as date. For each instruction in the program, a sequence of instruction of the interpreter is executed. HL language program Input data Interpreter Output data Zebo Peng, IDA, LiTH 12 6

System vs. Application Program System programs are programs which make it easier to run application programs: 0 Operative systems 0 Assemblers 0 Compilers and interpreters 0 Linkers 0 Loaders Application programs are the programs the end-users execute to accomplish certain tasks. Zebo Peng, IDA, LiTH 13 Summary A computer program can be written with different programming languages. Only programs in machine codes can be directly executed. Other programs must be first translated into machine codes before execution. Generally speaking, a translator take a program written in a source language [källspråk] and translate it into another program in a target language [målspråk] or object language [objektspråk]. Zebo Peng, IDA, LiTH 14 7

CPU The main function of the CPU is to execute instructions stored in the main memory. The major components of the CPU: 0 ALU: perform the computer s data processing functions. 0 Control unit: control the operation of the CPU and hence the computer. 0 A set of registers: provide storage internal to the CPU. 0 Internal CPU bus: provide data movement paths among the control unit, ALU, and registers. Zebo Peng, IDA, LiTH 15 CPU Internal Structure Zebo Peng, IDA, LiTH 16 8

Registers CPU must have some working space (temporary storage). These storage units are called registers. They are the top level component in the memory hierarchy. Number and function of the registers vary between different computers. Registration organization is one of the major design decisions. Zebo Peng, IDA, LiTH 17 Register Organization The registers serve two main functions: 0 User-Visible Registers: used by machine or assembly language programmers to minimize memory access. General-purpose registers Data registers Address registers Condition code registers 0 Control and Status Registers: used by the control unit to control the operation of the CPU, and by the operating system to control the execution of programs. Zebo Peng, IDA, LiTH 18 9

Control and Status Registers Program Counter (PC) Instruction Register (IR) Memory Address Register (MAR) Memory Buffer (Transfer) Register (MBR) Program status word (PSW) used to store the status of current instruction execution, such as 0 Zero set when the computation result is zero; 0 Overflow indicating arithmetic overflow; 0 Interrupt control to enable or disable interrupts; 0 Supervisor indicating if the execution is in supervisor mode or user mode. Zebo Peng, IDA, LiTH 19 Register Organization Examples Zebo Peng, IDA, LiTH 20 10

Summary The structure and function of the CPU are the most important architectural features of a computer system. It is essential to reduce the need to access the main memory in order to increase CPU performance, which can be achieved by using registers and a cache. Zebo Peng, IDA, LiTH 21 11