Motorola DSP56000 Family Optimizing C Compiler User’S Manual Motorola

Total Page:16

File Type:pdf, Size:1020Kb

Motorola DSP56000 Family Optimizing C Compiler User’S Manual Motorola Freescale Semiconductor, Inc. Motorola DSP56000 Family nc... Optimizing C Compiler User’s Manual, Release 6.3 DSP56KCCUM/D Document Rev. 2.0, 07/1999 Freescale Semiconductor, I For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. nc... Suite56, OnCe, and MFAX are trademarks of Motorola, Inc. Motorola reserves the right to make changes without further notice to any products herein. Motorola makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does Motorola assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. “Typical” parameters which may be provided in Motorola data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. All operating parameters, including “Typicals” must be validated for each customer application by customer’s technical experts. Motorola does not convey any license under its patent rights nor the rights of others. Motorola products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support life, or for any other application in Freescale Semiconductor, I which the failure of the Motorola product could create a situation where personal injury or death may occur. Should Buyer purchase or use Motorola products for any such unintended or unauthorized application, Buyer shall indemnify and hold Motorola and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that Motorola was negligent regarding the design or manufacture of the part. Motorola and are registered trademarks of Motorola, Inc. Motorola, Inc. is an Equal Opportunity/Affirmative Action Employer. All other tradenames, trademarks, and registered trademarks are the property of their respective owners. © Copyright Motorola, Inc., 1999. All rights reserved. For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Table of Contents Chapter 1 Introduction 1.1 Overview ....................................................... 1-1 1.2 Error Codes ..................................................... 1-4 1.3 Notation ........................................................ 1-4 1.4 Manual Organization .............................................. 1-5 Chapter 2 nc... Installation Guide 2.1 Introduction ..................................................... 2-1 2.2 Installation On An MS-DOS Machine (80386 or 80486) .................. 2-1 2.3 Standard Installation On A SUN ..................................... 2-3 2.4 Alternate Installation On A SUN ..................................... 2-4 2.5 Test Program .................................................... 2-4 Chapter 3 Control Program Options 3.1 Overview ....................................................... 3-1 3.2 G56k Command Line Options ....................................... 3-5 3.2.1 Preprocessor Phase Options ...................................... 3-7 3.2.2 Compile Phase Options ........................................ 3-20 3.3 Assemble Phase Options .......................................... 3-30 3.4 Link Phase Options .............................................. 3-31 Freescale Semiconductor, I Chapter 4 About g56k 4.1 Introduction ..................................................... 4-1 4.2 Identifiers ....................................................... 4-1 4.3 Predefined Preprocessor Macro Names ................................ 4-1 4.4 Data Types and Sizes .............................................. 4-1 4.4.1 Integral Data Types ............................................ 4-2 4.4.2 Floating-point Types ........................................... 4-3 4.4.2.1 Floating-point Format Description . ............................ 4-3 4.4.2.2 Comparison with IEEE STD 754-1985 Standard ................... 4-5 Motorola v For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. 4.4.3 Pointer Types . ............................................... 4-7 4.5 Register Usage ................................................... 4-8 4.6 Memory Usage................................................... 4-9 4.6.1 Activation Record ............................................ 4-10 4.6.2 Global/Static Data ............................................ 4-13 4.7 Compiler Naming Conventions ..................................... 4-13 4.8 Subroutine Call Sequence ......................................... 4-14 4.8.1 Caller Sequence .............................................. 4-14 4.8.2 Callee Sequence .............................................. 4-15 4.8.3 Return Sequence.............................................. 4-15 4.9 Software Support for Aritmetic Routines . ........................... 4-15 4.10 Run-time Safety . .............................................. 4-16 4.10.1 Memory Allocation Checks ..................................... 4-16 nc... 4.10.2 Run-time Stack Checks ........................................ 4-17 4.11 Optimization Techniques Implemented............................... 4-17 4.11.1 Register Promotion and Lifetime Analysis ......................... 4-17 4.11.2 Common Sub-expression Elimination . ........................... 4-17 4.11.3 Constant Propagation/Folding ................................... 4-18 4.11.4 Dead Code Elimination ........................................ 4-18 4.11.5 Tail Merging. .............................................. 4-18 4.11.6 Strength Reduction............................................ 4-19 4.11.7 Loop Invariant Code Motion .................................... 4-19 4.11.8 Hardware DO Loop Instruction .................................. 4-19 4.11.9 Loop Rotation. .............................................. 4-20 4.11.10 Jump Optimizations ........................................... 4-20 4.11.11 Instruction Combination........................................ 4-20 4.11.12 Leaf Routine Detection ........................................ 4-21 4.11.13 Function In-lining............................................. 4-21 4.11.14 Instruction Scheduling / Microcode Compaction .................... 4-21 Freescale Semiconductor, I Chapter 5 Mixing C and Assembly Language 5.1 Overview ....................................................... 5-1 5.2 In-line Assembly Code ............................................ 5-1 5.2.1 Instruction Template ........................................... 5-3 5.2.2 Output/Input Operands.......................................... 5-5 5.2.3 Explicit Register Saving......................................... 5-7 5.2.4 In-line Assembly Code Examples ................................. 5-8 5.2.5 Controlling Labels Generated by the Compiler ...................... 5-17 5.2.5.1 Calling Assembly Subroutines ................................ 5-17 vi Motorola DSP56000 Family Optimizing C Compiler User’s Manual Motorola For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. 5.2.5.2 Calling C Subroutines from Assembly Code ..................... 5-18 5.2.5.3 Referencing Assembly Global Variables from C .................. 5-20 5.2.5.4 Referencing Global C Variables from Assembly Language ......... 5-21 5.2.6 Specifying Registers for Variables................................ 5-22 5.2.7 Optimizer Effects on Code...................................... 5-22 5.3 #pragma Directive . .............................................. 5-22 5.4 Out-of-line Assembly Code........................................ 5-25 5.4.1 General Template ............................................. 5-26 5.4.1.1 Prologue . .............................................. 5-27 5.4.1.2 Save all registers........................................... 5-27 5.4.1.3 Main Program ............................................. 5-28 5.4.1.4 Restore all registers ........................................ 5-28 5.4.1.5 Epilogue . .............................................. 5-29 nc... 5.4.1.6 Out-of-line Assembly Code Example........................... 5-29 5.4.2 Global C and Static Variables in C ............................... 5-33 5.4.3 Using Run-time Stack for Local Data . ........................... 5-34 5.4.4 Calling C Routines ............................................ 5-35 5.4.5 Optimization Techniques ....................................... 5-36 Chapter 6 Software-Hardware Integration 6.1 Overview ....................................................... 6-1 6.2 Run-Time Environment Specification Files ............................ 6-1 6.3 crt0 File ........................................................ 6-2 6.4 Bootstrapping the C program........................................ 6-2 6.5 Memory Configuration and Management . ............................ 6-3 6.6 Interrupt Vectors . ............................................... 6-6 6.7 Miscellaneous Code............................................... 6-8 6.8 Signal File ...................................................... 6-9 Freescale Semiconductor, I 6.9 Signal() ....................................................... 6-10 6.9.1 Raise() ....................................................
Recommended publications
  • Theendokernel: Fast, Secure
    The Endokernel: Fast, Secure, and Programmable Subprocess Virtualization Bumjin Im Fangfei Yang Chia-Che Tsai Michael LeMay Rice University Rice University Texas A&M University Intel Labs Anjo Vahldiek-Oberwagner Nathan Dautenhahn Intel Labs Rice University Abstract Intra-Process Sandbox Multi-Process Commodity applications contain more and more combina- ld/st tions of interacting components (user, application, library, and Process Process Trusted Unsafe system) and exhibit increasingly diverse tradeoffs between iso- Unsafe ld/st lation, performance, and programmability. We argue that the Unsafe challenge of future runtime isolation is best met by embracing syscall()ld/st the multi-principle nature of applications, rethinking process Trusted Trusted read/ architecture for fast and extensible intra-process isolation. We IPC IPC write present, the Endokernel, a new process model and security Operating System architecture that nests an extensible monitor into the standard process for building efficient least-authority abstractions. The Endokernel introduces a new virtual machine abstraction for Figure 1: Problem: intra-process is bypassable because do- representing subprocess authority, which is enforced by an main is opaque to OS, sandbox limits functionality, and inter- efficient self-isolating monitor that maps the abstraction to process is slow and costly to apply. Red indicates limitations. system level objects (processes, threads, files, and signals). We show how the Endokernel Architecture can be used to develop enforces subprocess access control to memory and CPU specialized separation abstractions using an exokernel-like state [10, 17, 24, 25, 75].Unfortunately, these approaches only organization to provide virtual privilege rings, which we use virtualize minimal parts of the CPU and neglect tying their to reorganize and secure NGINX.
    [Show full text]
  • Memory Layout and Access Chapter Four
    Memory Layout and Access Chapter Four Chapter One discussed the basic format for data in memory. Chapter Three covered how a computer system physically organizes that data. This chapter discusses how the 80x86 CPUs access data in memory. 4.0 Chapter Overview This chapter forms an important bridge between sections one and two (Machine Organization and Basic Assembly Language, respectively). From the point of view of machine organization, this chapter discusses memory addressing, memory organization, CPU addressing modes, and data representation in memory. From the assembly language programming point of view, this chapter discusses the 80x86 register sets, the 80x86 mem- ory addressing modes, and composite data types. This is a pivotal chapter. If you do not understand the material in this chapter, you will have difficulty understanding the chap- ters that follow. Therefore, you should study this chapter carefully before proceeding. This chapter begins by discussing the registers on the 80x86 processors. These proces- sors provide a set of general purpose registers, segment registers, and some special pur- pose registers. Certain members of the family provide additional registers, although typical application do not use them. After presenting the registers, this chapter describes memory organization and seg- mentation on the 80x86. Segmentation is a difficult concept to many beginning 80x86 assembly language programmers. Indeed, this text tends to avoid using segmented addressing throughout the introductory chapters. Nevertheless, segmentation is a power- ful concept that you must become comfortable with if you intend to write non-trivial 80x86 programs. 80x86 memory addressing modes are, perhaps, the most important topic in this chap- ter.
    [Show full text]
  • Strengthening Diversification Defenses by Means of a Non-Readable Code
    1 Strengthening diversification defenses by means of a non-readable code segment Sebastian Österlund Department of Computer Science Vrije Universiteit, Amsterdam, Netherlands Supervised By: H. Bos & C. Giuffrida Abstract—In this paper we present a new defense against Just- hardware segmentation, this approach should theoretically have In-Time return-oriented-programming attacks. By making pro- no run-time performance overhead for Intel x86 architecture, gram code non-readable, the assembly of Just-In-Time gadgets by once it has been set up. Both position dependent executables scanning the memory is effectively blocked. Using segmentation and position independent executables are covered. Furthermore on Intel x86 hardware, the implementation of execute-only code an approach to implement a similar defense on x86_64 using can be achieved. We discuss two different ways of implementing the new MPX [7] instructions is presented. The defense such a defense for 32-bit Intel architecture: one for position dependent executables, and one for position independent executa- mechanism we present in this paper is of interest, mainly, bles. The first implementation works by splitting the address- for use in security of network connected applications (such space into two mirrored segments. The second implementation as servers or web-browsers), since these applications are often creates an execute-only memory-section at the top of the address- the main targets of remote code execution exploits. space, making it possible to still use the whole address-space. By relying on hardware segmentation the run-time performance II. RETURN-ORIENTED-PROGRAMMING ATTACKS overhead of these defenses is minimal. Remote code execution by means of buffer overflows has Keywords—ROP, segmentation, XnR, buffer overflow, memory been a problem for a long time.
    [Show full text]
  • Assembly Language
    Chapter 2 Instructions: Assembly Language Reading: The corresponding chapter in the 2nd edition is Chapter 3, in the 3rd edition it is Chapter 2 and Appendix A and in the 4th edition it is Chapter 2 and Appendix B. 2.1 Instructions and Instruction set The language to command a computer architecture is comprised of instructions and the vocabulary of that language is called the instruction set. The only way computers can rep- resent information is based on high or low electric signals, i.e., transistors (electric switches) being turned on or off. Being limited to those 2 alternatives, we represent information in com- puters using bits (binary digits), which can have one of two values: 0 or 1. So, instructions will be stored in and read by computers as sequences of bits. This is called machine language. To make sure we don't need to read and write programs using bits, every instruction will also have a "natural language" equivalent, called the assembly language notation. For example, in C, we can use the expression c = a + b; or, in assembly language, we can use add c; a; b and these instructions will be represented by a sequence of bits 000000 010001001 in the computer. Groups of bits are named as follows: ··· bit 0 or 1 byte 8 bits half word 16 bits word 32 bits double word 64 bits Since every bit can only be 0 or 1, with a group of n bits, we can generate 2n different combinations of bits. For example, we can make 28 combinations with one byte (8 bits), 216 with one half word (16 bits), and 232 with one word (32 bits).
    [Show full text]
  • Outline Executable/Object File Formats Brief History of Binary File Formats
    Outline CSci 5980/8980 ELF basics Manual and Automated Binary Reverse Engineering Slides 5: The ELF Binary File Format Stephen McCamant Static and dynamic linking University of Minnesota Executable/object file formats Brief history of binary file formats (Unix) Modern systems usually use a common format for Early Unix had a simple a.out format relocatable object files during compilation and final Lasted until early days of free Linux/BSD, now obsolete executables AT&T’s second try was named COFF Mostly binary data representing code and data Still limited, but widely adopted with changes Plus metadata allowing the data to be linked and AT&T’s third try was ELF, now used in almost all Unix loaded systems Brief history of binary file formats (non-Unix) Compile-time and run-time Early DOS and Windows had several limited formats Some file features are used during compilation Since the 32-bit era, Windows uses the PE (Portable Typically first created by assembler, then used/modified Executable) format by the linker Partially derived from COFF Other features are used when the program runs OS X era Apple (including iOS, etc) uses a format By the OS when the program starts named Mach-O And now also by runtime linking First developed for the Mach microkernel used on the NeXT Static and dynamic/shared linking ELF Traditional “static” linking happens all at compile time Executable (or Extensible) and Linking (or Linkable) Libraries become indistinguishable from the rest of the Format program First appeared in System V Release 4 Unix, c. 1989 For efficiency and flexibility, it is now more common to postpone library linking until runtime Linux switched to ELF c.
    [Show full text]
  • Code Optimization & Linking
    Code optimization & linking Jinyang Li Slides adapted from Bryant and O’Hallaron What we’ve learnt so far • C program x86 instructions – Memory layout – control flows: sequential, jumps, call/ret • Buffer overflow – Hijack control flow by overwriting a return address – Execute code intended by the attacker Today’s lesson plan • Code optimization (done by the compiler) – common optimization techniques – what prevents optimization • C linker Optimizing Compilers • Goal: generate efficient, correct machine code – allocate registers, choose instructions, ... Generated code must have the same behavior as the original C program under all scenarios gcc’s optimization levels: -O1, -O2, -O3 Common optimization: code motion • Move computation outside loop if possible. void set_arr(long *arr, long n) { for (long i = 0; i < n; i++) arr[i] = n*n; done inside loop } testq %rsi, %rsi # Test n jle .L1 # If 0, goto done movq %rsi, %rdx leaq (%rdi, %rsi, 8), %rax # rax = &arr[n] void set_arr(long *arr, long n) # rdx = n*n imulq %rsi, %rdx { .L3: long t = n*n; movq %rdx, (%rdi) # (*p) =rdx for (long i = 0; i < n; i++) addq $8, %rdi # p++; arr[i] = t; cmpq %rax, %rdi # cmp &arr[n]) vs. p } jne .L3 # if !=, goto Loop .L3 Equivalent C code .L1: ret Common Optimization: use simpler instructions • Replace costly operation with simpler one – Shift, add instead of multiply or divide 16*x --> x << 4 – Recognize sequence of products long ni = 0; for (long i=0; i<n; i++ { for (long i = 0; i < n; i++) arr[i] = n*i; { } arr[i] = ni; ni += n; } assembly not shown this
    [Show full text]
  • X86 Instruction Set Architecture
    x86 Instruction Set Architecture Comprehensive 32/64-bit Coverage First Edition Also by Tom Shanley HEAVEN’S FAVORITE —A Novel of Genghis Khan— Book 1, ASCENT: THE RISE OF CHINGGIS KHAN Book 2, DOMINION: DAWN OF THE MONGOL EMPIRE MINDSHARE TECHNICAL TRAINING Please visit www.mindshare.com for a complete description of Mind- Share’s technical offerings: • Books • eBooks • eLearning modules • Public courses • On-site course • On-line courses Intel Core 2 Processor (Penryn) Intel Nehalem Processor Intel Atom Processor AMD Opteron Processor (Barcelona) Intel 32/64-bit x86 Software Architecture AMD 32/64-bit x86 Software Architecture x86 Assembly Language Programming Protected Mode Programming PC Virtualization IO Virtualization (IOV) Computer Architectures with Intel Chipsets Intel QuickPath Interconnect (QPI) PCI Express 2.0 USB 2.0 USB 3.0 Embedded USB 2.0 Workshop PCI PCI-X Modern DRAM Architecture SAS Serial ATA High Speed Design EMI / EMC Bluetooth Wireless Product Development SMT Manufacturing SMT Testing x86 Instruction Set Architecture Comprehensive 32/64-bit Coverage First Edition MINDSHARE, INC. TOM SHANLEY MindShare Press Colorado Springs, USA Refer to “Trademarks” on page 5 for trademark information. The author and publisher have taken care in preparation of this book but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connec- tion with or arising out of the use of the information or programs contained herein. ISBN: 0-9770878-5-3 Copyright © 2009 by MindShare, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopy- ing, recording, or otherwise, without the prior written permission of the publisher.
    [Show full text]
  • Sharing of Data and Code in Main Memory
    “runall” 2002/9/24 page 274 CHAPTER 9 Sharing of Data and Code in Main Memory 9.1 SINGLE-COPY SHARING 9.2 SHARING IN SYSTEMS WITHOUT VIRTUAL MEMORY 9.3 SHARING IN PAGING SYSTEMS 9.4 SHARING IN SEGMENTED SYSTEMS 9.5 PRINCIPLES OF DISTRIBUTED SHARED MEMORY 9.6 IMPLEMENTATIONS OF DISTRIBUTED SHARED MEMORY The engineering of large software systems is greatly simplified if individual modules can be constructed separately and later linked together. This also permits the reuse of modules developed previously, and the use of libraries and other modules built by others, thus reducing the total software development cost. To facilitate the necessary cooperation, a flexible linking mechanism should be provided that does not require individual modules to be recompiled each time they are being included in a user address space. Important additional benefits are obtained if the same copy of a module can be linked into more than one address space at the same time, essentially sharing a single copy of the module in main memory among different processes. In addition to sharing code, many concurrent programs cooperate and must share common data areas to exchange partial results or other forms of information with each other. The first part of the chapter presents the main techniques for the sharing of code and data in centralized architectures. Because the shared memory model has proven to be such a convenient abstraction, it has also been implemented on top of distributed systems. In the last sections of the chapter, we introduce the basic ideas underlying distributed shared memory. 9.1 SINGLE-COPY SHARING Our general focus is on sharing a single copy of code or data in memory.
    [Show full text]
  • UNIX Systems Programming by Robbins & Robbins
    • Table of Contents Unix™ Systems Programming: Communication, Concurrency, and Threads By Kay A. Robbins, Steven Robbins Publisher: Prentice Hall PTR Pub Date: June 17, 2003 ISBN: 0-13-042411-0 Pages: 912 This completely updated classic (originally titled Practical UNIX Programming) demonstrates how to design complex software to get the most from the UNIX operating system. UNIX Systems Programming provides a clear and easy-to-understand introduction tothe essentials of UNIX programming. Starting with short code snippetsthat illustrate how to use system calls, Robbins and Robbins movequickly to hands-on projects that help readers expand their skill levels. This practical guide thoroughly explores communication, concurrency,and multithreading. Known for its comprehensive and lucid explanations of complicated topics such as signals and concurrency, the book features practical examples, exercises, reusable code, and simplified libraries for use in network communication applications. A self-contained reference that relies on the latest UNIX standards,UNIX Systems Programming provides thorough coverage of files, signals,semaphores, POSIX threads, and client-server communication. Thisedition features all-new chapters on the Web, UDP, and server performance. The sample material has been tested extensively in the classroom. • Table of Contents Unix™ Systems Programming: Communication, Concurrency, and Threads By Kay A. Robbins, Steven Robbins Publisher: Prentice Hall PTR Pub Date: June 17, 2003 ISBN: 0-13-042411-0 Pages: 912 Copyright About the Web Site Preface Acknowledgments Part I: Fundamentals Chapter 1. Technology's Impact on Programs Section 1.1. Terminology of Change Section 1.2. Time and Speed Section 1.3. Multiprogramming and Time Sharing Section 1.4. Concurrency at the Applications Level Section 1.5.
    [Show full text]
  • Download It to a Target System Where It Is Executed As the Local OS
    ENABLING USER-MODE PROCESSES IN THE TARGET OS FOR CSC 159 OPERATING SYSTEM PRAGMATICS A Project Presented to the faculty of the Department of Computer Science California State University, Sacramento Submitted in partial satisfaction of the requirements for the degree of MASTER OF SCIENCE in Computer Science by Michael Bradley Colson SPRING 2018 © 2018 Michael Bradley Colson ALL RIGHTS RESERVED ii ENABLING USER-MODE PROCESSES IN THE TARGET OS FOR CSC 159 OPERATING SYSTEM PRAGMATICS A Project by Michael Bradley Colson Approved by: __________________________________, Committee Chair Dr. Weide Chang __________________________________, Second Reader Dr. Yuan Cheng ____________________________ Date iii Student: Michael Bradley Colson I certify that this student has met the requirements for format contained in the University format manual, and that this project is suitable for shelving in the Library and credit is to be awarded for the project. __________________________, Graduate Coordinator ___________________ Dr. Jinsong Ouyang Date Department of Computer Science iv Abstract of ENABLING USER-MODE PROCESSES IN THE TARGET OS FOR CSC 159 OPERATING SYSTEM PRAGMATICS by Michael Bradley Colson One of the main responsibilities of an Operating System (OS) is to ensure system stability and security. Most OSes utilize mechanisms built into the CPU hardware to prevent user-mode processes from altering the state of the system or accessing protected spaces and hardware I/O ports. A process should only read from or write to memory addresses in its address space. In order to accomplish the above, the CPU is typically designed to operate in two or more modes with different privilege levels. The OS typically runs in the mode with highest privilege level, which enables it to execute any instruction and gives it access to all the memory in the system.
    [Show full text]
  • Malloc() + Free())? How Much Memory Can Be Used in a Program? What Are Segmentation and Segmentation Fault?
    Operating Systems Associate Prof. Yongkun Li 中科大-计算机学院 副教授 http://staff.ustc.edu.cn/~ykli Ch7 Memory Management from a Programmer’s Perspective 1 Why we need memory management • The running program code requires memory – Because the CPU needs to fetch the instructions from the memory for execution • We must keep several processes in memory – Improve both CPU utilization and responsiveness – Multiprogramming It is required to efficiently manage the memory 2 Topics in Ch7 From a programmer’s perspective: user-space memory management What is the address space of a process? How are the program code and data stored in memory? How to allocate/free memory (malloc() + free())? How much memory can be used in a program? What are segmentation and segmentation fault? From the kernel’s perspective: How to manage the memory What is virtual memory? How to realize address mapping (paging)? How to support very large programs (demand paging)? How to do page replacement? What is TLB? What is memory-mapped file? 3 Part 1: User-space memory Local variable Do you remember this? - Content of a process (in user-space memory) Dynamically-allocated memory How does each part use the memory? - From a programmer’s perspective Global variable Let’s forget about the kernel for a moment. We are going to explore the Code + constants user-space memory first. Process 4 User-space memory management - Address space; - Code & constants; - Data segment; - Stack; - Heap; - Segmentation fault; 5 Address space How does a programmer look at the memory space? Stack - Local variables
    [Show full text]
  • CMPE - 310 Lecture 19 – Paging and Segmentation Outline
    CMPE - 310 Lecture 19 – Paging And Segmentation Outline Concepts in Paging and Segmentation Privilege levels Call gates Adapted from slides prepared by Dr. Chintan Patel for CMPE 310 2 Memory Addressing Memory Paging: Available in the 80386 and up. Allows a linear address (virtual address) of a program to be located in any portion of physical memory. The paging unit is controlled by the microprocessors control registers: 31 12 11 0 CR4(Pentium and up) DE PVI PSE TSD MCE VME Page Directory Base Address CR3 PCD PWT CR2 Most recent Page Faulting Linear Address CR1 Reserved CR0 ET PE TS PG AM WP NW NE MP CD EM Adapted from slides prepared by Dr. Chintan Patel for CMPE 310 3 Memory Addressing Memory Paging: The paging system operates in both real and protected mode. It is enabled by setting the PG bit to 1 (left most bit in CR0). (If set to 0, linear addresses are physical addresses). CR3 contains the page directory 'physical' base address. The value in this register is one of the few 'physical' addresses you will ever refer to in a running system. The page directory can reside at any 4K boundary since the low order 12 bits of the address are set to zero. The page directory contains 1024 directory entries of 4 bytes each. Each page directory entry addresses a page table that contains up to 1024 entries. Adapted from slides prepared by Dr. Chintan Patel for CMPE 310 4 Memory Addressing Memory Paging: The virtual address is broken into three pieces: • Directory: Each page directory addresses a 4MB section of main mem.
    [Show full text]