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.

Multiplying by adding


 When running the test script I was clearing all the locations but the test script would put in the data first before I cleared then all the results would be wrong. I just had to make the result 0 every go around but since the other two memory locations were going to be over written any way I just left them alone.
            After doing this project I realized that if one plans out there project and Knows that the variable is going to be 0ver written then one does not need to clear it each time but always zero out variables that are not going to be over written but just read then written to.
The key to the multiply project is to know that when your multiplying you are adding itself to itself as many times as the multiplier says to. Also using a loops and jump statements are good.

Here was my laid out plan

//Start at fisrt memory location
//then stick that in to be computed
//then add it to itself as many times as it is supose to be multiplyed by
//use the multiplyer to controll the loop or counter

Part of the code that add'ed the data

@R1 
D=M
@R2
M=D+M
@LOOP
0;JMP


After a very long break. Getting under way....


            On and off for five months of trying to figure out the Hack assembly language and re reading  chapter 4 five or six time on top of taking pages and pages of notes I learned how to use it. Assembly language is different than any other language I have learned. Calling the memory location then putting data into that location.
Here is what I played with to figure out the ASM


@1    //this is the address to the memory where the program starts at
      //And since the system just started that memory location should be blank or 0
D=M   // since the above address memory location is empty then D is the value of the memory
@5    //this is a new value
D=D-A //A is = to 5 and D is equal to 0 so the new Value of D is -5
@100  //the vaule in the A register is now 100
D;JEQ // D = -5 JEQ is Jump to 100 in the program if D is equal to 0
@7 //A is now 200 if 7 then program doesnt move at all
M;JMP // Just jump to 200 in the program if 0 but if M Jump to 200 in memory also


Something like this should have put in the book with that much info on what the coded did.

Thursday, March 29, 2012

Progress on creating all the hardware

I am making all the schematics and taking pics of all the hardware. I am also videoing all the progress.
Next thing I will be doing is simulating all the schematics before I build the more complex parts.
Search Engine Submission - AddMe