Problem 1. For this problem, assume that you are developing code in the Clanguag
ID: 2079350 • Letter: P
Question
Problem 1. For this problem, assume that you are developing code in the Clanguage for a 32-bit CPU such as the PIC32. Also assume that you are given an integer named k. As usual, bit position 0 refers to the least-significant bit. a) Write a single instruction that will cause the bits 4 to 7 of k to be set to 1, without affecting any other bits of k. b) Write a single instruction that will cause bit 0 and bit 3 of k to be set to 1, without affecting any other bits of k. c) Write a single instruction that will cause the most-significant byte of k to be cleared to 00000000, without affecting any other bits of k. d) Write 1 or 2 instructions that will cause the least-significant byte of k to contain the bit pattern 10101010, without affecting any other bits of k. e) Write the statement that computes the condition that is true if the 4th bit of k is 1 and 6th bit of k is 0 In other words, write the statement that goes in the blank space below such that the if statement is true when the 4th bit of k is 1 and 6th bit of k is 0 and false, otherwise. if f Assume char in is a char that has been read from the input. Your code should check to see if char in is a lower case letter and if it is, prints the upper case version of itExplanation / Answer
here we taken K as an integer so for integer having 32 bits
1a.
K=K | 0x000000F0;
" | " gives the bit wise logical OR operation
0x000000F0 in hex =0000 0000 0000 0000 0000 0000 1111 0000 in binary
as we know that the operation of a two input OR gate is if any one of the input is one output is one.
1b.
K=K | 0x00000009;
1c.
K=K&0x00FFFFFF;
0x00FFFFFF in hex = 0000 0000 1111 1111 1111 1111 in binary
& indicates logical bit wise AND operation
as we know that 2 input AND operation is if any one of the input is zero output is zero
in the above problem the mostsignificant byte is AND with 8 zeros
1d.
K=K & 0xFFFFFFAA;
K=K | 0X000000AA;
here the first instruction is used to make the ouput bits (0,2,4,6) as zeros
here the second instruction makes the output bits (1,3,5,7) as ones
so after performing two instructions the outbut became the last significant byte as 10101010
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.