Is the ALU 15 bit?

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

Is the ALU 15 bit?

shaqywacky
I created the whole circuit in a different program than the one with the book and I was testing an assembler I created and I noticed that If I try to put in negative numbers I don't get what I expect.  This is because the 16th(MSB) is used to signify A or C-instructions.  Thus for A instructions it must be 0, which obviously will never allow negative numbers.

Did I just miss the part where the book said the ALU(and registers) were 15 bit?

Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Is the ALU 15 bit?

cadet1620
Administrator
Shaqywacky wrote
I created the whole circuit in a different program than the one with the book and I was testing an assembler I created and I noticed that If I try to put in negative numbers I don't get what I expect.  This is because the 16th(MSB) is used to signify A or C-instructions.  Thus for A instructions it must be 0, which obviously will never allow negative numbers.

Did I just miss the part where the book said the ALU(and registers) were 15 bit?

Thank you.
The ALU and registers are 16-bit, and the MSB is the sign bit.  The A instructions only allow positive numbers.  To load a negative number into the A- or D-register you need to use
    @1234
    A=-A  or  D=-A

Your assembler should reject negative numbers on A commands.

Note that the C-instructions can load -1 directly as in
    D=-1

Also note that the convention in the book is to number the bits 0 through 15 starting with the LSB = bit 0.

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

Re: Is the ALU 15 bit?

shaqywacky
Oh, OK.  That actually makes a lot of sense.

Thanks for the very fast reply!
Reply | Threaded
Open this post in threaded view
|

Re: Is the ALU 15 bit?

cadet1620
Administrator
Just curious, what tool did you use to write your circuits?

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

Re: Is the ALU 15 bit?

shaqywacky
I used Logisim just because I was more familiar with it.