Logo 
Search:

Assembly Language Forum

Ask Question   UnAnswered
Home » Forum » Assembly Language       RSS Feeds

convert c to assembly

  Asked By: Rafat    Date: Apr 22    Category: Assembly Language    Views: 1505
  

Rewrite the following C-code in assembly language:

int m = 0 ;
while( m < 18)
{
if ( m == 5 || m == 9)
continue;
if( m%2==1)
printf("%d is odd\n",m); // cout<<m<<" is odd\n";
else
printf("%d is even\n",i);// cout<<m<<” is even\n";
m++;
}
2-

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Abhishek Singh     Answered On: May 23

Program to check whether the value in register is even or odd
.ORIG X3000
AND R2,R1,X0001
BRZ EVEN
LEA R0,DEF ;PRINTS ODD IF VALUE IN REGISTER R2 IS 1
PUTS
HALT

EVEN:
LEA R0,ABC ;PRINTS EVEN IF VALUE IN R2 IS 0
PUTS
HALT
ABC .STRINGZ "EVEN"
DEF .STRINGZ "ODD"
.END

 
Didn't find what you were looking for? Find more on convert c to assembly Or get search suggestion and latest updates.




Tagged: