Help needed: ConvertToBin gives unknown label error message when tested on the vm emulator

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

Help needed: ConvertToBin gives unknown label error message when tested on the vm emulator

Obij
Goodday,

Please could someone assist me? When i test my translated vm file for the Convert to Bin jack file, on the vm emulator, it gives the error: Unknown Label-Main.Convert$IF_FALSE0. I have looked at the if statements, my compiler generates and they seem ok, yet i can't resolve the error. In fact, i even generated the vm files for the converttobin using the nand2tetris compiler and copied the exact format they used for if statements and while loops, yet the error persists.

Please any assistance would be appreciated.

Thanks,
Obinna
Reply | Threaded
Open this post in threaded view
|

Re: Help needed: ConvertToBin gives unknown label error message when tested on the vm emulator

code2win
So it sounds like the 'goto $IF_FALSE0' or 'if-goto $IF_FALSE0' is referencing a label that was not inserted into the code as the vm instruction: 'label $IF_FALSE0'. Open your compiled vm file, and search for the equivalent 'label $IF_FALSE0', which, 'if-goto' or 'goto' references. make sure the label matches exactly.

So for example in my VM code for ConvertToBin, I have a line which says 'label L1', and then another line in the code reads 'if-goto L1". If I had an 'if-goto L1', without the creation of the label, with the instruction 'label L1', then it would reference a label that is not present in the code.
Reply | Threaded
Open this post in threaded view
|

Re: Help needed: ConvertToBin gives unknown label error message when tested on the vm emulator

Obij
Thanks for your fast response. I did as you said, by making sure tha the name in my complied vm file matched exactly (or was ) goto $IF_FALSE0. And when i ran the file on the vm emulator, this time the error was: unknown label -Main.convert$$IF_FALSE0
Reply | Threaded
Open this post in threaded view
|

Re: Help needed: ConvertToBin gives unknown label error message when tested on the vm emulator

WBahn
Administrator
I notice that in the first post it is "Main.Convert$IF_FALSE0" but in the second it is "Main.convert$$IF_FALSE0".

In addition to the additional $ character, the uppercase C became lowercase.

The labels your compiler generator should not begin with a $ (unless your goto labels do, too) since mangling the names with the file names is the job of the VM Translator.
Reply | Threaded
Open this post in threaded view
|

Re: Help needed: ConvertToBin gives unknown label error message when tested on the vm emulator

Obij
        Thanks everyone. I have resolved the issue. It was caused because my if statements were not generating the proper indexes for their ending labels. For example, if the ending index for a label should be 0(eg the 0 in label IF_END0), my program would generate a label with a different index, such the if statement would not have a proper matching ending label.