Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need some help with these functions: #include PtrStuff.h // Add include directives here, as needed /** Uses pointer-based logic to access a specified portion of

Need some help with these functions:

#include "PtrStuff.h" // Add include directives here, as needed /** Uses pointer-based logic to access a specified portion of a region of * memory and prints the corresponding bytes to a supplied file stream. * * Pre: Out is open on a file * baseAddr points to the first byte of the memory region * Offset is the location, relative to baseAddr, of the first * relevant byte of the memory region * nToPrint is the number of bytes to be printed */ void showBytesAtOffset(FILE* Out, const uint8_t* const baseAddr, uint16_t Offset, uint8_t nBytes) { fprintf(Out, " "); } /** Uses pointer-based logic to display a specified portion of a region of * memory, using pointer typecasts to control the number of bytes that are * displayed, and the way those byte are interpreted. * * Pre: Out is open on a file * baseAddr points to the first byte of the memory region * Offset is the location, relative to baseAddr, of the first * relevant byte of the memory region * Sign indicates whether the bytes are to be interpreted as representing a * signed or unsigned integer * * nByte is the number of bytes to be considered. You may assume nByte * will be 1, 2, 4, or 8, corresponding to the sizes of the integer * types in . * * Restrictions: * You must use only pointer syntax in accessing the data. */ void showValueAtOffset(FILE* Out, const uint8_t* const baseAddr, uint32_t Offset, Sign Sgn, uint8_t nBytes) { fprintf(Out, " "); } /** Uses pointer-based logic to search a specified portion of a region of * memory for occurrences of a specified one-byte value. * * Pre: Out is open on a file * baseAddr points to the first byte of the memory region * Length is number of bytes in the memory region * Byte is the value to be found * Restrictions: * You must use only pointer syntax in accessing the data. */ void findOccurrencesOfByte(FILE* Out, const uint8_t* const baseAddr, uint32_t Length, uint8_t Byte) { fprintf(Out, " "); } /** Uses pointer-based logic to copy a specified portion of a region of * memory to replace the bytes in another portion of that memory region. * * Pre: Out is open on a file * baseAddr points to the first byte of the memory region * Source and Destination point to the first bytes of two sections * of the memory region that contains Length bytes * The regions pointed to by Source and Destination do not overlap * Post: Length bytes, beginning at *Source, have been copied to Length * consecutive locations, beginning at *Destination * Restrictions: * You must use only pointer syntax in accessing the data. */ void copyBlock(FILE* Out, const uint8_t* const baseAddr, uint32_t Source, uint32_t Destination, uint32_t Length) { fprintf(Out, " "); } /** Uses pointer-based logic to modify the contents of a specified portion * of a region of memory, by bitwise blending with bytes of another * portion of that memory region. * * Pre: Out is open on a file * baseAddr points to the first byte of the memory region * First and Second point to the first bytes of two sections * of the memory region that each contain Length bytes * The regions pointed to by First and Second do not overlap * Post: Length bytes, beginning at *Second, have been blended with Length * bytes, beginning at *First; the blending is accomplished as * follows: the k-th byte of *Second is modified by XORing its * hi nybble with the low nybble of the k-th byte from *First, * and its low nybble with the hi nybble of the k-th byte from * *First. * Restrictions: * You must use only pointer syntax in accessing the data. */ void blendBytes(FILE* Out, const uint8_t* const First, uint8_t* const Second, uint32_t Length) { fprintf(Out, " "); } 

HEADER:

#ifndef PTRSTUFF_H #define PTRSTUFF_H #include  #include  /** Uses pointer-based logic to access a specified portion of a region of * memory and prints the corresponding bytes to a supplied file stream. * * Pre: Out is open on a file * baseAddr points to the first byte of the memory region * Offset is the location, relative to baseAddr, of the first * relevant byte of the memory region * nToPrint is the number of bytes to be printed */ void showBytesAtOffset(FILE* Out, const uint8_t* const baseAddr, uint16_t Offset, uint8_t nBytes); /** Enumerated type used in interface of showValue() */ enum _Sign {SIGNED, UNSIGNED}; typedef enum _Sign Sign; /** Uses pointer-based logic to display a specified portion of a region of * memory, using pointer typecasts to control the number of bytes that are * displayed, and the way those byte are interpreted. * * Pre: Out is open on a file * baseAddr points to the first byte of the memory region * Offset is the location, relative to baseAddr, of the first * relevant byte of the memory region * Sign indicates whether the bytes are to be interpreted as representing a * signed or unsigned integer * nByte is the number of bytes to be considered. You may assume nByte * will be 1, 2, 4, or 8, corresponding to the sizes of the integer * types in . * * Restrictions: * You must use only pointer syntax in accessing the data. */ void showValueAtOffset(FILE* Out, const uint8_t* const baseAddr, uint32_t Offset, Sign Sgn, uint8_t nBytes); /** Uses pointer-based logic to search a specified portion of a region of * memory for occurrences of a specified one-byte value. * * Pre: Out is open on a file * baseAddr points to the first byte of the memory region * Length is number of bytes in the memory region * Byte is the value to be found * Restrictions: * You must use only pointer syntax in accessing the data. */ void findOccurrencesOfByte(FILE* Out, const uint8_t* const baseAddr, uint32_t Length, uint8_t Byte); /** Uses pointer-based logic to copy a specified portion of a region of * memory to replace the bytes in another portion of that memory region. * * Pre: Out is open on a file * baseAddr points to the first byte of the memory region * Source and Destination point to the first bytes of two sections * of the memory region that contains Length bytes * The regions pointed to by Source and Destination do not overlap * Post: Length bytes, beginning at *Source, have been copied to Length * consecutive locations, beginning at *Destination * Restrictions: * You must use only pointer syntax in accessing the data. */ void copyBlock(FILE* Out, const uint8_t* const baseAddr, uint32_t Source, uint32_t Destination, uint32_t Length); /** Uses pointer-based logic to modify the contents of a specified portion * of a region of memory, by bitwise blending with bytes of another * portion of that memory region. * * Pre: Out is open on a file * baseAddr points to the first byte of the memory region * First and Second point to the first bytes of two sections * of the memory region that each contain Length bytes * The regions pointed to by First and Second do not overlap * Post: Length bytes, beginning at *Second, have been blended with Length * bytes, beginning at *First; the blending is accomplished as * follows: the k-th byte of *Second is modified by XORing its * hi nybble with the low nybble of the k-th byte from *First, * and its low nybble with the hi nybble of the k-th byte from * *First. * Restrictions: * You must use only pointer syntax in accessing the data. */ void blendBytes(FILE* Out, const uint8_t* const First, uint8_t* const Second, uint32_t Length); #endif 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Represent your interests well

Answered: 1 week ago

Question

b. Will new members be welcomed?

Answered: 1 week ago

Question

c. Will leaders rotate periodically?

Answered: 1 week ago

Question

b. Will there be one assigned leader?

Answered: 1 week ago