Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Handling Negative numbers

3 views
Skip to first unread message

Philip Markowski

unread,
Feb 2, 2012, 2:08:10 PM2/2/12
to
For some reason, for the beq and lw problems, every time there is a
negative number involved, my answer is off by one hex digit from what
binasm produces. I've tried using all unsigned ints, hoping it would
solve the problem but it didn't change anything. Has anyone with a
similar problem have a hint?

Jeremy Roman

unread,
Feb 2, 2012, 3:12:36 PM2/2/12
to
You are probably not constraining that number to the correct range of bits.

As a 32-bit integer, -1 is 0xffffffff. As a 16-bit integer, it's only
0xffff. Make sure that you convert it correctly to the latter before
trying to merge it with your instruction, or you will end up affecting
bits that you did not intend.

philipmar...@gmail.com

unread,
Feb 2, 2012, 3:46:11 PM2/2/12
to
Ohh, that's probably it! I get it now. Thank you!
0 new messages