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() {
int n, m;
scanf("%d %d", &n, &m);
printf("Product: %d\n", times(n, m));
return 0;
}
thw following program will multiply two integers in assembly language :-
datasegment
a db 09h
b db 02h
c dw ?
data ends
code segment
assume cs:code, ds:data
start:
mov ax,data
mov ds,ax
mov ax,0000h
mov bx,0000h
mov al,a
mov bl,b
mul b
mov c,ax
int 3
code ends
end start
#include<stdio.h>
int myAge;
void putNext(int age)
{
int nextYr;
nextYr = age + 1;
printf("%d\n",age);
printf("Age next Year%d\n",nextYr);
}
int main()
{
scanf("%d",&myAge);
putNext(myAge);
putNext(64);
return 0;
}
#include <stdio.h>
void stars()
{
int j, k;
for (j=1 ; j<=5 ; j++)
{
for (k = 1 ; k <= j; k++)
{
printf ("*");
}
printf ("\n");
}
}
int main()
{
stars();
return 0;
}
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. #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; }
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 !
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; }
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;}
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; }
Can anyone help to solve this MIPS assembly language problem? Please help. Translate the fowlowwing C code to MIPS assembly language. void main() { int i, sum, begin, end; for(i=0; i < 5; i++){ scanf(“%d, %d”, &begin, &end); sum = accum_range(begin, end); printf(“sum[%d: %d] = %d\n”, begin, end, sum); } int accum_range(int a, int b){ return accum (b) - accum(a); } int accum(int final) { int sum = 0; for (int I = 1; I <= final; I = I...
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; }
(10 points) Translate the following algorithm into assembly language. IF 65 < X THEN X = 9+(X^2) ELSE X = - Y 3. (10 points) Translate the following algorithm into assembly language. X=0 FOR K = I TO 5 X=X+5 END_FOR 4. (10 points) Translate the following algorithm into assembly language. X=0 Y=5 Z=5 WHILE Z = 5 X=X+1 Y=Y-1 Z=X+Y 2. (10 points) Translate the following algorithm into assembly language. IF65 < X THEN X = 9t(X^2) ELSE X...