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.68HW
Explanation of Solution
Function definition for “lower_one_mask()” function:
The implementation for “lower_one_mask()” function is given below:
//Header file
#include <stdio.h>
#include <assert.h>
//Function definition for lower one with mask
int lower_one_mask(int n)
{
//Determine the value of "w".
int wValue = sizeof(int) << 3;
/* Return the given value by using "-1 >> (wValue - n)" */
return (unsigned) -1 >> (wValue - n);
}
//Main function
int main(int argc, char* argv[])
{
/* Call lower_one_mask with checking value using assert function */
assert(lower_one_mask(6) == 0x3F);
/* Call lower_one_mask with checking value using assert function */
assert(lower_one_mask(21) == 0x1FFFFF);
/* Call lower_one_mask with ch...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a C-function with two arguments (n and r) that has prototype:
char clearbit(char k, char bits)
The function clears (sets to 0) the bit number k (in the range of 0 to 7) in bits and returns the resulting value. For example, if k is 0x02 and bits is 0x07, the function would return bits with its k’th bit cleared, resulting in 0x03. It must not change other bits in bits.
Hint: You may use any number of C-statements, but this task can be accomplished in as few as one!
this is COmputer machine architecture !
Help me fix the following code as theres an error.
what were trying to accoplish;
The assignment is to create a MIPS program that corrects bad data using Hamming codes.
The program is to request the user to enter a 12-bit Hamming code and determine if it is correct or not. If correct, it is to display a message to that effect. If incorrect, it is to display a message saying it was incorrect and what the correct data is (the 12-bit Hamming code) again in hex. I will be testing only with single bit errors, so the program should be able to correct my tests just fine. You do not need to worry about multiple bit errors.
# This program corrects bad data using Hamming codes
# It requests the user to enter a 12-bit Hamming code and determines if it is correct or not
# If correct, it displays a message to that effect. If incorrect, it displays a message
# saying it was incorrect and what the correct data is (the 12-bit Hamming code) again in hex.
# This…
F = A +B'C which one of the followings is the representation of function F in terms of SOP
form?
F(A,B,C)= m0+m2+m3
F(A,B,C)= M0+M2+M3
F(A,B,C) = M1+M4+M5+M6+M7
F(A,B,C) = m1+m4+m5+m6+m7
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
- Code the function multiplier(). /***** *** //The multiplier function takes 2 integer // parameters n1 and n2 and displays the result // of n1 times n2 //*** *******arrow_forwardWrite a C language function named more_ones that takes a uint32_t parameter as input and returns an int result. The returned result should be 1 if there are strincly more 1 bits in the input than 0 bits, and 0 otherwise. So, more_ones(0) should return 0 while more_ones(0x0ffffff) should return 1. You must use bitwise operations to solve this problem and may not use any library functions to help.arrow_forward4. Using bitwise operators In C code Write a function int negate(int n) that can negate an integer without using the - operator.arrow_forward
- Problem F. 73154. Trailing zeros Input file: Output file: Time limit: Memory limit: standard input standard output 1 second 256 megabytes In this problem, you are given 8-bit number r. Find the number of trailing zeros in its binary representation. Trailing zeros are the ones that we encounter until the first 1-bit if we traverse the binary representation from right to left. For example, the binary representation of the mumber 96 is 01100000. Number of 0-bits until the first 1-bit is 5 (considering that we traverse the binary representation from right to left). Input The first line of input contains a single number z – 8-bit number (1arrow_forwardConsider the following code which includes a parity check for the third digit: C=(000,011,101,110). You get the third digit by adding the first two and then using the remainder on division by 2. Can this code detect and count single errors? how can this be implemented?arrow_forwardQuestion VI: Write a program that computes and plots the spectral representation of the function 1. y(t) = (10e-10t)u(t) 2. y(t) = (10e-10t cos100t)u(t)arrow_forwardIn C, write a function int setbit(int n, int i) to set the i^ᵗʰ bit of n if i^ᵗʰ bit is 0.arrow_forwardWrite a function int bitset(int x, int n) to set nth bit of x to 1, if its (n-1)th bit is 1. if n <1 or n >15, the function will return -1 to thecalling functionarrow_forwardimplement anyEvenBit(x) Return 1 if any even bit in x is set to 1 you are only allowed to use the following eight operators: ! ~ & ^ | + << >> “Max ops” field gives the maximum number of operators you are allowed to use to implement each function /* * anyEvenBit - return 1 if any even-numbered bit in word set to 1* Examples anyEvenBit(0xA) = 0, anyEvenBit(0xE) = 1* Legal ops: ! ~ & ^ | + << >>* Max ops: 12*/int anyEvenBit(int x) {return 2;}arrow_forwardImplement the Hamming Code error detection and correction algorithm for a group message to be transmitted over a network. Hamming code algorithm allows the receiver to detect errors that may have been introduced due to many factors such as noise, interference, and many others. -> Assume the following: 1. The sender message length is 2 bytes. The data transmitted to the user is the 2-byte data in addition to the parity bits. 2. The receiver must be able to detect and correct 1-bit error. Report :In the report you must include an overview of the Hamming code algorithm and you need to show: 1. The detailed calculation of the minimum number of parity bits needed for a message of 2-byte length. 2. Details on how sender generates the parity bits. 3. Details on how thew receiver detects and corrects a 1-bit error. THANKS., PLEASE GIVE DETAILED DESCRIPTION.arrow_forwardFunction 6n³ + 2n² + 7n + 1 belongs to: ○0 (n³) (n³) 22 (n²³) O all of the abovearrow_forward1. Convert infix to postfix ((A+B)*(C-D)+E)/(F+G) (A+B/C*(D+E)-F) A+(B*C-(D/E-F)*G}*Harrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_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