mult.asm does not compile, error without line number

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

mult.asm does not compile, error without line number

OppaErich
Hi,

the compiler does not like my code but does not really tell me where and what the problem is.

[oppa@oppa-F28 mult]$ ../../../tools/Assembler.sh mult.asm
Assembling /home/oppa/Dokumente/MOOCs/Coursera/nand2tetris/projects/04/mult/mult.asm
end of line expected, '=' is found

So, I'm lost here.

Have fun,
Stephan
Reply | Threaded
Open this post in threaded view
|

Re: mult.asm does not compile, error without line number

cadet1620
Administrator
It would be nice it the Assembler would report the line number!

Run the assembler in interactive mode and it will stop on the error.

Check that your line endings are correct. Your editor may have maintained the Windows newlines in the original Mult.asm. Convert to Linux using "fromdos Mult.asm".

If all else fails, upload your Mult.asm here (don't copy/paste it; that mangles the whitespace).

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

Re: mult.asm does not compile, error without line number

OppaErich
Hi,
my first, too naive, attempt went through fine. It's not the line endings.

But I found the problem using interactive mode.

@result=0 was not the way to do it.

Now I get a new one:
D=0-M - Expression expected

How do I flip the sign ? XOR 0xFFFF and then + 1 ?
Reply | Threaded
Open this post in threaded view
|

Re: mult.asm does not compile, error without line number

cadet1620
Administrator
D=-M

See chapter 4 figure 4.3.

The computation field in C-commands is an ALU operation with x=D, y=A/M.

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

Re: mult.asm does not compile, error without line number

OppaErich
Hi,

ah. I need something like

@operand
D=M
@zero
D=M-D

Thanks,
Stephan

I'm trying to catch up. Had a surgery last week with 4 days in hospital and no internet for 36h from tuesday afternoon.
Reply | Threaded
Open this post in threaded view
|

Re: mult.asm does not compile, error without line number

cadet1620
Administrator
This post was updated on .
In reply to this post by OppaErich
OppaErich wrote
Now I get a new one:
D=0-M - Expression expected
OppaErich wrote
@operand
D=M
@zero
D=M-D
If 'zero' is a variable with constant 0 value, you can simply write
    @operand
    D=-M
You might find Introduction to Hack Assembly Language helpful.

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

Re: mult.asm does not compile, error without line number

OppaErich
cadet1620 wrote
You might find Introduction to Hack Assembly Language helpful.
Nope  a 404 is not helpful

Is it this https://docs.wixstatic.com/ugd/44046b_4a28a2456639425896f6cc1c7a51da88.pdf now ?
Reply | Threaded
Open this post in threaded view
|

Re: mult.asm does not compile, error without line number

cadet1620
Administrator
This post was updated on .
I fixed the bad link in my previous post.

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

Re: mult.asm does not compile, error without line number

OppaErich
Hi,

thanks. Got it, had a hard time to find a nasty bug in the loop. But done now. Checks for operands being 0 or 1 and uses the smaller of the two as the loop counter. Hack.asm is 165 lines.

Have a nice weekend,
Stephan

fill.asm should be easier, just two cases/states.