Question: I've been using the Pep 8 Assembler vers. 8 . 1 . 3 and I've been having trouble trying to convert this java code to
I've been using the Pep Assembler vers. and I've been having trouble trying to convert this java code to assembly code. This is the java code
Translate into Pepassembly language with equates and methods to call. no python or java responses please
import java.util.Scanner;
public class CW
public static void mainStringargs
Scanner scnr new ScannerSystemin;
int x scnrnextInt;
printStarsx;
int y scnrnextInt;
printRangexy;
int z scnrnextInt;
inRangexyz;
public static void printStarsint a
for int k; ke && g f
System.out.printlnin range";
else
System.out.printlnoutside range"
This is the assembly code. So far, I am capable of printing out the stars to correspond with the input from the prntstar method, but I have been having trouble trying to get the correct outputs from the prntrnge method and inrange method and putting them into the main method
Br main
n: equate ;#c
n: equate ;#d
n: equate ;#d
msg: ASCII x :outside range
msg: ASCII x inside range
prntstar: lda i
loop: CPA n s
BRGE endstar
Charo i
adda i
BR loop
endstar: charo
i
ret
prntrnge:lda i
CPA n s
BRGE endRge
deco n i
CPA n s
adda i
endRge: charo
i
ret
inrange: lda s
sta n s
CPA n s
BRGE endrnge
lda n s
sta n s
CPA n s
endrnge: ret
num: equate ;#d
num: equate ;#d
main: subsp i;allocate #num#num
deci num s
LDA num s
sta s
subsp i ; push #num
call prntstar
addsp i ; pop #num
lda s
sta s
lda s
sta s
subsp i ;push #num
stro msg d
call prntrnge
addsp i ;pop #num
lda s
sta s
lda s
sta s
subsp i ;push #num
stro msg d
call inrange
addsp i; deallocate #num#num
stop
end
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
