Linux-SWAT
Forum Addict!
- Joined
- Feb 13, 2010
- Messages
- 9,194
So it's more a quick trick than a real operation.
I found a nice division explanation there, I will test it :
http://www.tofla.iconbar.com/tofla/arm/arm02/index.htm
I found a nice division explanation there, I will test it :
http://www.tofla.iconbar.com/tofla/arm/arm02/index.htm
To divide 50 (%110010) by 10 (%1010) in binary:
- We shift 10 as far as we can (two places) to the left until it becomes %101000 and subtract this from %110010 to get the first digit.
- %110010- %101000 = %1010 (First digit is 1)
- Now we shift %101000 back one place to the right and try to subtract %10100 from what remains of the 25 we started off with.
- %1010 - %10100 (Next digit is 0 - it 'won't go'!)
- Shift right, get %1010 and try again:
- %1010 - %1010 = %0 (Successful subtraction - next digit is 1)
Our '10' has now been shifted back two places to the right, returning it to its original value, which is our signal to stop and count up the digits in our answer - %101 in binary or '5' in decimal, w ich is of course the correct answer.