Necessary Fundamentals / Binary Integers
Subtitles of the Movie
OK, you know how to add binary numbers, multiplication and division work much as you would expect, computers use a procedure very much like the one that you would use with a pencil and paper but subtraction is different and it's different in a way that effects how editors are represented inside the computer. To subtract a number, it's complemented and added, let me show you how it works with a base 10 number. Here is a simple subtraction, 1000 minus 741 gives you 259. Now let's look at performing this subtraction using complements. As you know, any number can be preceded by zeros and for this example the base 10 number 740 is written preceded by 3 zeros. To get the tens complement of the number the first step is to subtract each digit from 9, the result is a number called the nine's complement, adding one to it gives it a ten's complement. Now that we have the complement of the number which is a way of representing a negative number, we only have to add it to 1000 and throw away the digits that are carried off to the left. The result is the same as if the number had been subtracted. Now let's do the same thing with a couple of base 2 numbers. This example will subtract 25 from 100. The first step is to get the one's complement of 25 by changing all the ones to zero and all the zeros to one. Then, get the two's complement by adding 1, then you perform a normal addition and the result is 75. Adding the two's complement and throwing away the bit carried off to the left is the same as subtracting. This is a perfect process for a computer because addition throws away the carried bits anyway. All this is largely transparent to you but there are some things about it that can affect assembly language programming. For instance, all negative numbers are stored in two's complement format so you can spot a negative number because the first bit is always 1 and the first bit of a positive number is always 0. When you shift a number to the right the leftmost bit is duplicated to fill the vacancy, such an operation is known as sign extinction. Continuous shifting will eventually result in a negative number becoming -1 and a positive number becoming 0. Shifting an editor to the left can cause a change in the sign bit so not only does shifting to the left double the value, it can change the sign of the number. Continuous shifts to the left will eventually result in 0 always. The operation of taking a two's complement is symmetric, do it to a positive number and you get the negative number of it, do it to a negative number and you get that same number in positive.
Tutorial Information
| Course: | Assembly Language Programming |
| Author: | Arthur Griffith |
| SKU: | 33995 |
| ISBN: | 1-935320-44-0 |
| Release Date: | 2009-05-28 |
| Duration: | 5.5 hrs / 70 lessons |
| Work Files: |
Yes |
| Captions: | Available on CD and Online University |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |
VTC Sign up & Benefits
- Unlimited Access
- 81,350 Video Tutorials (20,800 free)
- Video Available as Flash or QuickTime
- Over 782 Courses
- $30 for One Month Access
- Multi-User Discounts Available
United States 