fill.asm issues - help appreciated

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

fill.asm issues - help appreciated

pwolf
This post was updated on .
I cant get my fill.asm to work but I do not know what I am doing wrong, no doubt something stupid as usual!  
I get the error "In line 16 expression expected"   I don't think I'm doing anything too different from what I was doing for the first exercise mult.asm , but yet I cant get it working at all. I shall re-read the chapter but hopefully someone here can help me out!  my code is below. Commented with what I think I'm doing, in effort to facilitate my feeble mind!

Possible spoilers for those that haven't yet solved this..


        @screen       // variable to hold the start location of the screen
        D = 16384
        M = D    // set to start value of 16384 , the first 16 pixels of the screen
        @screenEnd   // variable to hold the end value of the screen
        D = 24575
        M = D      // set to end value of 24575, the last 16 pixels of the screen

(LOOP)          




deleted most of the code
Reply | Threaded
Open this post in threaded view
|

Re: fill.asm issues - help appreciated

cadet1620
Administrator
pwolf wrote
        @screen       // variable to hold the start location of the screen
        D = 16384
        M = D    // set to start value of 16384 , the first 16 pixels of the screen
Please don't post complete program sources to the forum. Just post a few lines around where the error occurs. Please edit your post to remove all but the first few lines of code.

Your error is that D = 16384 is not a legal C-command. The only constants that can be assigned with = are -1, 0 and 1.

(Also note that there is a built-in symbols SCREEN and KEYBOARD for 16384 and 24576.)

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: fill.asm issues - help appreciated

pwolf
I see! then how do I set screenEnd to 24575?  
Reply | Threaded
Open this post in threaded view
|

Re: fill.asm issues - help appreciated

pwolf
Am I doing this right now? i managed to copile it but im not sue if there may be an easier way?

        @24575
        D = A
        @screenEnd   // variable to hold the end value of the screen
        M = D      // set to end value of 24575, the last 16 pixels of the screen
Reply | Threaded
Open this post in threaded view
|

Re: fill.asm issues - help appreciated

cadet1620
Administrator
There is no easier way to set a variable to an arbitrary constant. In this case it might be easier, and produce smaller code, just to use the constant when you need it.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: fill.asm issues - help appreciated

pwolf
I've been stuck on this for hours now, i found several problems with my code but after fixing them it still doesn't work... is the following invalid?


@count    
        D = M        // D =  count value  
        @D
        M =  -1        // set current 16 pixels to black

Reply | Threaded
Open this post in threaded view
|

Re: fill.asm issues - help appreciated

cadet1620
Administrator
pwolf wrote
I've been stuck on this for hours now, i found several problems with my code but after fixing them it still doesn't work... is the following invalid?


@count    
        D = M        // D =  count value  
        @D
        M =  -1        // set current 16 pixels to black
"@D" references a symbol named D, so a RAM variable is allocated to and its address is set into the A register.

If what you want to do is set the A register to the value in the D register, you want "A=D". In this case, you can load M directly into A using "A=M".

If you want to, you may email me your code and I'll be happy to return comments.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: fill.asm issues - help appreciated

pwolf
I seem to be having trouble with the emulator, as sometimes it works and other times it doesn't... i've gotten the screen completely black but other times it doesn't, with program flow it works more often. test fails, and one time it would fill the first 16 pixels and clear them when i press and let go of a key... not sure what is worng to be hoenst

but even when its black it fails to return to white, which i dont understand..