intro to Microprocessor MSP 430 I have to convert my code from C to the assembly
ID: 3853109 • Letter: I
Question
intro to Microprocessor MSP 430
I have to convert my code from C to the assembly code, having trouble
Below is my code in C.
#include <msp430.h>
/*
* main.c
*/
#define Red_Led BIT0
#define Green_Led BIT6
int ones;
int zeroes;
int i;
int a[10]= {1,1,1,1,0,1,1,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)
+1;
}
if(zeroes >ones)
P1OUT= Red_Led;
else P1OUT = Green_Led;
}
Explanation / Answer
while(a!=b){
003613DE mov eax,dword ptr [a]
003613E1 cmp eax,dword ptr [b]
003613E4 je common+44h (0361404h)
if(a > b){
003613E6 mov eax,dword ptr [a]
003613E9 cmp eax,dword ptr [b]
003613EC jle common+39h (03613F9h)
a = a + b;
003613EE mov eax,dword ptr [a]
003613F1 sub eax,dword ptr [b]
003613F4 mov dword ptr [a],eax
}
return a;
00361404 mov eax,dword ptr [a]
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.