(This is a copy of my question on coursera discussion forums - I'm trying to get all the help I can)
All my local .cmp and .out files are the same.
My arithmetic grader tests are all passed - so the problem shouldn't be with loading / parsing / producing output.
Still, memory access tests fail. I didn't stop there and by using "debug" in my lang.txt got the file which is used in grader:
push constant 111
push constant 333
push constant 888
pop static 8
pop static 3
pop static 1
push static 3
push static 1
sub
push static 8
add
push constant 3030
pop pointer 0
push constant 3040
pop pointer 1
push constant 32
pop this 2
push constant 46
pop that 6
push pointer 0
push pointer 1
add
push this 2
sub
push that 6
addOnline grader says that there is a difference between .out and .cmp files:
PointerTest/PointerTest.out
|RAM[256]| RAM[3] | RAM[4] |RAM[3032|RAM[3046|
| 6070 | 3030 | 3040 | 0 | 0 |
PointerTest/PointerTest.cmp
|RAM[256]| RAM[3] | RAM[4] |RAM[3032|RAM[3046|
| 6084 | 3030 | 3040 | 32 | 46 |Then I translated it locally and watched its processing line by line. In the end my results were just the same to the results in .cmp (so locally my VMTranslator.py works as expected):
I know that it should be Stack[256] = 6084, not Stack[257] but it seems to be a mistake, because on line 11 in .vm program shown before we just add to get 1110 (seen in the first line of the stack). And then we move on to the next lines and work on them until the end of the program.
So it seems that my program output locally is:
|RAM[256(257)]| RAM[3] | RAM[4] |RAM[3032|RAM[3046|
| 6084 | 3030 | 3040 | 32 | 46 |I don't understand why my solution works differently locally and online. Would appreciate any help.