Question

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.nclude p24Hxxxx.inc global_reset ; Uninitialized data section .space 2 .space 2 count: space 1 Variables start at location 0x0800 Allocating space (two bytes) to variable. Allocating space (two bytes) to variable. x: ; Allocating space (one byte) to variable. ; Code Section in Program Memory ; start f Code section ; first instruction located atreset label ; Initialize the Stack Pointer .text reset: mov # SPL IM init, wo mov WO, SPLIM ; Initialize the stack limit register SP init set to be after all cated data User Code starts here. mov #0x3, wo mov #0x1, w! mov wl, x mov #0x3, w2 mov w2, y top: cp0.b count bra z, done bra nz, next inc w2, w2 mov w2, y next: cp wl, 2 bra GEU, next2 add #0x2, w! mov wl, x next2: dec.b count 4| P a g bra top done: goto donePlace holder for last line of executed code ; End of program code in this file

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#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

Add a comment
Know the answer?
Add Answer to:
Convert the following assembly language program into a C program: *Update: The variables are initialized, in...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT