Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Intro to Microprocessors A C program for the MSP430 to calculate the number of zeros and ones in an array. If the number of zeros

Intro to Microprocessors

A C program for the MSP430 to calculate the number of zeros and ones in an array. If the number of zeros is more than the number of ones, the red LED (conected to P1.0 on the MSP430 LaunchPad) will turn on. Otherwise, the green LED (connected to P1.6 on the MSP430 LaunchPad) will turn on.

I have done the above bold problem in C program. Which I will provide below, I just need help in writing it in the assembly language.

#include

/*

* main.c

*/

#define Red_Led BIT0

#define Green_Led BIT6

int ones;

int zeroes;

int i;

int a[10]= {0,0,0,0,0,1,0,0,0,1};

void main(void) {

WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

P1DIR = Red_Led|Green_Led;

P1OUT=0;

for(i =0;i<=10;i++)

{

if( a[i]== 0)

zeroes = zeroes+1;

else if(a[i]==1)

ones = ones +1;

}

if(zeroes >ones)

P1OUT= Red_Led;

else P1OUT = Green_Led;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+free to pirate employees from competitors?

Answered: 1 week ago