[ Pobierz całość w formacie PDF ]
.Method1 Write down the hex number but make it well spaced.2 Using the column header values of 8, 4, 2 and 1, convert each hex numberto a four bit binary number.3 Add leading zeros to ensure that every hex digit is represented by fourbits.ExampleConvert 1E08BH to binaryStep 11 E 0 8 B8421 8421 8421 8421 8421Step 20001 1110 0000 1000 1011So, 1E08BH = 000111100000100010112.34Hexadecimal the way we communicate with microsUsing stepping stonesIt is fairly easy to convert binary to hex and hex to binary.I find it mucheasier to multiply and divide by 2 rather than by 16, so when facedwith changing hex into denary and denary into hex I often changethem into binary first.It is a longer route but at least I can do it withoutmy calculator (see Figure 3.2).Figure 3.2A longer route mayprove easierObsolete octal probably not worth readingOctal is another number system which has no advantages over hex butis still met from time to time.Only a brief look will be offered here justto make sure that we have at least mentioned it.In hex, we used binary bits in groups of four because 11112 adds up to15 which is the value of the highest digit (F) in hex.In octal, we usegroups of three bits.The highest value is now 1112 which is 7.Octaltherefore has eight digits and counts from 0 to 7.The countproceeds:1234567There is no 8th digit so reset the count to 0 and put a 1 in the nextcolumn.35Introduction to Microprocessors and Microcontrollers1011121314151617Now go straight to 2020etc.No letters are involved and it is often not recognized as octal until werealize that none of the numbers involve the digits 8 or 9.Conversions follow the same patterns as we have seen for hex.Octal to denary: the column heading values are 84, 83, 82, 81, 80.Denary to octal: divide by 8 and write down the remainder then readremainders from the bottom upwards.Use the subscript 8 to indicatean octal number, e.g.6410 = 1008.Octal to binary: write each octal digit down as a three digit binarygroup.Binary to octal: start from the right-hand side and chop the binarynumbers into groups of three, then evaluate each group.I think that is enough for octal.It s (fairly) unlikely you will meet itagain so we can say goodbye Octal.Quiz time 3In each case, choose the best option.1 Which of these represents the largest number?(a) 10008(b) 100010(c) 10002(d) 1000H2 The number CD02H is equal to:(a) 5248210(b) 5422810(c) 5632210(d) 528421036Hexadecimal the way we communicate with micros3 The base of a number system is:(a) always the same as the highest digit used in the system.(b) usually +5 or +3.3.(c) equal to the number of different digits used in the system.(d) one less than the highest single digit number in the system.4 Which of these numbers is the same as101101110102:(a) 164610(b) 5BA16(c) AB5H(d) B72h5 The number of digits in a denary number is often:(a) more than the number of digits in the equivalent binarynumber.(b) less than or equal to the number of digits in the equivalent hexnumber.(c) more than the number of digits in the equivalent hexnumber.(d) more than the number of digits in the equivalent decimalnumber.374How micros calculateHow the microprocessor handles numbers (and letters)In the last chapter, we saw how numbers could be represented inbinary and hex forms.Whether we think of a number as hex or binaryor indeed denary, inside the microprocessor it is only binary.Thewhole concept of hex is just to make life easier for us.We may sit at a keyboard and enter a hex (or denary) number but thefirst job of any microprocessor-based system is to convert it to binary.All the arithmetic is done in binary and its last job is to convert it backto hex (or denary) just to keep us smiling.There was a time when we had to enter binary and get raw binaryanswers but thankfully, those times have gone.Everything wasdefinitely NOT better in the good old days.The form binary numbers take inside of the microprocessor dependson the system design and the work of the software programmers.Wewill take a look at the alternatives, starting with negative numbers.In real life, it is easy, we just put a symbol in front of the number andit is negative so +4 becomes 4.Easy, but we don t have any way ofputting a minus sign inside the microprocessor.We have tried severalways round the problem.38How micros calculateSigned magnitude numbersThe first attempt seemed easy but it was false optimism
[ Pobierz całość w formacie PDF ]