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
Consider the following C++ program: #include <iostream> #define PRIORITY 10 void main() {             int tableInd =...
Consider the following C++ program: #include <iostream> #define PRIORITY 10 void main() {             int tableInd = 20;             int arrayInd = 30;             cin >> tableInd;             if (tableInd > 50)                arrayInd = PRIORITY;             else                arrayInd = setindex(PRIORITY);             cout << arrayInd; } Answer the following questions: a) At what time is the keyword void bound to its meaning? Language design         Language implementation     Compile          Link    Load    Run b) At what time is the value of PRIORITY bound? Language design         Language implementation     Compile          Link    Load    Run c) At what...
The code is in C programming language pls convert it into python. Thanks. Program --> #include...
The code is in C programming language pls convert it into python. Thanks. Program --> #include <stdio.h> #include <stdlib.h> void main() { //declare variables FILE *fileptr; char filename[15]; char charRead; char filedata[200],searchString[50]; int i=0,j=0,countNoOfWord=0,count=0; //enter the filename to be opened printf("Enter the filename to be opened \n"); scanf("%s", filename); /* open the file for reading */ fileptr = fopen(filename, "r"); //check file exit if (fileptr == NULL) { printf("Cannot open file \n"); exit(0); } charRead = fgetc(fileptr); //read the string...
Consider the C program (twoupdate) to demonstrate race condition. In this assignment, we will implement Peterson's...
Consider the C program (twoupdate) to demonstrate race condition. In this assignment, we will implement Peterson's algorithm to ensure mutual exclusion in the respective critical sections of the two processes, and thereby eliminate the race condition. In order to implement Peterson's Algorithm, the two processes should share a boolean array calledflagwith two components and an integer variable called turn, all initialized suitably. We will create and access these shared variables using UNIX system calls relating to shared memory – shmget,...
Hi there, I've been asked to write a program in C which can read values from...
Hi there, I've been asked to write a program in C which can read values from a file then sort them, and then write to a binary file. I'm getting stuck when I write my binary file as the output is just spitting out garbage values and not the values that are being read in. When I print my input file reader everything is perfect but after sorting and then writing, the output is completely wrong. I have checked that...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT