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

Convert the following assembly language program into a C program: Convert the fo

ID: 3858070 • Letter: C

Question

Convert the following assembly language program into a C program:

Convert the following assembly language program into a C program: *Update: The variables are initialized, in lines 4 & 6 of the red assembly language code. include "p24Hxxxx.inc" global__reset bss: Uninitialized data section: Variables start at location 0x0800 x: .space 2: Allocating space (two bytes) to variable. y: .space 2;Allocating space (two bytes) to variable. count: .space 1: Allocating space (one byte) to variable.:: Code Section in Program Memory: text;start of Code section __reset:;first instruction located at __reset label mov #__SP_init, w15: Initialize the Stack Pointer mov #__SPLIM_init, W0 mov W0, SPLIM: Initialize the stack limit register: __SP_init set to be after allocated data: User Code starts here. mov #0x3, w0 mov.b wreg, count mov #0x1, w1 mov w1, x mov #0x3, w2 mov w2, y top: cp0.b count bra z, done cp w1, w2 bra nz, next inc w2, w2 mov w2, y next: cp w1, w2 bra GEU, next2 add #0x2, w1 mov w1, x next2: dec.b count bra top done: goto done: Place holder for last line of executed code end: End of program code in this file

Explanation / Answer

#include <stdio.h>
int main()
{

int x,y,count,w0,w1,w2;
w0 = 0x3;
count = w0;
w1 = 0x1;
x = w1;
w2 = 0x3;
y = w2;

while(1)
{

if(count == 0)
{
break;
}
else if(count <= 0)
{
goto next;
}
w2++;
y = w2;

next: if(w1>=w2)
{
goto next2;
}
w1 = w1 + 0x2;
x = w1;
next2: count--;
}

return 0;
}
//please upvote,,if u find the answer useful...Thanx