If you are not already doing so, you should write the VM source in the ASM output as comments. This makes it much easier to understand what you are looking at.
// push constant 17
@17
D=A
@SP
{There's more ASM here I'm not showing.}
// eq
@RET$3
D=A
@$CMP_EQ$
0;JMP
(RET$3)
// push constant 892
@892
D=A
@SP
The same code is also at previous lines 491 and 492 but code execution got pass that and did not stop there but then it is not moving beyond line 503.
The code at 491 is an unconditional jump to 502, which is also an unconditional jump to 502. The simulator is doing exactly what the code says to do.
The code at 484 looks like it puts a "true" on the stack and jumps to 502. The code at 493 looks like it puts "false" on the stack and executes directly to 502.
The code at 504 is the beginning of the code for "push constant 57" so you are at the end of all the eq/lt/gt VM commands.
This is strange because if the generated code for gt ends with this infinite loop, it ought to be hung after the the first gt, not the last. This makes me think of two possible problems:
1) Are you using the same label names in every compare command translation? If so, the CPUEmulator's assembler will always jump to the
last label with the same name.
2) Why is there an infinite loop at the end of the gt code? Is it accidentally left over from earlier testing?
Note: My code sample above shows my translation for eq doing an assembly language call to a helper routine that contains all the code required to actually do the eq command. This way there is only one copy of the long ASM code for eq. The $CMP_EQ$ routine looks like
($CMP_JEQ$) // EQ compare common code
@R13
M=D
{All to code that is needed for the eq command.}
@R13
A=M
0;JMP
--Mark