Fill.asm

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

Fill.asm

theopavlakou
Guys, can someone please provide me with a working .asm file so that I can see how it works please?
Thank you so much.
Reply | Threaded
Open this post in threaded view
|

Re: Fill.asm

cadet1620
Administrator
This post was updated on .
Theo wrote
Guys, can someone please provide me with a working .asm file so that I can see how it works please? Thank you so much.
Forum etiquette is not to post solutions.

Here's a snippet of code (not related to Fill.asm) that shows some useful concepts, basically an if-then-else:

// if q is even, r = q+3;  else r = q-1
    @q
    D=M
    @1
    D=D&A
    @ODD
    D;JNE
// even number
    @q
    D=M
    @3
    D=D+A
    @STORE
    0;JMP
(ODD)
    @q
    D=M-1
(STORE)
    @r
    M=D

--Mark

Reply | Threaded
Open this post in threaded view
|

Re: Fill.asm

theopavlakou
Hmmm, I am actually baffled by that.
I do like the way you tested for it being even and all, I just still don't really get what it is about.
I didn't know you couldn't give solutions, nevermind. But yeah, I really really don't understand how to increment addresses.
Reply | Threaded
Open this post in threaded view
|

Re: Fill.asm

JerJohnson
In reply to this post by cadet1620
I was wondering if you could use if than else statements in HACK. This should be helpful thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Fill.asm

ybakos
JerJohnson,
Yes. Be sure to read the relevant book chapter regarding the Hack assembly specification, especially regarding jump instructions.

(By the way, a friendly tip: it's easier to follow your topic of discussion if you start a new thread rather than posting a response somewhere.
Reply | Threaded
Open this post in threaded view
|

Re: Fill.asm

cadet1620
Administrator
In reply to this post by JerJohnson
JerJohnson wrote
I was wondering if you could use if than else statements in HACK. This should be helpful thanks.
If-then-else is a high-level language construct and is not available in the Hack assembly language. When you do the language translation projects in chapters 7-11 you will learn how if-then-else gets translated from the Jack language into machine language.

For the Fill.asm program you need to use only the instructions that are documented in chapter 4. They are the only thing that the Hack computer can do without a high-level language translator.

--Mark