Студенческая лаборатория МФТИ-Intel Assembler, Linker, MIPS Simulator Andrey Rodchenko 25.02.2013.

Slides:



Advertisements
Similar presentations
Hand-Held Devices and Embedded Systems Course Student: Tomás Sánchez López Student ID:
Advertisements

Programs in Memory Bryce Boe 2012/08/29 CS32, Summer 2012 B.
MIPS ISA-II: Procedure Calls & Program Assembly. (2) Module Outline Review ISA and understand instruction encodings Arithmetic and Logical Instructions.
MIPS ISA-II: Procedure Calls & Program Assembly. (2) Module Outline Review ISA and understand instruction encodings Arithmetic and Logical Instructions.
1 Lecture 4: Procedure Calls Today’s topics:  Procedure calls  Large constants  The compilation process Reminder: Assignment 1 is due on Thursday.
Wannabe Lecturer Alexandre Joly inst.eecs.berkeley.edu/~cs61c-te
Program Development Tools The GNU (GNU’s Not Unix) Toolchain The GNU toolchain has played a vital role in the development of the Linux kernel, BSD, and.
Lecture 8: MIPS Instruction Set
Assembler/Linker/Loader Mooly Sagiv html:// Chapter 4.3 J. Levine: Linkers & Loaders
Lecture 10: Linking and loading. Lecture 10 / Page 2AE4B33OSS 2011 Contents Linker vs. loader Linking the executable Libraries Loading executable ELF.
Linkers and Loaders 1 Linkers & Loaders – A Programmers Perspective.
CS 31003: Compilers ANIRUDDHA GUPTA 11CS10004 G2 CLASS DATE : 24/07/2013.
Computer Organization CS224 Fall 2012 Lesson 12. Synchronization  Two processors or threads sharing an area of memory l P1 writes, then P2 reads l Data.
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++
Lec 9Systems Architecture1 Systems Architecture Lecture 9: Assemblers, Linkers, and Loaders Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some.
Compilation (Semester A, 2013/14) Lecture 13: Assembler, Linker & Loader Noam Rinetzky Slides credit: Eli Bendersky, Mooly Sagiv & Sanjeev Setia.
System Programming Mr. M. V. Nikum (B.E.I.T). Introduction What is System? System is the collection of various components Ex:- College is a system What.
Assembler/Linker/Loader Mooly Sagiv html:// Chapter 4.3.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 33: Code Generation and Linking COMP 144 Programming Language Concepts Spring 2002.
The Assembly Language Level
UEE072HM Embedded Control Systems. Breaking down the compilation process Compilation is made up of a number of phases –Preprocessing –Compilation Can.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
ITEC 352 Lecture 11 ISA - CPU. ISA (2) Review Questions? HW 2 due on Friday ISA –Machine language –Buses –Memory.
Enabling the ARM Learning in INDIA ARM DEVELOPMENT TOOL SETUP.
MIPS coding. SPIM Some links can be found such as:
Chapter 1 Computer architecture Languages: machine, assembly, high
Objective At the conclusion of this chapter you will be able to:
Topic 2d High-Level languages and Systems Software
C OMPUTER A RCHITECTURE & O RGANIZATION Assemblers and Compilers Engr. Umbreen Sabir Computer Engineering Department, University of Engg. & Technology.
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.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 3 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /29/2013 Lecture 13: Compile-Link-Load Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE.
Introduction to Compilers. Related Area Programming languages Machine architecture Language theory Algorithms Data structures Operating systems Software.
CS412/413 Introduction to Compilers and Translators April 14, 1999 Lecture 29: Linking and loading.
1 CS503: Operating Systems Spring 2014 Part 0: Program Structure Dongyan Xu Department of Computer Science Purdue University.
Csci 136 Computer Architecture II – More on MIPS ISA Xiuzhen Cheng
CENG 311 Starting a Program. Review (1/2) °IEEE 754 Floating Point Standard: Kahan pack as much in as could get away with +/- infinity, Not-a-Number (Nan),
ISA's, Compilers, and Assembly
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
CSc 453 Linking and Loading
Linking I Topics Assembly and symbol resolution Static linking Systems I.
Program Translation and Execution I: Linking Sept. 29, 1998 Topics object files linkers class11.ppt Introduction to Computer Systems.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Hello world !!! ASCII representation of hello.c.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Object Files & Linking. Object Sections Compiled code store as object files – Linux : ELF : Extensible Linking Format – Windows : PE : Portable Execution.
Chapter 1 Introduction Samuel College of Computer Science & Technology Harbin Engineering University.
Program Execution in Linux David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Lecture 3 Translation.
Assemblers, linkers, loaders
Computer Architecture & Operations I
Introduction to Compiler Construction
Computer Science 210 Computer Organization
The University of Adelaide, School of Computer Science
Linking & Loading.
Program Execution in Linux
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Topic 2e High-Level languages and Systems Software
Assembler Design Options
Computer Science 210 Computer Organization
CALL & Pthread.
Computer Organization and Design Assembly & Compilation
Computer Architecture
Program Execution in Linux
Chapter 1 Computer architecture Languages: machine, assembly, high
10/6: Lecture Topics C Brainteaser More on Procedure Call
Program Assembly.
System Programming By Prof.Naveed Zishan.
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Presentation transcript:

Студенческая лаборатория МФТИ-Intel Assembler, Linker, MIPS Simulator Andrey Rodchenko

2 Assembly Language machine code HW dependent low-level programming language HW dependent high-level programming language mnemonic  opcode labels and symbols  addresses and constants macros  sequence of instructions data sections, assembler directives mnemonic  opcode labels and symbols  addresses and constants macros  sequence of instructions data sections, assembler directives advanced control structures functions declarations and invocations abstract data types OOP advanced control structures functions declarations and invocations abstract data types OOP encoded instruction set

3 Assemblers Variety And Usage multi-target / single target usage multi: GAS : i386, x86-64, PowerPC, ARC, ARM, VAX single: NASM : i386, x86-64 multi: GAS : i386, x86-64, PowerPC, ARC, ARM, VAX single: NASM : i386, x direct interaction with the hardware (device drivers, interrupt handlers, compilers, OSs) - specific instructions not implemented in a compiler - inline assembler in high level languages - self-modifying code - boot loaders, viruses, etc - direct interaction with the hardware (device drivers, interrupt handlers, compilers, OSs) - specific instructions not implemented in a compiler - inline assembler in high level languages - self-modifying code - boot loaders, viruses, etc

4 MIPS assembler basic structures directives labels comments instructions and pseudo-instructions.data - beginning of data segment.text- beginning of code segment.data - beginning of data segment.text- beginning of code segment main: # comment lw $t0, item

5 MIPS assembler syntax directives.align n.ascii str.asciiz str.byte b1,..., bn.half h1,..., hn.word w1,..., wn.data.extern sym size.float f1,..., fn.double d1,..., dn.globl sym.kdata.ktext.space n.text.align n.ascii str.asciiz str.byte b1,..., bn.half h1,..., hn.word w1,..., wn.data.extern sym size.float f1,..., fn.double d1,..., dn.globl sym.kdata.ktext.space n.text

6 Assembler phases 1 st pass – pseudo instructions replacement – symbol table creation – machine code generation and relocations creation 2 nd pass – complete address-related machine code using relocations sd $a0, 32($sp) =>sw $a0, 32($sp) =>sw $a1, 36($sp) LABELADDRESS lbl_u10x10 j lbl_u1=> 0x4: (lbl_u1_relocation:26b) j lbl_u1=> 0x4: ( ) ADDRLABELTYPE 0x4lbl_u1J displacement

7 Object File contains relocatable format machine code – header (descriptive and control information) – text segment (executable code) – data segment (static initialized data) – bss segment (uninitialized data) – relocation information – stack unwinding information – program symbols – debugging information different formats – ELF (executable and linkable fromat) – COFF (common object file format) – PE (portable executable)

8 Linking combines several objects files into single executable – symbol resolution – sections creation – relocations types of linking – static – dynamic linker script – controls how sections are merged and where they are placed

9 Symbols resolution symbol types – definitions (D) strong – several strong definitions are not allowed weak – may be overridden by other symbol definitions – Externals (U) for each object file (o) from left to right – if ‘o’ is not a library O = O U ‘o’  adds object file to set O U = U U ‘u’ – ‘d’ ∩ (U U ‘u’)  update undefined set U D = D U ‘d’  add ‘d ‘ to the D set checking that it has not been strongly defined – if ‘o’ is a library if (‘d’ ∩ U) = ‘e’ != 0 the same as above ‘o’ = ‘e’, ‘u’= 0, ‘d’ = ‘e’ when all arguments are passed if U == 0 than linking is successful int i = 1; int i;

10 Relocation And Dynamic Linking relocating sections and symbol definitions – all sections with the same name are merged relocating symbol references – all references are updated by addresses of objects in merged sections dynamic linker (loaded as shared library itself) – dynamic code must be position-independent – start-up code, mapping shared libraries to program’s address space – lazy linking can improve overall application performance if ‘potentially unnecessary’ references are numerous loads library code segment into memory demand-driven