Project 4 help

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

Project 4 help

dmoeller
I have programmed in assembly before so I understnad low level languages, but I dont understand what im supposed to do for Mult.asm, im just not sure what hte assignment is for that. And for Fill.asm im not sure:
1. how to check for input from the keyboard
2. how to change the entire screen, not just one pixel, to black from white
3. how to change it from black to white once input has stopped from the keyboard.

I do know how to make an infinite loop, but doesnt that usually cause a compiler error?
Reply | Threaded
Open this post in threaded view
|

Re: Project 4 help

ybakos
Mult.asm implements multiplication in software (Hack Assembly language). Given a number in one register, and another number in a second register, place their product in a third register.

Review the book chapter for how to read the keyboard - it's one register in Memory. Which register?

If you know how to change one pixel, do you know how to change, say, 16 pixels?

#3) That's part of the challenge you'll have to think about some more. Write it in pseudocode first. Solve the problem, then write the solution as asm.

An infinite loop is not a compilation error - sometimes we want an infinite loop in our program. When we don't want an infinite loop, but we end up with one in a program, it is, at most, a logic error.
Reply | Threaded
Open this post in threaded view
|

Re: Project 4 help

dmoeller
I want to make sure I understand this correctly. D represents the address of the register and m represents the value? so for changing the color of the screen, 1 pixel at a time would be
(infinite loop)
d=d+1
m=1
(end loop)
correct?
Reply | Threaded
Open this post in threaded view
|

Re: Project 4 help

cadet1620
Administrator
This post was updated on .
D is the Data register and A is the Address register.

I've written an introduction to Hack programming that you might find helpful.

Introduction to Hack Assembly Language

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

Re: Project 4 help

dmoeller
Im afraid I still don't understand the hack assembly language. I don't understand how to do NON infinite loop for MULT. All I understand is that when you use the @ symbol, that is what A is set to. I also dont understand what D and M are used for, they look like they are used for the same things.
Reply | Threaded
Open this post in threaded view
|

Re: Project 4 help

ybakos
dmoeller, how much time have you spent with the chapter in the book?

The Hack CPU has two registers: A and D, plus access to a bunch of registers in Memory.

Reply | Threaded
Open this post in threaded view
|

Re: Project 4 help

dmoeller
My instructors lecture las night cleared alot of things up for me. I do wonder, after I change the color of 16 pixels at a time, how do I move to the next 16? say I store the address of the begining of the screen at R0.
Would:
@0
D=M+1 move me just one pixel, or all 16? If it moves just one, would:
@16
D=A
A=D+A work?
Reply | Threaded
Open this post in threaded view
|

Re: Project 4 help

ybakos
Try it.
Reply | Threaded
Open this post in threaded view
|

Re: Project 4 help

dmoeller
I can run my program but the screen does not turn black when i push a key.
Reply | Threaded
Open this post in threaded view
|

Re: Project 4 help

dmoeller
sorry, I got this one figured out. Now I wonder what address is the end of the screen so I can stop turning registers black once the screen is full?
Reply | Threaded
Open this post in threaded view
|

Re: Project 4 help

cadet1620
Administrator
How many pixels are on the screen? That number /16 is the number of words of screen memory.
SCREEN + number of words is one word beyond the screen.

Hack assembler does not do arithmetic so you will have to use the actual number.

--Mark