[SOLVED] Pong.asm (@ponggame.0) Comparison failure - all programs still run fine

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

[SOLVED] Pong.asm (@ponggame.0) Comparison failure - all programs still run fine

mijuraut
This post was updated on .
Hey, and thank you for the wonderful course.

I got my assembler working with all 4 test programs. My assembled test programs, including pong.hack, run just fine with CPUEmulator.

Still, I guess I'm having a problem assembling the Pong.asm. The comparison between my assembled Pong.hack file to the one given by the default assembler gives following Comparison failure (@ponggame.0):

 - provided assembler: 0000 0000 0001 0000    (16 in decimal)
 - my assembler: 0000 0000 0101 1011   (91 in decimal)

"@ponggame.0" is at line 4712 of the pong.asm. I can't figure out what's wrong here. Has anyone encountered this problem, or have an insight to what is going on?
Reply | Threaded
Open this post in threaded view
|

Re: Pong.asm (@ponggame.0) Comparison failure - all programs still run fine

A_Random_Person
I'm having a similar problem, but my assembler thinks ponggame.0 is 2 variables.
Reply | Threaded
Open this post in threaded view
|

Re: Pong.asm (@ponggame.0) Comparison failure - all programs still run fine

ivant
In reply to this post by mijuraut
mijuraut wrote
"@ponggame.0" is at line 4712 of the pong.asm. I can't figure out what's wrong here. Has anyone encountered this problem, or have an insight to what is going on?
ponggame.0 isn't defined anywhere in Pong.asm, so it's a variable symbol. Quoting from chapter 6:
Variable Symbols Any symbol Xxx appearing in an assembly program that is
not predefined and is not defined elsewhere using the (Xxx) command is treated as
a variable. Variables are mapped to consecutive memory locations as they are first
encountered, starting at RAM address 16 (0x0010).
Reply | Threaded
Open this post in threaded view
|

Re: Pong.asm (@ponggame.0) Comparison failure - all programs still run fine

ivant
In reply to this post by A_Random_Person
A_Random_Person wrote
I'm having a similar problem, but my assembler thinks ponggame.0 is 2 variables.
Again, quoting from chapter 6:
Constants and Symbols Constants must be non-negative and are written in decimal
notation. A user-defined symbol can be any sequence of letters, digits, underscore (_),
dot (.), dollar sign ($), and colon (:) that does not begin with a digit.
As you can see, the dot is an accepted character, which you maybe have missed. Check your parser code and see if it properly handles it. Note, that if you are using regular expressions, dot has a special meaning there and has to be escaped.
Reply | Threaded
Open this post in threaded view
|

Re: Pong.asm (@ponggame.0) Comparison failure - all programs still run fine

mijuraut
In reply to this post by mijuraut
Okay this is finally explained in module 1 in next course (Nand2Tetris part 2), specifically in unit 1.5: VM Implementation: Memory Segments.

Say we have Jack source code (Ponggame.jack), where a static variable x is declared and probably used to store some value. The compiler generates VM code file ponggame.vm, where we then have a command like "pop static 0". The VM translator (doing the .vm->.asm conversion) produces the line @ponggame.0. This is a static variable reference.

Now the way the Hack assembler should work is that all static variables should be stored in RAM[16], ..., RAM[255]. In pong.asm, the line @ponggame.0 is the first reference to a static variable encountered in the .asm files. Thus the provided assembler stores it in RAM[16].