CPS 001 24.1 Today’s topics Machine Architecture More Low-level Programming Upcoming Language Translation ( G.I. Chapter 9) Reading Great Ideas, Chapters.

Slides:



Advertisements
Similar presentations
Chapt.2 Machine Architecture Impact of languages –Support – faster, more secure Primitive Operations –e.g. nested subroutine calls »Subroutines implemented.
Advertisements

1 CIS 461 Compiler Design and Construction Fall 2014 Instructor: Hugh McGuire slides derived from Tevfik Bultan, Keith Cooper, and Linda Torczon Lecture-Module.
Chapter 10- Instruction set architectures
Chapter 8 ICS 412. Code Generation Final phase of a compiler construction. It generates executable code for a target machine. A compiler may instead generate.
Chapter 2.
 Suppose for a moment that you were asked to perform a task and were given the following list of instructions to perform:
Computer Architecture CSCE 350
CompSci A Peek at the Lower Levels  It is good to have a sense of what happens at the hardware level  Not required for this course  It may.
Intermediate Representation I High-Level to Low-Level IR Translation EECS 483 – Lecture 17 University of Michigan Monday, November 6, 2006.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1.
Programming Creating programs that run on your PC
Chapter 1: An Overview of Computers and Programming Languages J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program.
From: From:
The Analytical Engine Module 6 Program Translation.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
CSC 200 Spring 2006 Instructor: Matt Kayala. What is a “Computer”? We all use them for all kinds of tasks: –Games –Word Processing Good at repetitive.
CS 300 – Lecture 19 Intro to Computer Architecture / Assembly Language C Coding & The Simulator Caches.
Chapter 7 Low-Level Programming Languages. 2 Chapter Goals List the operations that a computer can perform Discuss the relationship between levels of.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Table 1. Software Hierarchy Levels.. Essential Tools An assembler is a program that converts source-code programs into a machine language (object file).
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
1 CHAPTER 4 LANGUAGE/SOFTWARE Hardware Hardware is the machine itself and its various individual equipment. It includes all mechanical, electronic.
9/29: Lecture Topics Memory –Addressing (naming) –Address space sizing Data transfer instructions –load/store on arrays on arrays with variable indices.
1 Chapter-01 Introduction to Computers and C++ Programming.
Topic 8: Data Transfer Instructions CSE 30: Computer Organization and Systems Programming Winter 2010 Prof. Ryan Kastner Dept. of Computer Science and.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
BIT Presentation 6. Contents GENERATIONS OF LANGUAGES COMPILERS AND INTERPRETERS VIRTUAL MACHINES OBJECT-ORIENTED PROGRAMMING SCRIPTING LANGUAGES.
Computer Architecture ECE 4801 Berk Sunar Erkay Savas.
CPS120: Introduction to Computer Science
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Cosc 2150: Computer Organization
Introduction to C++ Programming Language
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Computers Operating System Essentials. Operating Systems PROGRAM HARDWARE OPERATING SYSTEM.
CS 671 Compilers Prof. Kim Hazelwood Spring 2008.
1 Ethics of Computing MONT 113G, Spring 2012 Session 7 Computer Architecture The Internet.
1 Text Reference: Warford. 2 Computer Architecture: The design of those aspects of a computer which are visible to the programmer. Architecture Organization.
1 ICS 51 Introductory Computer Organization Fall 2009.
Chapter 7 Low-Level Programming Languages. 2 Chapter Goals List the operations that a computer can perform Discuss the relationship between levels of.
Chapter 7 Low-Level Programming Languages (slides modified by Erin Chambers)
Compilers and Interpreters. HARDWARE Machine LanguageAssembly Language High Level Language C++ Visual Basic JAVA Humans.
Lecture 2 Programming life cycle. computer piano analogy Piano + player - computer hardware Musical score/notes - software or program Composer - programmer.
 Computer Languages Computer Languages  Machine Language Machine Language  Assembly Language Assembly Language  High Level Language High Level Language.
Introduction to OOP CPS235: Introduction.
CompSci Today’s topics Machine Architecture The basic machine Basic programming Assembler programming Upcoming Language Translation Reading Great.
The Process From bare bones to finished product. The Steps Programming Debugging Performance Tuning Optimization.
Processor Fundamentals Assembly Language. Learning Objectives Show understanding of the relationship between assembly language and machine code, including.
Compilers and Interpreters
Chapter 1 An Overview of Computers and Programming Languages.
Assembly Variables: Registers Unlike HLL like C or Java, assembly cannot use variables – Why not? Keep Hardware Simple Assembly Operands are registers.
Programming Languages Salihu Ibrahim Dasuki (PhD) CSC102 INTRODUCTION TO COMPUTER SCIENCE.
F453 Module 8: Low Level Languages 8.1: Use of Computer Architecture.
©SoftMoore ConsultingSlide 1 Code Optimization. ©SoftMoore ConsultingSlide 2 Code Optimization Code generation techniques and transformations that result.
Compilers: History and Context COMP Outline Compilers and languages Compilers and architectures – parallelism – memory hierarchies Other uses.
central heating system
Microprocessor and Assembly Language
Optimization Code Optimization ©SoftMoore Consulting.
Introduction to Assembly Language
Computer Systems Summary
CSCE Fall 2013 Prof. Jennifer L. Welch.
Computer Science 210 Computer Organization
CSCE 121: Simple Computer Model Spring 2015
CSCE Fall 2012 Prof. Jennifer L. Welch.
A Level Computer Science Topic 5: Computer Architecture and Assembly
Review of Previous Lesson
Programming language translators
9/27: Lecture Topics Memory Data transfer instructions
Algoritmos y Programacion
Presentation transcript:

CPS Today’s topics Machine Architecture More Low-level Programming Upcoming Language Translation ( G.I. Chapter 9) Reading Great Ideas, Chapters 8

CPS Programming Loops  Now use new instructions to do the equivalent of while  We noted that syntax for if and while were same  Assembler code surprisingly similar for these two  Major addition is the update  Also need jump back to beginning of loop  Demonstrate with code equivalent to: { limit = 0; sum = 0; x = a.getInt(); while (limit < x) { sum = (sum + x); x = a.getInt(); } b.setInt(sum); }

CPS summer.as 0 copy ax, #C0 1 copy limit, ax 2 copy ax, #C0 3 copy sum, ax 4 in ax 5 copy x, ax 6 #L0 copy ax, limit 7 cmp ax, x 8 jnb #L1 9 copy ax, sum 10 add ax, x 11 copy sum, ax 12 in ax 13 copy x, ax 14 jmp #L0 15 #L1 copy ax, sum 16 out ax 40 limit 0 41 #C sum 0 43 x 0 Notes: #L0=6 #L1=15

CPS Another looping example  Calculate N! (N factorial) but do it with a loop this time  Code is equivalent to the following Java: { n = a.getInt(); i = 1; fact = 1; while (i < n+1) { fact = (fact * I); i = (i + 1); } b.setInt(fact); }

CPS fact.as 1 in ax 2 copy n, ax 3 copy ax, #C1 4 copy i, ax 5 copy fact, ax 6 #L0 copy ax, n 7 add ax, #C1 8 copy E0, ax 9 copy ax, i 10 cmp ax, E0 11 jnb #L1 12 copy ax, fact 13 mult ax, i 14 copy fact, ax 15 copy ax, i 16 add ax, #c1 17 copy i, ax 18 jmp #L0 19 #L1 copy ax, fact 20 out ax 21 halt 40 n 0 41 i 0 42 #C fact 0 44 E0 0 Notes: #L0=6 #L1=19

CPS Assembler Programming Notes  Note that previous program added the mul instruction  Most hardware has standard arithmetic support  Historically not the case  The best way to follow such a program is by tracing  See trace for fact.as program on web page  Writing assembler programs from scratch  Not that hard  Can get quite used to working at this level  Was done for efficiency reasons o Could do better than automatic translation (e.g., compiler)  However, remember 15 lines of code a day o This figure is language independent! o Compilers have gotten better than the average programmer

CPS Handling List or Arrays  Need extra hardware to do this well  Have registers that point to the list/array  Increment these registers to step through list/array  Can be done with our limited hardware  Involves having the program modify itself  Not hard to write  Errors in such self-modifying code very hard to find!  Additional Features Desired (minimal upgrade)  Need for more registers  Handling function/method calls o Need to “remember” where you came from o Jump to statement after that when done

CPS Modern Hardware  Memory Size  PC’s often have gigabyte of memory now  What does this do to the size of the instruction?  Lots of Registers  It is not unusual to have 32 accumulators  What does this do to the size of the instruction?  Memory Hierarchy 1. Registers 2. Cache Memory 3. Main Memory 4. Disk (virtual memory) 5. Offline storage (tapes, CDROMs, DVDs, etc.)