Project 12: MemoryDiag test [v2.5]

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

Project 12: MemoryDiag test [v2.5]

bupjae
1. Between out[0] = 21 and out[0] = 50, allocated size of Array A is 20. However, checkOverlap on out[0] = 32 and out[0] = 42 tests Array A as if allocated size is 3.

        let out[0] = 20;
        let a = Memory.alloc(20);
        let out[3] = a;                     // RAM[17003] = block address

// ... more test code ...

        let out[0] = 32;
        do Main.checkOverlap(b, 3, a, 3);
        let out[0] = 33;

// ... more test code ...

        let out[0] = 42;
        do Main.checkOverlap(c, 500, a, 3);
        let out[0] = 43;

2. Some out[0] code is used more than once. (code 70, 71, 72)
Primary prupose of out[0] is to distinguish where the test is failed. Therefore I assumed that duplicated code is not intended.

        // Deallocate blocks 'b' and 'c'.

        let out[0] = 70;
        do Memory.deAlloc(c);

        let out[0] = 71;
        do Memory.deAlloc(b);
        let out[0] = 72;

        // Test that deallocated blocks are placed on the free list and can
        // be reused.

        let out[0] = 70;
        let a = Memory.alloc(8000);
        let out[7] = a;                     // RAM[17007] = block address

        let out[0] = 71;
        do Main.checkRange(a, 8000);

        let out[0] = 72;
        do Memory.deAlloc(a);
Reply | Threaded
Open this post in threaded view
|

Re: Project 12: MemoryDiag test [v2.5]

WBahn
Administrator
I can't tell what the problem is or what your question is.

Could you provide more detail, please?
Reply | Threaded
Open this post in threaded view
|

Re: Project 12: MemoryDiag test [v2.5]

dolomiti7
This post was updated on .
In reply to this post by bupjae
I think you are right on the first point. This is referring to project/12/MemoryTest/MemoryDiag/Main.jack

The overlap checks should be done with a size of 20 for a:
...
do Main.checkOverlap(b, 3, a, 20);
...
do Main.checkOverlap(c, 500, a, 20);
...

I have attached a corrected version, maybe the nand2tetris team will include it into their repository:
Edit: see post below

Main.jack (project/12/MemoryTest/MemoryDiag/Main.jack)

Regarding the second point, it looks to me intentional.

The idea was apparently that out[0] (e.g. memory address [17000]) contains an error code depending on where the test fails. Though this has not been properly documented. If [17000]==100 at the end of the program, everything was alright. For every other value in [17000], you can look up in Main.jack at which point the test failed.

Reply | Threaded
Open this post in threaded view
|

Re: Project 12: MemoryDiag test [v2.5]

dolomiti7
Sorry, I misread your second point. I have corrected this now as well. The error codes while re-allocating free blocks are now in the range of 80 to 85.

Corrected file:
Main.jack
(project/12/MemoryTest/MemoryDiag/Main.jack)

Reply | Threaded
Open this post in threaded view
|

Re: Project 12: MemoryDiag test [v2.5]

bupjae
Thanks for looking this issue.

It would be good if the next version of toolkit includes this fix.
(Although I'm not sure when the last update of toolkit is...)
Reply | Threaded
Open this post in threaded view
|

Re: Project 12: MemoryDiag test [v2.5]

bupjae
One more point: it seems that "Broken Memory.jack fails (deAlloc() does not recycle memory blocks):" in "MemoryDiag/README.html" also should be changed to RAM[17000] = 83