Fill.asm works in emulator, fails test

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

Fill.asm works in emulator, fails test

greebo777
The Fill.asm works when I run it in the CPU emulator program, but fails the automatic test -when it tries to turn the screen white.

I'm a little stuck. Any idea why that might be?
Reply | Threaded
Open this post in threaded view
|

Re: Fill.asm works in emulator, fails test

WBahn
Administrator
Post you code and we can take a look -- we can delete the code when we're done.
Reply | Threaded
Open this post in threaded view
|

Re: Fill.asm works in emulator, fails test

greebo777
(RESTART)
//set pointer i=0
@i
M=0


//set n, as in number of screen registers
@8191
D=A
@n
M=D

//set screen to be stored in address value
@SCREEN
D=A
@ADDR
M=D



//checking if a key is pressed
@KBD
D=M


//if KBD=0, go to LOOPWHITE
@LOOPWHITE
D; JEQ


//if KBD not 0, go to LOOPBLACK
@LOOPBLACK
D; JNE



// if KBD=0, then the screen is white
//going through the screen and turning it white

(LOOPWHITE)
// if i==n goto RESTART
@i
D=M
@n
D=D-M
@RESTART
D; JEQ

//set RAM [screen +i)= 0 to make screen white

@ADDR
A=M     //pointer to the correct row
M=0    // setting the value of that row to zero so that the screen is white


//incrementing i
@i
M=M+1


//incrementing to next register
@ADDR
M=M+1


@LOOPWHITE
0; JMP


// if KBD not 0, then the screen is black
//going through the screen and turning it white

(LOOPBLACK)
// if i==n goto END
@i
D=M
@n
D=D-M
@RESTART
D; JEQ


//set RAM [screen +i)= -1 to make screen black
@ADDR
A=M       // pointer to the correct row
M=-1    // setting the value of that row to -1 so that the screen is black


//incrementing i
@i
M=M+1

//incrementing to next row
@ADDR
M=M+1

@LOOPBLACK
0;JMP

@RESTART
0;JMP
Reply | Threaded
Open this post in threaded view
|

Re: Fill.asm works in emulator, fails test

WBahn
Administrator
I haven't forgotten about you -- just have some other things that have to take priority so I can only answer the really quick questions right now.
Reply | Threaded
Open this post in threaded view
|

Re: Fill.asm works in emulator, fails test

WBahn
Administrator
One thing I noticed is that you claim there are 8191 screen registers. There are 8192. Be sure that you are getting both the first and the last word worth of pixels set or cleared. The test script looks specifically at these extremes.
Reply | Threaded
Open this post in threaded view
|

Re: Fill.asm works in emulator, fails test

greebo777
I changed it to 8192, but it still breaks in the test...
Reply | Threaded
Open this post in threaded view
|

Re: Fill.asm works in emulator, fails test

WBahn
Administrator
HOW does it break the test?

What error message are you getting?

How are you creating your .hack file?

Reply | Threaded
Open this post in threaded view
|

Re: Fill.asm works in emulator, fails test

greebo777
I've created it both using the "binary" option in the CPU emulator and  using the assembler.

The error is "Comparison failure at line 2"

Sorry to be a bother, I'm completely new to using code for anything, so it's probably something obvious that I'm missing
Reply | Threaded
Open this post in threaded view
|

Re: Fill.asm works in emulator, fails test

WBahn
Administrator
This post was updated on .
The binary option in the CPU Emulator?

In the ROM Format options?

That doesn't create a .hack file from your .asm file. That merely controls how the contents that are currently loaded in the ROM are displayed.

The script is always going to load the ROM from the fill.hack file that is on disk each time it is run.

You can change the script to load the .asm file instead and see what that does. You need to change the script using a text editor and save it -- you can't do that from within the CPU Emulator.

You want to use the assembler to assemble the file and be sure to save it to disk after you assemble it.

Look in the .out and the .cmp files at line 2 and see which memory location doesn't match. That should give you a hint as to how to proceed.