1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Daniel [21]
4 years ago
11

suppose we number the bytes in a w-bit word from 0 (less significant) to w/8-1 (most significant). write code for the followign

c function, which will return an unsigned value in which byte i of argument x has been replaced by byte b:unsigned replace_byte (unsigned x, int i, unsigned char b);
Engineering
1 answer:
sammy [17]4 years ago
8 0

Solution:

typedef  unsigned  char  *byte_pointer;

static int  int_of_bit  (byte_pointer x,  int  loc)

{

                  return(x[loc] << loc*8);

}  

static int  replace_byte(unsigned int a,  int loc,  unsigned int  b)

    unsigned int a_loc = int_of_bit((byte_pointer) &a ,  loc);

    unsigned int b_loc = (b  <<  loc*8);

 

     a  -=  a_loc;

      a  += b_loc;

      return a;

}

Explanation:

This takes two ints in hex format, one with 8 bits (0x00000000) and one with 2 bits (0x00) then places the 2 bit hex into the 8 bit at a given location.

EX:  replace_byte(0x00000000, 1, 0xFF) return 0x0000FF00

First thing first, it looks like you have some mixup:

" one with 8 bits (0x00000000) and one with 2 bits (0x00)*- what you mean is nibble not bits. Each hex character (0-9, A-F) represent 4 bits (16 possible combination), and is called a "nibble".

0x0000000 is 4 bytes. 0x00 is 2 bytes.

Next, you say "takes two ints in hex format" - your function takes two ints in any format. You're just choosing tp express them in hexidecimal. C++ doesn't care if you specify numbers in hex, decimal, octal, binary, etc.

You might be interested in
!!!!!!!!!!!!!!PLEASE ANSWER THIS!!!!!!!!!!!!!!!!
dmitriy555 [2]

Answer:

age = int(input())

ticket = 100

total = 0

passengers = 1

while passengers <= 5:

if age < 3:

 continue

else:

 total += ticket

passengers += 1

print(total)

Explanation:

UuU

6 0
2 years ago
Which of the following statements are true of computer hardware engineers?
9966 [12]

Answer:

you never mentioned the options

3 0
4 years ago
What is the critical path and time duration?
kvasek [131]

The critical path is A-B-C, with a duration of 15 minutes.

<u>Explanation</u>:

  • The critical path is A-B-C, with a term of 15 minutes. You don't need to be knowledgeable in computer lingo to make sense of this one (as I made sense of it absent a lot of data on that half of the condition). Here's the manner by which I made sense of this.  
  • The main thing I saw was that "predecessor" was utilized, which implies something precedes the other thing. That provided me the primary insight that A precedes B and C, and that B must precede C. Then, I just included the term times for the three ways, which allowed me 15 minutes.
3 0
3 years ago
Which dimension of wellness focuses on finding enjoyment and satisfaction in daily endeavours?
UNO [17]

Answer:

I believe its emotional because it says satisfaction and most of the time that has to deal with emotions running through the body.

Explanation:

5 0
3 years ago
Select the correct answer.
scoundrel [369]
A is your answer choice
8 0
3 years ago
Other questions:
  • A 15-ft beam weighing 570 lb is lowered by means of two cables unwinding from overhead cranes. As the beam approaches the ground
    9·1 answer
  • The voltage in a series circuit is being increased from 12 volts to 24 volts.
    6·1 answer
  • ITS FOR DRIVERS ED!!
    13·2 answers
  • You are traveling along an interstate highway at 32.0 m/s (about 72 mph) when a truck stops suddenly in front of you. You immedi
    11·1 answer
  • This elementary problem begins to explore propagation delayand transmission delay, two central concepts in data networking. Cons
    6·1 answer
  • Explain the benefits of reading A vocabulary section at the beginning of a text
    10·2 answers
  • A(n) ____ is an object setting used to control the visible display of objects.
    15·1 answer
  • 17- The cathodic polarization is ..... *
    12·1 answer
  • Situation: Peter is designing a new hybrid car that functions on solar power. He is currently working on sketches of his design
    7·1 answer
  • Construction support involves mostly what kind of work?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!