Problem with getMap in Output

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

Problem with getMap in Output

bss1234
When I try to assign the return array from Output.getMap() the VM emulator gives and error:

'That' segment must be in the Heap or Screen range in Output.printChar.15

I also tried to bypass the function and directly assign it from the charMap array, but I get the same error.
 
function void printChar(char c) {
    var Array cm;
   
    let cm = Array.new(11);
    let cm = Output.getMap(c);
    return;
    }
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with getMap in Output

cadet1620
Administrator
bss1234 wrote
When I try to assign the return array from Output.getMap() the VM emulator gives and error:

'That' segment must be in the Heap or Screen range in Output.printChar.15

I also tried to bypass the function and directly assign it from the charMap array, but I get the same error.
 
function void printChar(char c) {
    var Array cm;
   
    let cm = Array.new(11);
    let cm = Output.getMap(c);
    return;
    }
Sounds like a problem with Output.getMap().  VM code from the JackCompiler that uses that is usually an array indexing operation.

You can email me your Output.Jack and I'll take a look at it.

--Mark


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with getMap in Output

bss1234
I found the issue, I needed to load the Main file directly into the VM Emulator and not the test directory. I now see a nice "B" on the screen.

I'm using Mac OS X Version 10.11.3 for reference.

Thank you for looking at the file.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with getMap in Output

cadet1620
Administrator
bss1234 wrote
I found the issue, I needed to load the Main file directly into the VM Emulator and not the test directory. I now see a nice "B" on the screen.
If you directly load the Main.vm file, the VM Emulator will not load the Output.vm in the OutputTest directory; it will use the builti-in Output class.

When you load a directory into the VM Emulator, it loads all the VM files in that directory and only uses the built-ins for classes that are not found in the loaded VM files.

I'll take a look at source you just sent me and see what's causing the segment error.

--Mark
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with getMap in Output

bss1234
Well that explains why the rest of the functions past the tests on the first try :)

Thanks for the followup email, calling Output.initMap() in init solved the issue.

Now lets see how well my code works... :)
Loading...