Jump to content

GB Programming: Difference between revisions

→‎Negative numbers: Changed the ranges, the dashes could be mistaken for minus signs.
>Torchickens
>ISSOtm
(→‎Negative numbers: Changed the ranges, the dashes could be mistaken for minus signs.)
Line 418:
I've told you, "individual registers can hold unsigned 8-bit values, and pairs unsigned 16-bit values". However, these aren't true: these values can be signed. How does that work?
 
What we will be doing is cutting our number range in half, and telling one half is composed of negative numbers. But how to distinguish positive and negative numbers? Well, we tell the MSB is no longer meaning the symbol in front of 2^7, but it will give away the sign of the number (0 = positive, 1 = negative). So, instead of having values in ranges 0 - 255 and 0 - 65535, we will have values in ranges -128 -to 127 and -32768 -to 32767. Neat!
 
How to multiply by -1? Easy! You can either :
Line 439:
</pre>
And, you just saw why I told you to consider 0 the same as 256 : they are similar! As 256 uses 8 zero bits preceded by a 1... but the 1 is discarded.
 
 
===Memory===
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.