Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How can you translate this C code into assembly code in the code composer... I\'

ID: 3671060 • Letter: H

Question

How can you translate this C code into assembly code in the code composer... I'm using the msp430g2553 I'm trying to run this program but in a assembly


#include <msp430g2553.h>

int count;

int scount;

int z;

int main(void) {

WDTCTL = WDTPW | WDTHOLD; // Stop watchdogtimer

P1DIR = 0xFF;

P2DIR = 0x00;

count = 0;

scount = 0;

z = 0;

while (1)

{

if ((P2IN ) == 0x01)

{

z = 1;

}

if ((P2IN )== 0x02)

{

z = 0;

}

if ((P2IN )== 0x04)

{

z = 2;

}

if (P2IN == 0x09)

{

z = 1;

}

if (P2IN == 0x0A)

{

z = 0;

}

if (P2IN == 0x0C)

{

z = 2;

}

if (z == 1)

{

count++;

scount++;

if ((P2IN & BIT3) == BIT3)

{

P1OUT |= count;

_delay_cycles(1000000);

}

if ((P2IN & BIT3) != BIT3)

{

P1OUT |= scount;

_delay_cycles(10000);

}

P1OUT &= ~0xFF;

}

if (z == 0)

{

if ((P2IN & BIT3) == BIT3)

{

P1OUT |= count;

_delay_cycles(1000000);

}

if ((P2IN & BIT3) != BIT3)

{

P1OUT |= scount;

_delay_cycles(10000);

}

P1OUT &= ~0xFF;

}

if (z == 2)

{

count = 0;

scount = 0;

_delay_cycles(1000000);

P1OUT &= ~0xFF;

}

}

}

Explanation / Answer

In the code composer studio IDE, follow the steps to run this C code.

step 1) click on file > New > CCS project

step 2) Then give project name and select type "Executable"

step 3) Now uncheck "use default location"

step 4) Then click on browse location and select location

step 5) In device section select "msp430g2553" option

step 6) In project source and template section, select Empty assembly only project

step 7) click finish

step 8) Again right click on project main folder, new > source file > give source filename > then select template type as "default c source template"

step9) Finished.. execute the ptogrm.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote