Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 2, Problem 2.59HW
Explanation of Solution
C expression for given statement:
The C expression for word containing of least significant byte of “x” and the remaining bytes “y” is shown below.
Expression: (x & 0xFF) | (y & ~0xFF)
From the above expression,
- First, performing the “&” operation for “x” and “0xFF”, then the result producing “0x000000EF”.
- Then performs the “&” operation for “y” and “~0xFF”, then the result producing “0x76543200”.
- After performing “|” operation that is “(x & 0xFF) | (y & ~0xFF)”, the final result is “0x765432EF”.
For the above expression “(x & 0xFF) | (y & ~0xFF)”, a complete program has been developed in the below section:
//Header file
#include <stdio.h>
#include <assert...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a C++ program that reads two items from a data file, the bit string itself and the parity required, and then adjusts the bit string and then expresses both the original string and the parity adjusted string in hexadecimal form.Sample Run:Enter the bit string and parity (EVEN or ODD): 10110101 EVENOriginal Hex Value: B5Parity Adjusted Hex Value: 16B
Write a c++ program that takes 2 hex values and gives back the CRC Checksum.
sample output:
Enter two hex values separated by a space: 098 5CRC Checksum: 01Enter two hex values separated by a space: AC 5CRC Checksum: 11
code required in mips programming language a .s or .asm code not a c code.
Write a MIPS procedure that takes as its two parameters the starting address of a (zero-terminated) string, and a character c, and removes all instances of the character from the string. Also, write a main program to test your procedure. Your main program should input a string from the user (you can assume that the string will be at most 40 characters, not including the zero byte delimiter), and then prompt for input of a character c. If the character c that the user inputs is the newline character (ascii code 10), your program should terminate. Otherwise, your program should invoke your procedure, output the modified string, and then prompt for input of another character to be removed from the string, continuing in this manner until the input character is the newline character
Chapter 2 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Ch. 2.1 - Practice Problem 2.1 (solution page 143) Perform...Ch. 2.1 - Prob. 2.2PPCh. 2.1 - Prob. 2.3PPCh. 2.1 - Practice Problem 2.4 (solution page 144) Without...Ch. 2.1 - Prob. 2.5PPCh. 2.1 - Prob. 2.6PPCh. 2.1 - Prob. 2.7PPCh. 2.1 - Prob. 2.8PPCh. 2.1 - Practice Problem 2.9 solution page 146 Computers...Ch. 2.1 - Prob. 2.10PP
Ch. 2.1 - Prob. 2.11PPCh. 2.1 - Prob. 2.12PPCh. 2.1 - Prob. 2.13PPCh. 2.1 - Prob. 2.14PPCh. 2.1 - Prob. 2.15PPCh. 2.1 - Prob. 2.16PPCh. 2.2 - Prob. 2.17PPCh. 2.2 - Practice Problem 2.18 (solution page 149) In...Ch. 2.2 - Prob. 2.19PPCh. 2.2 - Prob. 2.20PPCh. 2.2 - Prob. 2.21PPCh. 2.2 - Prob. 2.22PPCh. 2.2 - Prob. 2.23PPCh. 2.2 - Prob. 2.24PPCh. 2.2 - Prob. 2.25PPCh. 2.2 - Practice Problem 2.26 (solution page 151) You are...Ch. 2.3 - Prob. 2.27PPCh. 2.3 - Prob. 2.28PPCh. 2.3 - Prob. 2.29PPCh. 2.3 - Practice Problem 2.30 (solution page 153) Write a...Ch. 2.3 - Prob. 2.31PPCh. 2.3 - Practice Problem 2.32 (solution page 153) You are...Ch. 2.3 - Prob. 2.33PPCh. 2.3 - Prob. 2.34PPCh. 2.3 - Practice Problem 2.35 (solution page 154) You are...Ch. 2.3 - Prob. 2.36PPCh. 2.3 - Practice Problem 2.37 solution page 155 You are...Ch. 2.3 - Prob. 2.38PPCh. 2.3 - Prob. 2.39PPCh. 2.3 - Practice Problem 2.40 (solution page 156) For each...Ch. 2.3 - Prob. 2.41PPCh. 2.3 - Practice Problem 2.42 (solution page 156) Write a...Ch. 2.3 - Practice Problem 2.43 (solution page 157) In the...Ch. 2.3 - Prob. 2.44PPCh. 2.4 - Prob. 2.45PPCh. 2.4 - Prob. 2.46PPCh. 2.4 - Prob. 2.47PPCh. 2.4 - Prob. 2.48PPCh. 2.4 - Prob. 2.49PPCh. 2.4 - Prob. 2.50PPCh. 2.4 - Prob. 2.51PPCh. 2.4 - Prob. 2.52PPCh. 2.4 - Practice Problem 2.53 (solution page 160) Fill in...Ch. 2.4 - Practice Problem 2.54 (solution page 160) Assume...Ch. 2 - Compile and run the sample code that uses...Ch. 2 - Try running the code for show_bytes for different...Ch. 2 - Prob. 2.57HWCh. 2 - Write a procedure is_little_endian that will...Ch. 2 - Prob. 2.59HWCh. 2 - Prob. 2.60HWCh. 2 - Prob. 2.61HWCh. 2 - Write a function int_shifts_are_arithmetic() that...Ch. 2 - Fill in code for the following C functions....Ch. 2 - Write code to implement the following function: /...Ch. 2 - Write code to implement the following function: /...Ch. 2 - Write code to implement the following function: / ...Ch. 2 - You are given the task of writing a procedure...Ch. 2 - Prob. 2.68HWCh. 2 - Write code for a function with the following...Ch. 2 - Write code for the function with the following...Ch. 2 - You just started working for a company that is...Ch. 2 - You are given the task of writing a function that...Ch. 2 - Write code for a function with the following...Ch. 2 - Write a function with the following prototype: /...Ch. 2 - Prob. 2.75HWCh. 2 - The library function calloc has the following...Ch. 2 - Prob. 2.77HWCh. 2 - Write code for a function with the following...Ch. 2 - Prob. 2.79HWCh. 2 - Write code for a function threefourths that, for...Ch. 2 - Prob. 2.81HWCh. 2 - Prob. 2.82HWCh. 2 - Prob. 2.83HWCh. 2 - Prob. 2.84HWCh. 2 - Prob. 2.85HWCh. 2 - Intel-compatible processors also support an...Ch. 2 - Prob. 2.87HWCh. 2 - Prob. 2.88HWCh. 2 - We are running programs on a machine where values...Ch. 2 - You have been assigned the task of writing a C...Ch. 2 - Prob. 2.91HWCh. 2 - Prob. 2.92HWCh. 2 - following the bit-level floating-point coding...Ch. 2 - Following the bit-level floating-point coding...Ch. 2 - Following the bit-level floating-point coding...Ch. 2 - Following the bit-level floating-point coding...Ch. 2 - Prob. 2.97HW
Knowledge Booster
Similar questions
- Write a C Code program that performs the following • Prints your name And student number Reads number of positive integers, finds and prints the smallest even integer of them and counts its occurrences. Assume that the input end when the user enters-1 E.g:- if you entered 6 2 1 2 2 2 -1; the program find the smallest even integer is 2 and occurence count for 2 is 4arrow_forwardIn c++ Now write a program for a double floating pointtype.•What are the number of significant bits that the double’s mantissa can hold, excluding the sign bit.•What is the largest number that a double’s mantissa can hold without roundoff error?•Repeat the program shown on the previous page but set to show where the double’s mantissa starts to exhibit roundoff errors.arrow_forwardWrite a C++ function name bitwise that takes input two int arrays of size 5 and then perform bitwise AND, OR and XOR operation between the two adjacent indexes of the array. Display the resulting arrays as output.arrow_forward
- Write a c++ program that takes 2 hex values and gives back the CRC Checksum. sample output: Enter two hex values separated by a space: 098 5CRC Checksum: 01arrow_forwardWrite a C program Test, Debug and execute the C program Write a program that reverses the order of the bits in an unsigned integer value. The program should input the value from the user and call function reverseBits to print the bits in reverse order. Print the value in bits both before and after the bits are reversed to confirm that the bits are reversed properly. Write a program that creates a function multiple that determines if the integer entered from a keyboard is a multiple of some integer x.arrow_forwardWrite a C++ program that calculates the division of binary, use the BinDiv( ) - a function that performs binary division Sample Output Enter First Number: 11101 Enter Second Number:101 THE DIVISION OF THE TWO BINARY NUMBERS: 101.1100110011001101arrow_forward
- 3. Write a C program multiplication Table.c that outputs the multiplication table as follows: X Multiplication Table 1 2 7 8 9 10 2 7 8 9 10 4 14 16 18 20 6 9 12 15 18 21 24 27 30 8 12 16 20 24 28 32 36 40 35 40 45 50 18 24 30 36 42 48 54 60 42 49 35 42 49 56 63 70 64 72 80 72 81 90 70 80 90 100 3 4 5 6 3 4 5 6 1 1 2 3 3 4 4 5 5 10 15 20 25 30 6 6 12 7 7 14 21 28 35 16 24 32 40 48 8 8 99 18 10 10 20 30 40 50 60 56 27 36 45 54 63arrow_forwardThis needs to be done in C Programming. A manufacturing plant has an alarm monitor program that reports any of sixteen possible alarms. A 16-bit variable ALARM is examined, and each 1 bit found corresponds to an active alarm. The alarms are numbered 1 – 16, with the least significant bit (LSB) corresponding to Alarm 1 and the most significant bit (MSB) corresponding to Alarm 16. Prompt for the unsigned short integer ALARM, and then use bitwise logic to determine and display all corresponding active alarms, e.g., output “Alarm 12 Active”.arrow_forwardWrite a C++ program to input the values of two integers x, and y and find the number of the same bits in the binary representation of both the numbers. Example: If x = 10, y = 15 Output: 4 All test cases will be generated such that both the numbers have the same number of bits.arrow_forward
- Write a MIPS program that will handle calculating minifloat addition for two numbers using the rules discussed in class and storing each of the parts as a binary integer. To do this, each ‘minifloat’ number will need to be represented (I suggest hard coded) as one register for the sign, one for the exponent part, one for the ‘significand’ (which you then convert to the fraction part). Hard coding means here that you don’t need to read in the 6 parts as user input, just have something like li $s0, 0 li $s1, 12 li $s2, 5 which is equivalent to a minifloat of 0 1101 101 = 1.101 * 2^(12-7) = 1.101*2^5 This means your program will be work with at least 6 registers as variables. For testing, show that your program can correctly calculate the Lab 5 X+Y and A+B and then one other example of your choosing. Don’t worry about special cases of 0 0000 000 or 1 1111 111 or similar, but your program should detect overflow. This will involve a lot of (in your head) jumping back and forth between…arrow_forward13. Write a C program to print the following grid of numbers for any given input integer n (>= 1). Example: Input: 4 Output: 1 2 3 4 2 1 2 3 3 2 12 4 3 2 1 Input: 6 Output: 1 2 3 4 5 6 2 1 2 3 4 5 32 23 4 3 2 1 2 3 5 4 3 2 12 654321 Hint: The logic is that the first digit in each row is 1 more than the first digit of the previous row. Then we count down to 1. After we reach 1, again start counting up to n. There shall be n digits in each row.arrow_forwardWrite a C++ program to convert a decimal value to an eight-bit two's complement binary number. Let the user enter a decimal whole number X, either positive or negative, and output the equivalent two's complement binary number. The value of X will range between -128 <= X <= 127. Error check input size. Output to the screen, each X and its eight-bit two's complement equivalent separated by a space, =, and then another space. Refer to the sample output below. Sample Runs (2):Enter a value: 1515 = 00001111Enter a value: -49-49 = 11001111arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education