Bilgisayar Organizasyonu. Programlama. Programlama. Programlama. Programlama. http://www.ecs.umass.edu/ece/vspgroup /burleson/courses/232/spim/



Similar documents
5 MIPS Assembly Language

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

Translating C code to MIPS

An Introduction to Assembly Programming with the ARM 32-bit Processor Family

What to do when I have a load/store instruction?

Summary of the MARIE Assembly Language

LSN 2 Computer Processors

Instruction Set Architecture (ISA)

COMP 303 MIPS Processor Design Project 4: MIPS Processor Due Date: 11 December :59

Instruction Set Architecture

We will use the accumulator machine architecture to demonstrate pass1 and pass2.

Instruction Set Design

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

Typy danych. Data types: Literals:

EC 362 Problem Set #2

1 Classical Universal Computer 3

Reduced Instruction Set Computer (RISC)

Central Processing Unit (CPU)

Chapter 2 Topics. 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC

Levels of Programming Languages. Gerald Penn CSC 324

Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University

Central Processing Unit Simulation Version v2.5 (July 2005) Charles André University Nice-Sophia Antipolis

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-12: ARM

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings:

Solution: start more than one instruction in the same clock cycle CPI < 1 (or IPC > 1, Instructions per Cycle) Two approaches:

Instruction Set Architecture (ISA) Design. Classification Categories

Administrative Issues

Figure 1: Graphical example of a mergesort 1.

Intel 8086 architecture

Computer Systems Architecture

A SystemC Transaction Level Model for the MIPS R3000 Processor

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

WAR: Write After Read

PROBLEMS #20,R0,R1 #$3A,R2,R4

Compiler I: Syntax Analysis Human Thought

OAMulator. Online One Address Machine emulator and OAMPL compiler.

In the Beginning The first ISA appears on the IBM System 360 In the good old days

CSE 141 Introduction to Computer Architecture Summer Session I, Lecture 1 Introduction. Pramod V. Argade June 27, 2005

HC12 Assembly Language Programming

CSCI 3136 Principles of Programming Languages

MIPS Assembly Code Layout

Administration. Instruction scheduling. Modern processors. Examples. Simplified architecture model. CS 412 Introduction to Compilers

MIPS Assembler and Simulator

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

Introducción. Diseño de sistemas digitales.1

High level code and machine code

Chapter 5 Instructor's Manual

CPU Organization and Assembly Language

THUMB Instruction Set

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX

High-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)

Review: MIPS Addressing Modes/Instruction Formats

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

EE282 Computer Architecture and Organization Midterm Exam February 13, (Total Time = 120 minutes, Total Points = 100)

Lecture Outline. Stack machines The MIPS assembly language. Code Generation (I)

CPU Organisation and Operation

Processor Architectures

Microprocessor and Microcontroller Architecture

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

CHAPTER 4 MARIE: An Introduction to a Simple Computer

Byte code Interpreter for 8051 Microcontroller

More MIPS: Recursion. Computer Science 104 Lecture 9

Computer Architectures

Chapter 7D The Java Virtual Machine

An Overview of Stack Architecture and the PSC 1000 Microprocessor

Chapter 2 Logic Gates and Introduction to Computer Architecture

Compiler Construction

Lab Work 2. MIPS assembly and introduction to PCSpim

A-level COMPUTER SCIENCE

M A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE

Computer Organization and Components

BCD (ASCII) Arithmetic. Where and Why is BCD used? Packed BCD, ASCII, Unpacked BCD. BCD Adjustment Instructions AAA. Example

a storage location directly on the CPU, used for temporary storage of small amounts of data during processing.

4 Machine Language. Make everything as simple as possible, but not simpler. Albert Einstein ( )

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Computer Architecture TDTS10

Computer Architecture Basics

Execution Cycle. Pipelining. IF and ID Stages. Simple MIPS Instruction Formats

Pipelining Review and Its Limitations

İSTANBUL AYDIN UNIVERSITY

Lecture 3 Addressing Modes, Instruction Samples, Machine Code, Instruction Execution Cycle

Notes on Assembly Language

Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z)

Chapter 4 Lecture 5 The Microarchitecture Level Integer JAVA Virtual Machine

MACHINE ARCHITECTURE & LANGUAGE

CSE 141L Computer Architecture Lab Fall Lecture 2

Language Processing Systems

picojava TM : A Hardware Implementation of the Java Virtual Machine

Chapter 9 Computer Design Basics!

Introduction to MIPS Assembly Programming

Computer Organization and Architecture

on an system with an infinite number of processors. Calculate the speedup of

Contents. System Development Models and Methods. Design Abstraction and Views. Synthesis. Control/Data-Flow Models. System Synthesis Models

How To Write An Array In A Microsoft Zil

Where we are CS 4120 Introduction to Compilers Abstract Assembly Instruction selection mov e1 , e2 jmp e cmp e1 , e2 [jne je jgt ] l push e1 call e

1 Computer hardware. Peripheral Bus device "B" Peripheral device. controller. Memory. Central Processing Unit (CPU)

The Design of the Inferno Virtual Machine. Introduction

Computer organization

VLIW Processors. VLIW Processors

UT69R000 MicroController Software Tools Product Brief

Transcription:

Bilgisayar Organizasyonu http://wwwecsumassedu/ece/vspgroup /burleson/courses/232/spim/ Ismail Kadayif Canakkale Onsekiz Mart Universitesi Bilgisayar Muhendisligi 4/13/2004 Formal Diller 11 4/13/2004 Bilgisayar Organizasyonu 12 programlama dilleri high-level s (yuksek seviyeli diller) (C, C++, Java, Fortran, ) komplex operationlar ifade edilebilir programlama islemini kolaylastirir low-level s (alcak seviyeli diller) (C, asssembly, makine dili, ) operationlari basit (program yazimi zor ve kolayca hata yapilmaya musait) hypotenuse := sqrt (sqr(a) + sqr(b) ); mul asquare, a, b mul bsquare, b, b mdd sumsquare, asquare, bsquare sqrt hypotenuse, sumsquare 4/13/2004 Bilgisayar Organizasyonu 13 4/13/2004 Bilgisayar Organizasyonu 14 hypotenuse := sqrt (sqr(a) + sqr(b) ); ls $f0, aa muls $f0,$f0,$f0 ls $f2, bb muls $f2, $f2, $f2 adds $f4, $f0, $f2 ss $f4, sumsquare negs $f6, $f4 ss $f6, hypotenuse 4/13/2004 Bilgisayar Organizasyonu 15 0011 1100 0000 0001 0001 0000 0000 0000 1100 0100 0010 0000 0000 0000 0000 0000 0100 0110 0000 0000 0000 0000 0000 0010 0011 1100 0000 0001 0001 0000 0000 0000 4/13/2004 Bilgisayar Organizasyonu 16

Compilation Bilgisayar Mimarisi high-level compiler assembly assembler machine assembly dilinde programlama bilgisayar mimarisine bagli olarak degisiklik gosterir (instruction set architecture) (ISA) ISA az sayida bir operationlardan (instruction) olusur Instructionlar hardware tarafindan dogrudan calistirilabilirler bilgisayarin machine ureticisi tarafindan belirlenir MIPS RISC architecture 4/13/2004 Bilgisayar Organizasyonu 17 4/13/2004 Bilgisayar Organizasyonu 18 Low-level Languages (MIPS mimarisinde) MIPS RISC mimarisindeki abstraction True Assembly Language (TAL): ISA daki instructionslardan olusur TAL dan daha asagi seviyede programlama yapilamaz More Abstract Language (MAL) (MIPS Assembly Language) MIPS RISC assembler, MAL programi once TAL programa, daha sonra TAL daki her instructionu MIPS RISC makine koduna cevirir MAL programlar TAL programlar kadar efficient tir MAL da programlama TAL da programlamadan daha kolay Simple Abstract Language (SAL) MAL dan daha yuksek seviyelidir High-level lerle Assembly Language arasindaki boslugu doldurmak icin kullanilir SAL MAL TAL MIPS RISC machine 4/13/2004 Bilgisayar Organizasyonu 19 4/13/2004 Bilgisayar Organizasyonu 110 Bilgisayar Organizasyonu programin calismasi sirasinda, processor instructionlari run eder instructionlar degiskenlere nasil degerler atandigini (memory) belirler memory nin boyu sabit fakat oldukca genistir programda tanimlanan her bir variable (degiskene) karsi bir bellek gozu (memory location tahsis edilir herhangi bir degiskenin degerinin okunmasi/degiskene deger atanmasi, bu degisknin bulundugu bellek gozunun okunmasi/yazilmasi anlamina gelir (load/store) binding :bellek gozunun bir degiskene tahsis edilmesine CPU Bilgisayar Organizasyonu Kontrol Read Write Memory CPU (Central Processing Unit): 4/13/2004 Bilgisayar Organizasyonu 111 4/13/2004 Bilgisayar Organizasyonu 112

Program Execution Sirasinda Temel Adimlar part1: x1:=x2+x3; x4:=x2-x5; if(x4=x1) then goto 10; x1:=x2+x5; 10: part1: add x1, x2, x3 sub x4, x2, x5 beq x4, x1, part2 add x1, x1, x5 part2: 1 instruction fetch 2 program counter (PC) update 3 instruction decode 4 operand load 5 operation execution 6 storage of results (sonuclarin bellge yazilmasi) 4/13/2004 Bilgisayar Organizasyonu 113 4/13/2004 Bilgisayar Organizasyonu 114 SAL da program summation(input, output); var end n: integer; sum: integer; i: integer; write( Please Enter a positive integer: ); readln(n); writeln; sum:=0; for i:=0 to n do sum:=sum+i; write( The sum of the firs ); writeln(n); write( integers is ); writeln(sum); data str1: asciiz Please enter a positive integer: str2: asciiz The sum of the firs str3: asciiz integers is newline: byte \n n: word 0 sum: word 0 i: word 0 temp: word 4/13/2004 Bilgisayar Organizasyonu 115 4/13/2004 Bilgisayar Organizasyonu 116 Branch Instructions (SAL) start: puts str1 get n put newline for: sub temp, n, i bltz temp, endfor add sum, sum, i add i, i, 1 b for endfor: puts str2 put n puts str3 put sum put newline done 4/13/2004 Bilgisayar Organizasyonu 117 b label # goto label beq x, y, label # if x = y then goto label bne x, y, label # if x <> y then goto label blt x, y, label # if x < y then goto label bgt x, y, label # if x > y then goto label ble x, y, label # if x <= y then goto label bge x, y, label # if x >= y then goto label 4/13/2004 Bilgisayar Organizasyonu 118

Branch Instructions (SAL) Communication Instructions bltz x, label # if x < 0 then goto label bgtz x, label # if x > 0 then goto label blez x, label # if x <= 0 then goto label bgez x, label # if x >= 0 then goto label beqz x, label # if x = 0 then goto label bnez x, label # if x <> y then goto label get x # readln(x) (x word veya float) get x # read(x) (x byte) put x # write(x) (x, word, float, byte) puts stringname # write(string) (asciiz) 4/13/2004 Bilgisayar Organizasyonu 119 4/13/2004 Bilgisayar Organizasyonu 120 if (A > 0) then B := C div A else B := A+10; blez A, elsepart div B, C, A b endif elsepart: add B, A, 10 bgtz A, ifpart add B, A, 10 b endif ifpart: div B, C, A 4/13/2004 Bilgisayar Organizasyonu 121 4/13/2004 Bilgisayar Organizasyonu 122 if ( (A = B) or ( C < D ) ) then A := A + 1; B := B - 1; D := A + C; beq A, B, do_if blt C, D, do_if b end_if do_if: add A, A, 1 add B, B, -1 add D, A, C 4/13/2004 Bilgisayar Organizasyonu 123 if ( (A = B) and ( C = D ) or ( E < 0 ) ) then A := A + 1; C := E; bne A, B, check_e beq C, D, do_if check_e: bgez E, end_if do_if: add A, A, 1 move C, E end_if: 4/13/2004 Bilgisayar Organizasyonu 124

Procedure result := 1; counter := exponent; while (counter > 0 ) do result := result * base counter := counter 1; move result, 1 move counter, exponent while: blez counter, endwhile mul result, result, base sub counter, counter, 1 b while endwhile: 4/13/2004 Bilgisayar Organizasyonu 125 Programin moduler olmasina yardimci olurlar Procedure kullanimi SAL sinirlamalari Procedura parametre aktarma olanagi yoktur Recursive procedure cagirma olanagi yoktur Temel adimlar Save return address Procedure call Execute procedure Return 4/13/2004 Bilgisayar Organizasyonu 126 text call: b proc rtnaddr: proc: b procedure call return location # procedure code here rtnaddr return_addr1: return_addr2: proc1: b la proc1_ret, ret_addr1 b proc1 la proc1_ret, ret_addr2 b proc1 # procedure code here (proc1_ret) 4/13/2004 Bilgisayar Organizasyonu 127 4/13/2004 Bilgisayar Organizasyonu 128