Hello world !!! ASCII representation of hello.c.

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

The Assembly Language Level
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
COSC 120 Computer Programming
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 2 – Hardware and Software Concepts Outline 2.1 Introduction 2.2Evolution of Hardware Devices.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
Introduction to Computer Systems Topics: Staff, text, and policies Lecture topics and assignments Class overview CS 213 S ’08 CS-213 Aleksandar Kuzmanovic.
Topic 1: Introduction to Computers and Programming
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
CPU Registers PC Arith Logic Unit Bus Interface I/O Bridge System bus Memory bus Main Memory USB Controller Graphics Adapter Disk Controller I/O Bus Mouse.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Topics Introduction Hardware and Software How Computers Store Data
CPS120: Introduction to Computer Science
The Computer Systems By : Prabir Nandi Computer Instructor KV Lumding.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
CMSC 313, F ‘09 1 Introduction to Assembly TopicsTopics –Assembly Overview –Instructions –Hardware.
University of Amsterdam Computer Systems – a guided tour Arnoud Visser 1 Computer Systems A guided Tour.
CPU Computer Hardware Organization (How does the computer look from inside?) Register file ALU PC System bus Memory bus Main memory Bus interface I/O bridge.
Introduction to Computer Systems Topics: Theme Four great realities of computer systems Chap 1 in “Computer Systems” book “The Class That Gives.
Intro to Computer Systems Summer 2014 COMP 2130 Introduction to Computer Systems Computing Science Thompson Rivers University.
Computer Systems Organization CS 1428 Foundations of Computer Science.
Implementation of a Stored Program Computer ITCS 3181 Logic and Computer Systems 2014 B. Wilkinson Slides2.ppt Modification date: Oct 16,
Programming With C.
5-1 Chapter 5 - Languages and the Machine Department of Information Technology, Radford University ITEC 352 Computer Organization Principles of Computer.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
Lesson 3 — How a Computer Processes Data Unit 1 — Computer Basics.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
5-1 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
Computer Architecture And Organization UNIT-II General System Architecture.
Computer Organization & Assembly Language © by DR. M. Amer.
Introduction to Compilers. Related Area Programming languages Machine architecture Language theory Algorithms Data structures Operating systems Software.
Computer Organization Instructors Course By: Lecturer: Shimaa Ibrahim Hassan TA: Eng: Moufeda Hussien Lecture: 9:45 Address:
Electronic Analog Computer Dr. Amin Danial Asham by.
1 CS503: Operating Systems Spring 2014 Part 0: Program Structure Dongyan Xu Department of Computer Science Purdue University.
Chapter 1 : Overview of Computer and Programming By Suraya Alias
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
Computer Systems. Bits Computers represent information as patterns of bits A bit (binary digit) is either 0 or 1 –binary  “two states” true and false,
CHAPTER 1: INTRODUCTION C++ Programming. CS 241 Course URL: Text Book: C++ How to Program, DETITEL & DEITEL, eighth Edition.
Introduction to OOP CPS235: Introduction.
Question What technology differentiates the different stages a computer had gone through from generation 1 to present?
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
1 Basic Processor Architecture. 2 Building Blocks of Processor Systems CPU.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
ECE 101 Exploring Electrical Engineering Chapter 9 Programming Development Environment Herbert G. Mayer, PSU Status 3/1/2016.
Operating Systems A Biswas, Dept. of Information Technology.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
F453 Module 8: Low Level Languages 8.1: Use of Computer Architecture.
Lecture 3 Translation.
Advanced Computer Systems
Computer Systems MTSU CSCI 3240 Spring 2016 Dr. Hyrum D. Carroll
Chapter 1: A Tour of Computer Systems
System Programming and administration
Computer Science I CSC 135.
Computer Organization & Compilation Process
Computers: Hardware and Software
Topics Introduction Hardware and Software How Computers Store Data
Introduction to Computer Systems
Introduction to Computer Systems
Hardware Organization
Computer Organization & Compilation Process
Presentation transcript:

Hello world !!!

ASCII representation of hello.c

Hello.c is translated to other form hello.c is a high-level C program - read and understood by human hello.c is translated by other programs into a sequence of low-level machine-language instructions. These instructions are then packaged in a form called an executable object program, and stored as a binary disk file.

Compilation system Lexer Separates the characters of a program’s source into tokens

Compilation system Parser Groups tokens into syntactically correct statements

Compilation system Intermediate code generator Converts statements into a stream of simple instructions

Compilation system Optimizer Improves code execution efficiency and memory requirements

Compilation system Code generator Produces the object file containing the machine-language

Linkers – Create a single executable unit – Integrate precompiled modules called libraries referenced by a program – Assign relative addresses to different program or data units – Resolve all external references between subprograms – Produce an integrated module called a load module – Linking can be performed at compile time, before loading, at load time or at runtime

Linking Object module Symbol table contains external names (functions or data made available to other programs) and external references (functions and data referenced from another module).

Linking Linking Process Symbol X and Y have the same relative address in their respective modules. The linker must modify these addresses.

Linking Symbol Resolution External reference to symbol C module 2 Is resolved with the external name C of Module 1. Pass I: Creates a symbol table, associates address with each reference. Pass II: Resolves the external references.

Loaders – Convert relative addresses to physical addresses – Place each instruction and data unit in main memory Techniques for loading a program into memory – Absolute loading Place program at the addresses specified by programmer or compiler (assuming addresses are available) – Relocatable loading Relocate the program’s addresses to correspond to its actual location in memory – Dynamic loading Load program modules upon first use

Compiling, Linking, and Loading

Compilation system

Compilation System Four phases: – Preprocessor – Compiler – Assembler – Linker

1. Preprocessing phase Modifies the original C program according to directives (begins with the # character). Example: #include 1. reads the contents of the system header file stdio.h and 2. insert it directly into the program text. hello.c  hello.i $ cpp hello.c

2. Compilation phase hello.i  hello.s hello.s which contains an assembly-language program. Each statement in an assembly-language program exactly describes one low-level machine-language instruction in a standard text form. $gcc –S hello.c

3. Assembly phase hello.s  hello.o The assembler (as) translates hello.s into machine- language instructions, packages them in a form known as a relocatable object program, and stores the result in the object file hello.o. The hello.o file is a binary file whose bytes encode machine language instructions rather than characters. $ gcc –c hello.s

4. Linking phase hello.o  hello Notice that our hello program calls the printf function, the printf function resides in a separate precompiled object file called printf.o, which must somehow be merged with our hello.o program. The linker (ld) handles this merging. The result is the hello file, which is an executable object file (or simply executable) that is ready to be loaded into memory and executed by the system.

Shell $./hello Hello world $

Hardware organization

Hardware Organization Buses: -a collection of electrical conduits called buses that carry bytes of information back and forth between the components. -designed to transfer fixed-sized chunks of bytes known as words. -The number of bytes in a word (the word size) is a fundamental system parameter that varies across systems. -Intel -4, Sparc – 8

Hardware Organization I/O Devices: Input/output (I/O) devices are the system’s connection to the external world. -a keyboard and -mouse for user input, -a display for user output, and -a disk drive (or simply disk) for long-term storage of data and programs.

Hardware Organization I/O Devices: - the hello executable program resides on the disk. - each I/O device is connected to the I/O bus by either a controller or an adapter. - the purpose of the controller is to transfer information back and forth between the I/O bus and an I/O device.

Hardware Organization Main Memory: The main memory is a temporary storage device that holds both a program and the data it manipulates while the processor is executing the program. Physically, main memory consists of a collection of Dynamic Random Access Memory (DRAM) chips. Logically, memory is organized as a linear array of bytes, each with its own unique address (array index) starting at zero.

Hardware Organization Main Memory: In general, each of the machine instructions that constitute a program can consist of a variable number of bytes. The sizes of data items that correspond to C program variables vary according to type. For example, on an Intel machine running Linux, data of type short requires two bytes, types int, float, and long four bytes, and type double eight bytes.

Processor -CPU is the engine that interprets (or executes) instructions stored in main memory. -At its core is a word-sized storage device (or register) called the program counter (PC). -PC points at (contains the address of) some machine-language instruction in main memory. -It reads the instruction from memory pointed at by the program counter (PC), -interprets the bits in the instruction, -performs some simple operation dictated by the instruction, and then -updates the PC to point to the next instruction

Processor A few simple operations: Load: Copy a byte or a word from main memory into a register, overwriting the previous contents of the register. Store: Copy the a byte or a word from a register to a location in main memory, overwriting the previous contents of that location. Update: Copy the contents of two registers to the ALU, which adds the two words together and stores the result in a register, overwriting the previous contents of that register. I/O Read: Copy a byte or a word from an I/O device into a register. I/O Write: Copy a byte or a word from a register to an I/O device. Jump: Extract a word from the instruction itself and copy that word into the program counter (PC), overwriting the previous value of the PC.

Running the Hello program 1. Shell reads hello 2. Stores in registers 3. Stores in main memory

Running the Hello program 1. Hit the enter key 2. Shell loads executable hello from disk to main memory (DMA)

Running the Hello program 1. Processor executes 2. “hello world” copied to registers 3. then to display device

Running the Hello program Disk drives are 10 million times slower than the main memory. Registers are 100 times faster than main memory. L1 and L2 caches are implemented using Static RAM.

Memory Hierarchy

Running the Hello program

Process and context switch

Virtual Memory Program code and data: Machine-level instructions, C variables from hello executable. Heap: Expands and contracts dynamically as malloc and free are called. Shared Libraries: Libraries shared by several processes. Stack: Used for function calls. Expands and contracts with a function call and retrun

A network is just another I/O device