
Compile and run the sample code that uses show_bytes (file show-bytes. c) on different machines to which you have access. Determine the byte orderings used by these machines.

Byte ordering:
- Some machines decide to store the objects in memory ordered from least significant byte to most, while other machines store them from most to least.
- The byte ordering are made by the two ways:
- Little Endian
- In little Endian, the least significant byte comes first.
- Big Endian
- In big Endian, the most significant byte comes first.
- Little Endian
Example:
The example for find the little-endian and big-endian for hexadecimal value is shown below:
Here assume that the hexadecimal value is “0x13244860”. Then address range for given ordering byte is “0x200” through “0x203”.
Big Endian for given hexadecimal value is
0x200 | 0x201 | 0x202 | 0x203 |
13 | 24 | 48 | 60 |
Little Endian for given hexadecimal value is
0x200 | 0x201 | 0x202 | 0x203 |
60 | 48 | 24 | 13 |
Explanation of Solution
Corresponding code from given question:
#include <stdio.h>
//Define variable "byte_pointer" in char datatype.
typedef unsigned char* byte_pointer;
//Function definition for show_bytes.
void show_bytes(byte_pointer start, size_t len)
{
//Declare variable "i" in int data type.
int i;
/* "For" loop to determine byte representation in hexadecimal */
for (i = 0; i < len; i++)
//Display each bytes in "2" digits hexadecimal value.
printf(" %.2x", start[i]);
printf("\n");
}
//Function to determine byte for "int" number.
void show_int(int x)
{
//Call show_bytes function with integer value.
show_bytes((byte_pointer) &x, sizeof(int));
}
//Function to determine byte for "float" number.
void show_float(float x)
{
//Call show_bytes function float value.
show_bytes((byte_pointer) &x, sizeof(float));
}
//Function to determine byte for "pointer" number.
void show_pointer(void *x)
{
//Call show_bytes function with pointer value.
show_bytes((byte_pointer) &x, sizeof(void *));
}
//Test all show bytes.
void test_show_bytes(int val)
{
//Define variables.
int ival = val;
float fval = (float) ival;
int *pval = &ival;
//Call function.
show_int(ival);
show_float(fval);
show_pointer(pval);
}
//Main function.
int main(int argc, char* argv[])
{
//Define the sample number.
int sampleNumber = 682402;
//Call test_show_bytes function.
test_show_bytes(sampleNumber);
return 0;
}
The given program is used to display the byte representation of different program objects by using the casting.
- Define “byte_pointer” using “typedef”.
- It is used to define data type as a pointer to an object of type “unsigned char”.
- The function “show_bytes” is used to display the address of a byte sequence by using the argument that is byte pointer and a byte count.
- Each byte is displayed by “2” digit.
- The function “show_int” is to display the byte representations of object of “int” data type.
- The function “show_float” is to display the byte representations of object of “float” data type.
- The function “show_pointer” is to display the byte representations of object of “void *” data type.
- Test all the data type values by using function “test_show_bytes”.
- Finally, assign the sample number in main function and call the “test_show_bytes” with argument “sampleNumber”.
Byte ordering used by the given machines:
After compiling and running the above code, the following output will be appear
a2 69 0a 00
20 9a 26 49
3c cc e9 18 ff 7f 00 00
From the above output,
- The byte representation for “int” data type is “a2 69 0a 00”.
- The byte representation for “float” data type is “20 9a 26 49”.
- The byte representation for “int *”data type is “3c cc e9 18 ff 7f 00 00”.
The byte ordering used by these machines is “big-endian”.
- Reason:
- Consider, the byte representation of “int” value is “a2 69 0a 00”.
- From this, the value is ordered from most significant byte to least significant byte. Hence, it is referred as big-endian.
Want to see more full solutions like this?
Chapter 2 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Additional Engineering Textbook Solutions
Introduction To Programming Using Visual Basic (11th Edition)
Degarmo's Materials And Processes In Manufacturing
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
SURVEY OF OPERATING SYSTEMS
Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out With Visual Basic (8th Edition)
- I want to explain my work in Python botnets and it is completely working on the tkinter function with an explanation of how I can work on it with an introduction about what it is and what its benefit isarrow_forwardWhen you connect your device to Wi-Fi, what happens "under the hood"? Explain in detail, with pictures, what it's like.arrow_forwardYou will write a program that allows the user to keep track of college locations and details about each location. To begin you will create a College python class that keeps track of the csollege's unique id number, name, address, phone number, maximum students, and average tuition cost. Once you have built the College class, you will write a program that stores College objects in a dictionary while using the College's unique id number as the key. The program should display a menu in this order that lets the user: 1) Add a new College 2) Look up a College 4) Delete an existing College 5) Change an existing College's name, address, phone number, maximum guests, and average tuition cost. 6) Exit the programarrow_forward
- I need help with this problem and an step by step explanation of the solution from the image described below. (Introduction to Signals and Systems)arrow_forwardI need help with this problem and an step by step explanation of the solution from the image described below. (Introduction to Signals and Systems)arrow_forwardI need help with this problem and an step by step explanation of the solution from the image described below. (Introduction to Signals and Systems)arrow_forward
- I need help with this problem and an step by step explanation of the solution from the image described below. (Introduction to Signals and Systems)arrow_forwardHello, Please read the provided text carefully—everything is detailed there. I need high-quality diagrams for both cases: Student A and Student B, showing the teacher teaching them through knowledge distillation. Each case should be represented as a separate image. The knowledge distillation process must be clearly illustrated in both. I’ve attached an image that shows the level of clarity I’m aiming for. Please do not use AI-generated diagrams. If I wanted that, I could do it myself using ChatGPT Premium. I’m looking for support from a real human expert—and I know you can help. " 1. Teacher Model Architecture (T) Dataset C: Clean data with complete inputs and labels Architecture Input Embedding Layer Converts multivariate sensor inputs into dense vectors. Positional Encoding Adds time-step order information to each embedding. Transformer Encoder Stack (repeated N times) Multi-Head Self-Attention: Captures temporal dependencies across time steps. Add…arrow_forward(connection)? Q1: Define the BGP ? Ebgp vs I bgp, and how do I advertise? With a drawing example QT: Explain how to make messages in the BGP protocol. Q: What is concept the hot potato routing in BGP? Q: What are the criteria for BGP route selection? Qo: Define the concept of Spanning Tree Protocol. Explain in detail and draw the figures. Q1: What happens when STP is disabled? QV: Define the concept of broadcast storm. QA: List and explain the Steps to a Loop-Free Topology when using the Spanning Tree Algorithm and Spanning Tree Protocol in a four-step process. I want a typical and concise Solutionarrow_forward
- WATCH THE VIDEO ABOUT MODELLING OR SPECIFICATION PHASE AND ANSWER THE FOLLOWING QUESTIONS: https://www.youtube.com/watch?v=uoIxDeAyfdo 1.- DEFINE SPECIFICATION OR MODELLING 2.- WRITE DOWN THE 3 REQUIREMENTS SPECIFICATION TECHNIQUES OR FORMATS 3.-DEFINE USE CASES 4.-DEFINE SRS 5.-DEFINE USER STORIES 6.- IS IT RECOMMENDABLE TO USE SRS DOCUMENTS IN AGILE METHODOLOGY? WHY? 7.- HOW DO YOU KNOW WHICH TECHNIQUE OR FORMAT TO USE? 8.- WRITE DOWN THE USE CASE COMPONENTSarrow_forwardREADING AND LISTENING ACTIVITIES BASED ON THE VIDEO: “REQUIREMENT ELICITATION “ Watch the following video and look for the answer to the following questions: https://www.youtube.com/watch?v=pSQRetBoaRE&t=24s 1.-NAME THE 2 PHASES OF THE REQUIREMENT ENGINEERING PROCESS 2.-NAME AT LEAST 7 ELICITATION TECHNIQUES TO COLLECT THE INFORMATION REQUIRED 3.-REFER TO THE NUMBER OF QUESTIONS AND TYPE OF QUESTIONS THAT SHOULD BE ASKED TO THE DIFFERENT STAKEHOLDERS. 4.-NAME THE DIFFERENT TYPES OF PROBLEMS YOU CAN ENCOUNTER DURING THE REQUIREMENT ELICITATION PROCESS 5.- ACCORDING TO THE VIDEO, WHICH TYPES OF TECHNIQUES SHOULD YOU USE, WHICH ONES WOULD YOU USE ACCORDING TO PROFESSOR SHERRIFF ‘S RECOMMENDATIONS?arrow_forwardCan you please show me how I can do this on google sheets. For the spreadsheet you need to create a multi page sheets thing that uses all the techniques of counts/sums and graph showing how many contracts have been returned for each grade...you can make up the data (let's say in grade 9 I got 15 contracted back with fake data that I want you to show me how to create on google spreadsheet) For grade 10 i got 20 contracts signed, for grade 11 I got 16 contracts and for grade 12 I got 25 contracts back. Can you help me pls. Thanks so much. Make sure you have graphs on the page and also the sum written as a formula and the numbers filled in the columns.arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





