local to LCL conversion and error

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

local to LCL conversion and error

twitu
I am converting any push or pop related to local to @LCL asm command. But the CPUEmulator and Assembler give "Expression expected error" at the @LCL line. I have rechecked the documents, LC is supposed to be a register mapping to memory address RAM[1] according to project 6.
What could be the issue here ?
Reply | Threaded
Open this post in threaded view
|

Re: local to LCL conversion and error

cadet1620
Administrator
twitu wrote
the CPUEmulator and Assembler give "Expression expected error" at the @LCL line. I have rechecked the documents, LC is supposed to be a register mapping to memory address RAM[1] according to project 6.
What could be the issue here ?
Check the line before the @LCL.

It is common for errors to be reported on the line following the actual error location.  For instance, "expression expected" might mean that the previous line ended with an '=' and the parser was looking for the computation part of the instruction.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: local to LCL conversion and error

twitu
This is part of the code generated while converting BasicLoop.vm using my own VMtranslator.

@256
D=A
@SP
M=D
@0
D=A
@SP
A=M
M=D
@SP
M=M+1
@SP
AM=M-1 // I want this to happen updating stack pointer and address value simultaneously
D=M
@LCL // line number 15 where expression expected error is showing

I can't find any syntactic errror
Reply | Threaded
Open this post in threaded view
|

Re: local to LCL conversion and error

cadet1620
Administrator
Your posted code sample assembles without error for me. Whatever the problem is, it was corrected when the code was reformatted in posting.

Look for strange characters in the file, for instance '\0' characters in the file can cause this error.

If you can't find the problem, upload the failing file so that we can see it without it being mangled by reformatting. (More button)

What OS are you using?

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: local to LCL conversion and error

twitu
BasicLoop.asm
This is the file. I am using Ubuntu 16.04 and using Java in IntelliJ to code the VMtranslator. Also the code for project 7 worked perfectly so there shouldn't be a problem with the code.
Error in CPU emulator
Reply | Threaded
Open this post in threaded view
|

Re: local to LCL conversion and error

twitu
I think I have found the error. Turns out I have made a blunder in terms of decoding.
Taking A=A+1 to be possible I extended it to A=A+0 and then to A=A+x for any x where x is given as "pop local x".
Reply | Threaded
Open this post in threaded view
|

Re: local to LCL conversion and error

cadet1620
Administrator
Yes, A=A+0 is the problem.

Note that even if A=A+# worked, that isn't what you would want in pop local #.

(edit:  at least not immediately after @LCL)

--Mark