How might i translate the Java Code below in PseudoCode for assembly language using the Motorola 68000:
if(x > y && y < 100) {
x++;
y--;
} // end if
else if(x < y) {
x--;
y++;
} // end else if
else {
x=0;
y=0;
} // end else
I think that i might be on the right track just not sure:
IF:
if(x <= y) goto end if
if(y <= 100) goto end if
x++;
y--;
goto IF
ELSE IF:
if(x >= y) goto end else if
x--;
y++;
goto ELSE IF
x = 0;
y = 0;
goto DONE
DONE:
There is no standard pseudo code format. It’s very informal. The point is to show the logical structure of the code clearly without getting bogged down in syntax.
If you’ve been told to pseudo code for assembly, I’d assume that you’d want to break down the java code into, roughly, what it would look like in 68k assembly. This seems to be what you’ve started here, but you’ve made a few mistakes.
First, you mean
y >= 100.Your first two ifs should
goto ELSE IF, notEND IF.There is no reason to
goto IF. You should only be there once. The conditions are not supposed to be checked more than once, according to the java code. Yourgoto IFshould probably be agoto DONE, because it is only executed if the fist condition was true, and this means no other condition will be evaluated.You need a label for the else condition. This is what you should be going to
if x >= y.You don’t want to backtrack to ELSE IF as you do with
goto ELSE IF. You probably meant togoto DONE.Your final
goto DONEis redundant. If you had left it out, it would have gone toDONEanyway, seeing as that is the next instruction.This is roughly what it should look like (Note that the IF label is never referenced. It is just there for looks.):