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;
}
The given program shows the pep assembly code:
.LC0:
.string "Pick a number 0..3: "
.LC1:
.string "%d"
.LC2:
.string "Too low"
.LC3:
.string "Right on"
.LC4:
.string "Too high"
main:
push rbp
mov rbp, rsp
sub rsp, 16
mov edi, OFFSET FLAT:.LC0
mov eax, 0
call printf
mov eax, DWORD PTR [rbp-4]
mov esi, eax
mov edi, OFFSET FLAT:.LC1
mov eax, 0
call __isoc99_scanf
cmp DWORD PTR [rbp-4], 3
je .L2
cmp DWORD PTR [rbp-4], 3
jg .L3
cmp DWORD PTR [rbp-4], 1
jg .L4
cmp DWORD PTR [rbp-4], 0
jns .L5
jmp .L3
.L4:
cmp DWORD PTR [rbp-4], 2
je .L6
jmp .L3
.L5:
mov edi, OFFSET FLAT:.LC2
mov eax, 0
call printf
jmp .L3
.L6:
mov edi, OFFSET FLAT:.LC3
mov eax, 0
call printf
jmp .L3
.L2:
mov edi, OFFSET FLAT:.LC4
mov eax, 0
call printf
.L3:
mov edi, 10
call putchar
mov eax, 0
leave
ret
ranslate the following C program to Pep/9 assembly language. Note: Your jump table must have exactly...
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; }
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; }
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 <stdio.h> int main() { int number; scanf(“%d”,&number ); if (number <0) { number =- number; } printf ("%d", number); return0; }
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;}
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 !
please rewrite or convert this C program into Assembly language and please make a notice of which function is which! #include <stdio.h> #include <stdlib.h> void printMonthYear(int mon,int year); void printDaysOfWeek(); void printDays(int mon,int year); int getFirstDayOfMonth(int mon, int year); int getNumOfDaysInMonth(int mon, int year); int main(void) { int mon=-1; int year= -1; printf("Month : "); fflush(stdout); scanf("%d",&mon); if(mon < 1|| mon > 12){ printf("Invalid month >.<!: %d ! Must be between 1 and 12\n",mon); return 1; } printf("Year...
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 the programming to be in language C. I am using a program called Zybook Prompt: Write a statement that outputs variable numObjects. End with a newline. Given: #include <stdio.h> int main(void) { int numObjects; scanf("%d", &numObjects); return 0; } What I did so far. I am not sure if its right tho? #include <stdio.h> int main(void) { int numObjects; scanf("%d", &numObjects); printf(" num Objects is "); printf("%d\n", userAge); return 0; }
The following code is a C Program that is written for encrypting and decrypting a string. provide a full explanation of the working flow of the program. #include <stdio.h> int main() { int i, x; char str[100]; printf("\n Please enter a valid string: \t"); gets (str); printf ("\n Please choose one of the following options: \n"); printf ("1 = Encrypt the given string. \n"); printf("2 = Decrypt the entered string. \n"); scanf("%d",&x); // using switch case statements switch (x) {...