Question

Translate the following C program to Pep/9 assembly language. #include <stdio.h> int main() {     int...

Translate the following C program to Pep/9 assembly language.
#include <stdio.h>
int main() {
    int number;
    scanf("%d", &number);
    if (number % 2 == 0) {
        printf("Even\n");
    }
    else {
        printf("Odd\n");
    }
    return 0;
}

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

SOLUTION-

I have solve the problem in pep9 assembly code with comments and screenshot for easy understanding :)

CODE-

BR       main

number: .EQUATE    int number       ;local variable #2d

main :

            SUBSP 2,i           ;push #number

           DECI number,s    ;scanf("%d", &number) (get number)

           LDWA number,s    ; if (number %2 == 0) (check if number %2 is zero)

           BRGE elseIf

          STRO print1,d     ;printf("Even\n")

       BR     endIf

elseif:

          STRO print2 , d    ;printf("Odd\n")

endIf: ADDSP 2,i    

          STOP

print1 :      .

          .ASCII "Even\n\x00"

Print1:

    .ASCII "Odd\n\x00"

.END    

IF YOU HAVE ANY DOUBT PLEASE COMMENT DOWN BELOW I WILL SOLVE IT FOR YOU:)
----------------PLEASE RATE THE ANSWER-----------THANK YOU!!!!!!!!----------

Add a comment
Know the answer?
Add Answer to:
Translate the following C program to Pep/9 assembly language. #include <stdio.h> int main() {     int...
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
  • Translate the following C program to Pep/9 assembly language. #include <stdio.h> const int limit = 5;...

    Translate the following C program to Pep/9 assembly language. #include <stdio.h> const int limit = 5; int main() { int number; scanf("%d",&number); while (number < limit){ number++; printf("%d",number); } return 0; }

  • Hello guys ! Could you let me know about this ?? Translate the following C program...

    Hello guys ! Could you let me know about this ?? Translate the following C program to Pep/9 assembly language. #include <stdio.h> int main() { int number; scanf("%d", &number); if (number % 2 == 0) { printf("Even\n") } else { printf("Odd\n"); } return 0; } Thank you !

  • Translate the following C program to Pep/9 assembly language. It multiplies two integers using a ...

    Translate the following C program to Pep/9 assembly language. It multiplies two integers using a recursive shift-and-add algorithm. mpr stands for multiplier and mcand stands for multiplicand. A recursive integer multiplication algorithm #include <stdio.h> int times(int mpr, int mcand) {    if (mpr == 0) {       return 0;    }    else if (mpr % 2 == 1) {       return times(mpr / 2, mcand * 2) + mcand;    }    else {       return times(mpr / 2, mcand * 2);    } } int main() {    ...

  • Translate the High order language program to assembly language and generate PEP9 assembly language code. #include...

    Translate the High order language program to assembly language and generate PEP9 assembly language code. #include <stdio.h> int main() { int number; scanf(“%d”,&number ); if (number <0) { number =- number; } printf ("%d", number); return0; }

  • ranslate the following C program to Pep/9 assembly language. Note: Your jump table must have exactly...

    ranslate the following C program to Pep/9 assembly language. Note: Your jump table must have exactly four entries, but your program must have only three case symbols and three cases. #include <stdio.h> int main () { int guess; printf(“Pick a number 0..3: “); scanf(“%d”, &guess); switch (guess) { case 0: case 1: (printf (“Too low”); break; case 2: printf(“Right on”); break; case 3: printf(“Too high” ); } printf(“\n”); return 0; }

  • Convert C++ language to PEP/8 assembly language

    Convert this C++ language to PEP/8 assembly language. #include <stdio.h> int main(void) {        int num, rem;     printf("Enter a number: ");     scanf("%d", &num);     printf("Roman numerals: ");             while(num != 0)     {         if (num >= 1000)       // 1000 - m         {            printf("m");            num -= 1000;         }         else if (num >= 900)   // 900 -  cm         {            printf("cm");            num -= 900;         }                 else if (num >= 500)   // 500 - d         {                       printf("d");            num -= 500;         }         else if (num >= 400)   // 400 -  cd         {            printf("cd");            num -= 400;         }         else if (num >= 100)   // 100 - c         {            printf("c");            num -= 100;                                }         else if (num >= 90)    // 90 - xc         {            printf("xc");            num -= 90;                                                       }         else if (num >= 50)    // 50 - l         {            printf("l");            num -= 50;                                                                              }         else if (num >= 40)    // 40 - xl         {            printf("xl");                       num -= 40;         }         else if (num >= 10)    // 10 - x         {            printf("x");            num -= 10;                    }         else if (num >= 9)     // 9 - ix         {            printf("ix");            num -= 9;                                  }         else if (num >= 5)     // 5 - v         {            printf("v");            num -= 5;                                              }         else if (num >= 4)     // 4 - iv         {            printf("iv");            num -= 4;                                                                     }         else if (num >= 1)     // 1 - i         {            printf("i");            num -= 1;                                                                                            }     }     return 0;}

  • Write an assembly language program that corresponds to the following C program: int width; int length;...

    Write an assembly language program that corresponds to the following C program: int width; int length; int perim; int main () { scanf ("%d%d", &width, &length); perim = (width + length) * 2; printf ("width = %d\n", width); printf ("length = %d\n\n", width); printf ("perim = %d\n", perim); return 0; }

  • i need flowchart for the following c code #include <stdio.h> int main() {     int n,...

    i need flowchart for the following c code #include <stdio.h> int main() {     int n, i, sum = 0;     printf("Enter an integer: ");     scanf("%d",&n);     i = 1;     while ( i <=n )     {         sum += i;         ++i;     }     printf("Sum = %d",sum);     return 0; }

  • All in C please~ #1 Consider this program: #include <stdio.h> int main () { /* main...

    All in C please~ #1 Consider this program: #include <stdio.h> int main () { /* main */ constint constant1 = 10, constant2 = 20, constant3 = 14; int input_value; char current_truth; printf("What is the input value?\n"); scanf("%d", &input_value); current_truth = input_value > constant1; printf("current_truth = %d\n", current_truth); current_truth = current_truth && (input_value < constant2); printf("current_truth = %d\n", current_truth); current_truth = current_truth && (input_value == constant3); printf("current_truth = %d\n", current_truth); } /* main */ What is the output of this program...

  • 6. Consider the following program: #include <stdio.h> main() { int a,b,c,d ; a=0; while (1) {...

    6. Consider the following program: #include <stdio.h> main() { int a,b,c,d ; a=0; while (1) { printf("%d\n", a); printf("Input? "); scanf("%d",&c); if (c == 0) break; d=0; for (b=1; b<=c; b++) if (c%b == 0) d++; if (d == 2 11 C == 1) a=a+c; } } What does this program do? Rewrite the code, organizing it using sound principles. Include comments and redo variable names and indentation. Use multiple functions, blocks, and/or preprocessing if you deem it necessary.

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