Question

Consider the following program listing that is written in the C Language: #include <msp430.h> void main(void);...

  • Consider the following program listing that is written in the C Language:

#include <msp430.h>

void main(void);

{

WDTCTL = WDTPW|WDTHOLD;

unsigned char a=0x14;

unsigned char b=0xDC;

unsigned char c,d,e,f;

c = a^b;

d = a|b;

e = ~d;

f = ~e;

while(1);

}

  • 1) Are the declared data types local or global variables?
  • 2) Perform bitwise logical analysis to determine the unknown values of the given logic expressions.
  • 3) Show the correct addresses and contents for all variables in the code listing. Hint: Draw/Illustrate the proper order of placing data into the specified memory locations!!!

Step Into CCS IDE and provide screenshots!!!

I mainly just need help with #3

Homework Answers

Answer #1

Answer:- 1) The declared data types are global here as they have been defined outside of the main scope.

Answer :- 2) The value in WDTCTL after bitwise OR operation is-
WDTCTL = 0x5A | 0x80
=> WDTCTL = 0xDA

Answer :- 3) c = a+b = 0x6524. Here only 16-bit value is kept as variable size is of 16-bit due to int.

d = 0x89A8. Only 16-bit value.

e = 0x6524 - 0x89A8 = 0xDB7C.

Let's take starting memory is 0x1000. Then-

variable 'a' is at 0x100.

variable 'b' is at 0x1002.

variable 'c' is at 0x1004.

variable 'd' is at 0x1006.

variable 'e' is at 01008.

variable 'f' is at 0x100A to 0x100D. As float takes 4-bytes.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT