promotion image of download ymail app
Promoted

mano's assembly language  Write a program loop using a pointer and a counter that negates each word in memory locations?

300 through 30F, using 2’s complement representation.

I did solve it but I'm not sure of my solution because in location 300 it still shows that its 0000 (not the 2s complement)

1 Answer

Relevance
  • 2 months ago
    Favorite Answer

    There's not enough in your question for me to see what your question is, but if you're worried about the two's complement of 0000h, that's 0000h. 

    There are two bit patterns that don't change under a two's complement conversion, and this is the easy one to understand.  "Minus zero" is just zero, numerically, and there's only one bit pattern for zero in two's complement.

    The process is worth looking at.  One common way to describe the two's complement conversion is "flip all bits and then add 1".  Starting with 0000h as a 16-bit value, inverting all bits gets you FFFFh, and then adding 1 gets back to 0000h.  Yes, there's a 1 carried out of the leftmost bit position, but that's generally ignored.

    The other bit pattern that doesn't change is a 1 in the leftmost bit of the word, with all other bits set to 0.  The hex value of a 16-bit version of that is 8000h.  Invert all bits produces 7FFFh and adding 1 makes that 8000h again.  This pattern is usually interpreted as negative, -(2^15) = -32,768 in the 16-bit case.  It's the only value x that's representable in a two's complement format, but its opposite (-x) is not.

    • Commenter avatarLogin to reply the answers
Still have questions? Get your answers by asking now.