Question

In: Computer Science

Port = 0x0055 A) Port &= 0xff0; B) Port |= 15;   C) Port = Port ^...

Port = 0x0055

A) Port &= 0xff0;

B) Port |= 15;  

C) Port = Port ^ 0x0005;

D) Port = ( ( Port &~(0x000f) ) | 0x0020 );  

Please explain how each logical opperator works and write out the results.

Solutions

Expert Solution


Given:
Port = 0x0055
   In decimal : 85
   In Binary: 1010101

A)  
   Port &= 0xff0;
       = Port = Port & 0xff0

       0xff0 = 4080 in decimal
               = 111111110000 in Binary

       Port & 0xff0 => 1010101 & 111111110000 = 1010000 in Binary

B)
   Port |= 15;
   Port = Port | 15

   15 = 1111 in Binary

   Port | 15 =>
       1010101 | 1111 = 1011111 => 95 in decimal

C)
   Port = Port ^ 0x0005;

   0x0005 => 5 in decimal => 101 in binary

   Port ^ 0x0005 = 1010101 ^ 101 => 1010000 => 80 in decimal

D)
   Port = ( ( Port &~(0x000f) ) | 0x0020 );

   0x000f = 15 in decimal = 1111 in binary
   ~(0x000f) = -16 in decimal = 11111111111111111111111111110000 in binary
   0x0020 = 32 in decimal = 100000 in binary

   ( Port &~(0x000f) => 1010101 & 11111111111111111111111111110000 = 80 in decimal = 1010000 in binary
   ( Port &~(0x000f) | 0x0020 => 1010000 | 100000 => 1110000 = 112 in decimal


Related Solutions

Write the C code required to configure pin 0 on port B to be an input...
Write the C code required to configure pin 0 on port B to be an input with the pullup resistor enabled.
b. Who is a ‘port technician’?
b. Who is a ‘port technician’?
1.  Suppose c = 15 and A = 35 degrees. Find: a= b= B= 2. Suppose a...
1.  Suppose c = 15 and A = 35 degrees. Find: a= b= B= 2. Suppose a = 12 and b = 11. Find an exact value or give at least two decimal places: sin(A)= cos(A) = tan(A) = sec(A)= csc(A)= cot(A)=
1. Evaluate: (a+b)/(c-d) + 9/(a+d) when a=5, b=3, c=8, d=4 a. 6 b. 3 c. 15/2...
1. Evaluate: (a+b)/(c-d) + 9/(a+d) when a=5, b=3, c=8, d=4 a. 6 b. 3 c. 15/2 d. 17/13 2. Solve for x: 5(x+3) = 35 a. 2 b. 7 c. 4 d. -4 3. Acid rain occurs primarily as a result of a. operating a nuclear power plant b. burning coal or oil containing sulfur c. by-products created by operating an oil refinery d. the use of Freon and other refrigerants 4. The "ozone holes" at the polar region arise...
Write instruction(s) in C to get bits 4 and 7 of Port-C, then compute the “XOR...
Write instruction(s) in C to get bits 4 and 7 of Port-C, then compute the “XOR (exclusive OR)” of these two bits and write the result of the “XOR operation” to bit 4 of Port-D.
Write instruction(s) in C to get bits 4 and 7 of Port-C, then compute the “XOR...
Write instruction(s) in C to get bits 4 and 7 of Port-C, then compute the “XOR (exclusive OR)” of these two bits and write the result of the “XOR operation” to bit 4 of Port-D.
Q1- Write code in C language(Atmel atmega32 avr microcontroller) (a)-Switches are connected to Port C and...
Q1- Write code in C language(Atmel atmega32 avr microcontroller) (a)-Switches are connected to Port C and Port B and LED’s with PORTD. Write a code to read input from PortB and C and perform following. Addition of both inputs, Subtraction, Multiplication, Division, And, Or, Nor,Xor. (b)- A switch is connected to PD0 and LED’s to Port B and Port C. Write a code to perform following: When switch is 0 send your roll number to Port B. When Switch is...
Bond Coupon Rate ​(annual payments) Maturity ​(years) A 0.0​% 15 B 0.0​% 10 C 3.9​% 15...
Bond Coupon Rate ​(annual payments) Maturity ​(years) A 0.0​% 15 B 0.0​% 10 C 3.9​% 15 D 7.6​% 10 What is the percentage change in the price of each bond if its yield to maturity falls from 6.1% to 5.1%​? The price of bond A at 6.1% YTM per $100 face value is $ (round to nearest cent) ​
An LCD 16x2 display is used for PIC16F1619, if Port C is connected to 8 data...
An LCD 16x2 display is used for PIC16F1619, if Port C is connected to 8 data pins of the LCD. Pin4 and 5 of port A are connected to EN and RS respectively. RW is tied to the ground. Write a C code to set up 2 lines, 5x8 matrix, 8-bit mode and force the cursor to the beginning of the first line.
Write a C program that accepts a port number as a command line argument, and starts...
Write a C program that accepts a port number as a command line argument, and starts an HTTP server. This server should constantly accept() connections, read requests of the form: GET /path HTTP/1.1\r\n\r\n read the file indicated by /path, and send it over the "connect" file descriptor returned by the call to accept().
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT