Giter Club home page Giter Club logo

danieldotwav / 31-bit-virtual-storage-address-segment-extraction Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 7 KB

The program demonstrates how to extract and display the segment, page, and offset components of a 31-bit virtual address using bitwise operations in C++. It includes a dedicated function for printing these components in a formatted hexadecimal representation.

C++ 100.00%
bitwise-operations cpp memory-management systems-programming virtual-memory hexadecimal-formatting

31-bit-virtual-storage-address-segment-extraction's Introduction

Overview

This program is designed to demonstrate the extraction and formatting of virtual address components, such as segment, page, and offset, from a 31-bit address. It uses bitwise operations to isolate these components from a given virtual address and then prints them in a formatted manner.

Features

  • Extracts the segment, page, and offset from a 31-bit virtual address.
  • Utilizes bitwise operations for extraction:
    • Offset: Extracted using a bitwise AND operation with 0x00000fff.
    • Page: Extracted by first ANDing with 0x00ffffff and then shifting the result right by 12 bits.
    • Segment: Extracted by shifting the address right by 24 bits.
  • Displays the original address and its extracted components in a formatted output.

Code Structure

  • The program begins by defining the main function, which initializes a 31-bit address and variables for the segment, page, and offset.
  • It then extracts these components using bitwise operations.
  • The printFormattedResults function is called to print the original address and its components.
  • Finally, the extracted values are reset to 0, demonstrating the concept of variable reusability and function isolation.

Expected Output

Upon execution, the program will print the original 31-bit address and its extracted components (segment, page, and offset) in a hexadecimal format.

31-bit-virtual-storage-address-segment-extraction's People

Contributors

danieldotwav avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.