Question: Write a Pep / 9 assembly language program that uses recursive function calls to convert a series of positive decimal integer input values into octal

Write a Pep/9 assembly language program that uses recursive function calls to convert a series of positive decimal integer input values into octal notation. The program will convert all input values entered by the user one at a time until the user enters a zero or a negative number, at which point the program should stop. The following C program shows how this may be accomplished. Your program should produce exactly the same output as this sample C program:
```
#include
int num;
void convert(int n){
int result, remain;
result = n/8;
remain = n - result*8;
if (result >0){
}
convert(result);
printf("%d", remain);
}// end of convert
int main(){
printf("?");
scanf("%d", &num);
while (num >0){
printf("%d decimal =", num);
convert(num);
printf(" octal
");
printf("?");
scanf("%d", &num);
}// end while
return 0;
}// end of main
``` To save you time, I have converted the main() function for the C program shown above into Pep/9 Assembly language. You may use this as a starting point for your program if you wish. Note that you will have to replace the comments below with code that pushes and pops various values onto/off the run-time stack.
```
main: STRO prompt, d
DECI num, d
while: LDWA num,d
CPWA 0, i
BRLE endwh
DECO num, d
STRO msg1, d
;
```
```
insert code that pushes storage for the
parameter onto the run-time stack for
convert(num);
;------------------------------------------------
;
CALL convert
;
;----------------------------------------;
; the stack
;-------------------------------------------
STRO msg2, d
;
STRO prompt, d
DECI num, d
BR while
endwh: \stackrel{STOP}{S}\{
;
prompt: .ASCII "?\x00"
msg1: .ASCII " decimal =\x00"
msg2: .ASCII " octal
\x00"
.END
```
Copy this code and then paste it into the "Source Code" window of the Pep/9 simulator to get a head-start on this assignment. HINT: be sure to have unique names for parameters and local variables in your functions.
Write a Pep / 9 assembly language program that

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!