Dr. Chuck Cartledge. 7 Nov. 2017

Similar documents
Dr. Chuck Cartledge. 15 July 2015

Dr. Chuck Cartledge. 3 June 2015

Dr. Chuck Cartledge. 24 Oct. 2017

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program

Extra-credit QUIZ Pipelining -due next time-

QUIZ. What are 3 differences between C and C++ const variables?

Getting started with C++ (Part 2)

These are notes for the third lecture; if statements and loops.

Syntax and Variables

Sixth lecture; classes, objects, reference operator.

Maciej Sobieraj. Lecture 1

Test Results Schedule Miscellanea Chap. 10 Break Hands on Q & A Conclusion References Files

Test Results Schedule Miscellanea Control Structs. Add l Oper s Break Hands on Q & A Conclusion References Files

Lecture 8: Structs & File I/O

EEE145 Computer Programming

Low-level software. Components Circuits Gates Transistors

QUIZ. Name all the 4 parts of the fetch-execute cycle.

ME240 Computation for Mechanical Engineering. Lecture 4. C++ Data Types

QUIZ. Name all the 4 parts of the fetch-execute cycle.

2SKILL. Variables Lesson 6. Remembering numbers (and other stuff)...

C++ For Science and Engineering Lecture 15

PIC 10A Pointers, Arrays, and Dynamic Memory Allocation. Ernest Ryu UCLA Mathematics

Non-numeric types, boolean types, arithmetic. operators. Comp Sci 1570 Introduction to C++ Non-numeric types. const. Reserved words.

C++ Support Classes (Data and Variables)

G52CPP C++ Programming Lecture 13

Enums. In this article from my free Java 8 course, I will talk about the enum. Enums are constant values that can never be changed.

CS1102: What is a Programming Language?

Lab 5: SDC Virtual Machine

PIC 10A Objects/Classes

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

Monday, August 28, 2017

QUIZ. Source:

C++ Lecture 5 Arrays. CSci 588: Data Structures, Algorithms and Software Design.

assembler Machine Code Object Files linker Executable File

Week 3 Lecture 2. Types Constants and Variables

C++ for Java Programmers

CS61C : Machine Structures

6. Pointers, Structs, and Arrays. March 14 & 15, 2011

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

Functions, Pointers, and the Basics of C++ Classes

NAMESPACES IN C++ You can refer the Programming with ANSI C++ by Bhushan Trivedi for Understanding Namespaces Better(Chapter 14)

COSC 2P95. Procedural Abstraction. Week 3. Brock University. Brock University (Week 3) Procedural Abstraction 1 / 26

Looping and Counting. Lecture 3 Hartmut Kaiser hkaiser/fall_2012/csc1254.html

Pointers, Arrays and Parameters

CS 61C, Fall, 2005, Midterm 1, Garcia Question 1: For those about to test, we salute you (11 pts, 20 min.)

switch case Logic Syntax Basics Functionality Rules Nested switch switch case Comp Sci 1570 Introduction to C++

CS 61c: Great Ideas in Computer Architecture

Classes Classes 2 / 36

5. Applicative Programming. 1. Juli 2011

Procedures, Parameters, Values and Variables. Steven R. Bagley

Consider the above code. This code compiles and runs, but has an error. Can you tell what the error is?

COMP3221: Microprocessors and. and Embedded Systems. Instruction Set Architecture (ISA) What makes an ISA? #1: Memory Models. What makes an ISA?

6. Pointers, Structs, and Arrays. 1. Juli 2011

Programming in C++ 4. The lexical basis of C++

My First Command-Line Program

Wednesday, September 13, Chapter 4

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.

QUIZ. What is wrong with this code that uses default arguments?

4.7 Approximate Integration

Variables and Constants

Structured Programming Using C++ Lecture 2 : Introduction to the C++ Language. Dr. Amal Khalifa. Lecture Contents:

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

Lecture (01) Getting started. Dr. Ahmed ElShafee

CS61C : Machine Structures

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

Name: Login: cs61c- Decimal Ternary 5 12 three three

Ch. 10: Name Control

What you need to know about the stored program model

How to import text files to Microsoft Excel 2016:

MySQL: an application

C++ Data Types. 1 Simple C++ Data Types 2. 3 Numeric Types Integers (whole numbers) Decimal Numbers... 5

6.096 Introduction to C++ January (IAP) 2009

Principles of Programming Pointers, Dynamic Memory Allocation, Character Arrays, and Buffer Overruns

6.096 Introduction to C++

Dr. Chuck Cartledge. 4 Mar. 2015

CS 61c: Great Ideas in Computer Architecture

Object-Oriented Programming

Final Project: LC-3 Simulator

Coding Workshop. Learning to Program with an Arduino. Lecture Notes. Programming Introduction Values Assignment Arithmetic.

Memory Management II

Programming with C++ Language

6.S096 Lecture 2 Subtleties of C

CS61C : Machine Structures

C Language, Token, Keywords, Constant, variable

Lab # 02. Basic Elements of C++ _ Part1

Computer Programming. Basic Control Flow - Loops. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons

Ch. 11: References & the Copy-Constructor. - continued -

G52CPP C++ Programming Lecture 8. Dr Jason Atkin

CMSC445 Compiler design Blaheta. Project 2: Lexer. Due: 15 February 2012

Syntax of LC-3 assembly: Language elements. Instructions

CS106X Handout 33 Winter 2018 February 28 th, 2018 Section Handout

Looping and Counting. Lecture 3. Hartmut Kaiser hkaiser/fall_2011/csc1254.html

Parallel Programming: Background Information

Parallel Programming: Background Information

Comp 11 Lectures. Mike Shah. June 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures June 26, / 57

The story so far. Elements of Programming Languages. While-programs. Mutable vs. immutable

Lecture 2 Tao Wang 1

2 nd Week Lecture Notes

CMSC202 Computer Science II for Majors

Numerical Conversions Intro to Strings in C/C++ CS 16: Solving Problems with Computers I Lecture #8

Transcription:

5.2 5.3 5.4 Chap. 5 review Conclusion References CSC-205 Computer Organization Lecture #012 Sections 5.2 through 5.4, Machine instructions and assemblers Dr. Chuck Cartledge 7 Nov. 2017 1/17

Table of contents (1 of 1) 1 5.2 Irritating things about direct addressing 2 5.3 How symbols make life easier. 3 5.4 Translating from Level HOL6 4 Chap. 5 review Assembly language 5 Conclusion 6 References 2/17

Irritating things about direct addressing A simple program. You (the human) have to know the code (hex) for everything. 3/17

Irritating things about direct addressing When do you stop printing a string? What is difference between C++ string and char[] when printing?? 4/17

Irritating things about direct addressing Terrific quote In all these examples, the instruction simply grinds through the von Neumann execution cycle. You must always remember that the translation process is different from the execution process and that translation happens before execution. After translation, when the instructions are executing, the origin of the bits is irrelevant. The only thing that matters is what the bits are, not where they came from during the translation phase. J. Stanley Warford [3] J. Stanley Warford 5/17

How symbols make life easier. Let the software worry about where things are. 6/17

How symbols make life easier. A truly silly program. The symbol this points to memory location 0000 Memory location 0000 contains the opcode for DEC0 with OprnSpec this and to treat the contents as decimal von Neumann starts at address 0000 Loads the instruction Executes the instruction (outputs the contents at memory location 0000) Stops The opcode is interpreted as data (as per the opcode) and output. Seems silly, but von Neumann doesn t distinguish between program and data. Powerful stuff. 7/17

Translating from Level HOL6 We ve bumped into the idea of compilers (née, translators) before. Compilers convert HOL directly into machine code (ones and zeros), or Compiler convert HOL in assembler level code that another program has to translate into machine code. A compiler is a program (albeit, a complex one). Image from [3]. 8/17

Translating from Level HOL6 Relative sizes of different compilers. Files from Ubuntu 14.04.2 g++ g++-4.8 775Kbytes fortran 14785Kbytes javac 7KBytes, an ELF file Executable and Linkable Format (ELF) tells computer where to get information and where to put it memory 9/17

Translating from Level HOL6 Some HOL statements get translated Statements that actually do something get translated: The cout statement The return statement return inside the main() becomes STOP only in the Pep/8 compiler. What about the other statements?? 10/17

Translating from Level HOL6 Some HOL statements don t get translated The #include <> is a compiler directive on where to get additional information The using namespace... is to make typing easier for the human The semicolons terminate a logical line All HOLs have the same types of problems: scoping, brevity, line endings, line beginings, etc. 11/17

Translating from Level HOL6 Variables are just named places in memory About variables: At the ISA level, they live in memory At the ASL level, they are labels for memory location At the HOL level, they exist There are generally three types of variables: Global available to everyone and remember things Local available to the current context and then lost Static available to the current context and then remembered Other available to lower context and then lost 12/17

Translating from Level HOL6 How to resolve structures and classes? Remember at the lowest level, there are only addresses. typedef takes a known type and makes a new type enum creates an int, limits the values it can assume, and gives those values names struct names a collection of contiguous memory locations We can now create an array of contiguous memory locations of the same type. The compiler keeps track of variable names, types, and locations in memory. A class is a block of contiguous memory locations that has addresses of functions inside of it. 13/17

Translating from Level HOL6 A special type of variable that doesn t vary. C++ uses the compiler directive const to tell the compiler to cause an error when the constant thing is modified. Pep/8 uses the.equate directive Usually you ll use immutable variables for safety and documentation purposes. 14/17

Assembly language Moving up the food chain. Relationship between assembly and machine code, Pages 194 and 195, Pep/8 pseudo operators, Immediate addressing and trap instructions, Concept of symbols, von Neumann, von Neumann, von Neumann, Translating from HOL6 Image from [1]. 15/17

5.2 5.3 5.4 Chap. 5 review Conclusion References What have we covered? Immediate addressing and the trap instructions Symbols Translating from level HOL6 Chapter review Next period: Test, Section 6.1, Assemblers and high order languages 16/17

References (1 of 1) [1] Wikipedia Staff, Adventures of Huckleberry Finn (1885)/Chapter 5, https://en.wikisource.org/wiki/adventures_of_ Huckleberry_Finn_(1885)/Chapter_5, 2016. [2] Xilin Staff, Building applications in sdk, http: //www.xilinx.com/support/documentation/sw_manuals/ xilinx12_2/sdk_doc/concepts/sdk_c_build.htm, 2015. [3] J. Stanley Warford, Computer Systems, Jones & Bartlett Publishers, 2010. 17/17