Monday, August 20, 2012

Filling up the Screen and erasing it


Next project is to get the screen to fill black with a key press. This should be a little easier. This project wasn’t easier but it also wasn’t harder. After getting the screen to fill with key press and erase with the key up I had a problem checking for memory boundaries. As I was trying to figure it out I decided to post on the forums and ask for help. This is what I typed out

I made the Fill.asm program and it will fill the screen to the bottom with black and if the key is let go it will erase all the black. The Issue is that it will keep going passed the screen memory and on erase it will go all the way passed the memory in the other direction.

[begin]
How can I check for memory boundary?

I tried
(FILL)
@Store
D=M
A=D
//here I need to check if the address is too big if so then just jump back up
@24575
D=D-A
@KEYDWN
D;JEQ

But it just goes way out of bounds.
[End]

After typing this and before submitting I reread 4.2 example and realized I was  changing D and that I could read memory as much as I want as long as I don’t wright to it. So I did this.

@Store
D=M
@24575
D=D-A
@KEYDWN
D;JEQ
That way I was reading the memory and checking if it was out of bounds at the bottom

@Store
D=M
@SCREEN
D=D-A
@KEYDWN
D;JEQ

And out of bounds at the top.

So after a very long delay I finished chapter 4 still needing to do more examples because I still don’t fully understand ASM because using only 3 calls one has to make things so much simpler and the order of every last command is important.
            It is now my belief that all computer science students should take a very basic ASM class after taking BASIC or PASCAL but before taking C/C++ class’s. It helps with so many different things.

No comments:

Post a Comment

Search Engine Submission - AddMe