DOC PREVIEW
NMT EE 308 - Binary, Hex and Decimal Numbers (4-bit representation)

This preview shows page 1-2-3-4 out of 13 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

EE 308 Spring 2002Binary, Hex and Decimal Numbers (4-bit representation)Hex0123456789ABCDEFDecimal 0 1 2 3 4 5 6 7 8 9101112131415Binary00000001001000110100010101100111100010011010101111001101111011111EE 308 Spring 2002What does a number represent?Binary numbers are a code, and represent what the programmerintends for the code.0x72’r’ (ASCII)INC (HC12 instruction)2.26V (Input from A/D converter)11410(Unsigned number)11410(Signed number)Some possible codes:Set temperature in room to 69 FSet cruise control speed to 120 mph2EE 308 Spring 2002Binary to Unsigned Decimal:111101121 x 2 + 1 x 2 + 1 x 25 4+ 1 x 2 + 0 x 2 + 1 x 2 + 1 x 26 2 1031 x 64 + 1 x 32 + 1 x 16 + 1 x 8 + 0 x 4 + 1 x 2 + 1 x 112310Convert Binary to Unsigned DecimalHex to Unsigned Decimal334948 x 16 + 2 x 16 + 13 x 16 + 6 x 1682D6162 1 038 x 4096 + 2 x 256 + 13 x 16 + 6 x 110Convert Hex to Unsigned Decimal3EE 308 Spring 2002Unsigned Decimal to Hex721 = 2D1Q721/16 45/16 2/1645 2 011321D210 16DivisionRDecimal HexConvert Unsigned Decimal to Hex4EE 308 Spring 2002Unsigned Number Line: Numbers go from 0 to0 1 2 2 42 5 6 7 8 9 10 11 12 13Unsigned Number LineUnsigned Number Wheel: Numbers go from 0 to 000001110 010011100101111012345670 1 2 3 4 5 6 75EE 308 Spring 2002Signed Number Line: Numbers go fromto−2 −1 0 1 2 3−3−6 −5 −4 4 5 6 7Number Wheel: Numbers go fromto000001110 0100111001011110123−4−3−3 −2 −1 0 1 2 3−1−2−46EE 308 Spring 2002Number Wheel: Carry and OverflowCarry applies to unsigned numbers — when adding or subtracting, result isincorrect.Overflow applies to signed numbers — when adding or subtracting, result isincorrect.000001110 010011100101111123−3−1−20−470123456CarryOverflowBlue: Unsigned NumbersRed: Signed Numbers7EE 308 Spring 2002Binary, Hex and Decimal (Signed & Unsigned) Numbers (4-bit representation)00000001001000110100010101100111100010011010101111001101111011110123456789ABCDEF 0 1 2 3 4 5 6 7 8 9101112131415US S 0 1 2 3 4 5 6 7−8−7−6−5−4−3−2−1Binary HexDecimal8EE 308 Spring 2002If most significant bit is 0 (most significant hex digit 0−7), number is positive.Get decimal equivalent by converting number to decimal, and using + sign.Example for 8−bit number:If most significant bit is 1 (most significant hex digit 8−F), number is negative.Get decimal equivalent by taking 2’s complement of number, converting to decimal,and using − sign.Example for 8−bit number:Signed Number Representation in 2’s Complement Form:16 − ( 5 x 16 + 13 x 16 ) − ( 5 x 16 + 13 x 1 ) − 933A −> + ( 3 x 16 + 10 x 16 )+ ( 3 x 16 + 10 x 1 )+ 5816A3 −> − ( 5D )11001010161 01010109EE 308 Spring 2002One’s Complement Table Makes It Simple To Find 2’s Complements01234567 8DEF9ABCOne’s Complement TableTo take two’s complement, add one to one’s complement.Take two’s complement of :D0C32F3C + 1 = 2F3D10EE 308 Spring 2002Overflow and Carry assume you have a fixed word sizeA carry is generated when you add two unsigned numbers together, and theresult is too large to fit in the fixed word size.A carry is generated when you subtract two unsigned numbers, and the resultshould be negative.An overflow is generated when you add or subtract two signed numbers, andthe fixed-length answer has the wrong sign.Addition and Subtraction of Binary and Hexadecimal Numbers 4−bit word:+ 1011 11011 1000ADDITION AND SUBTRACTION OF BINARY AND HEXADECIMAL NUMBERSDoes not matter if numbers are signed or unsigned − mechanics the sameLimit number of digits to specified word size.1)2)Do the operation, then determine if carry and/or overflow bits are set.Keep only 4 bits in answerCarry is set, overflow is clear 4−bit word: 1101 Neg+ 1011 Neg1 1000 Neg11EE 308 Spring 2002Condition Code Register Gives Information On Result Of Last OperationS H I N Z V CXCondition Code Register − 8 FFsV − Overflow : 1 −> last operation generated an overflowC − Carry : 1 −> last operation generated a carryZ − Zero : 1 −> result zero, 0 −> result not zeroN − Negative : most significant bit of resultNote: Not all HC12 instructions change CCR bits. A bit in the CCR is the resultof the last executed instruction which affects that bit. For example, after theinstruction sequence:aba ; Add B to Astaa $0900 ; Store A in address $0900the C bit of the CCR will reflect the result of the ABA instruction, not the resultof the STAA instruction.12EE 308 Spring 2002Overflow only occurs under certain addition and subtraction operations.S H I N Z V CXCondition Code Register − 8 FFsV − Overflow : 1 −> last operation generated an overflowC − Carry : 1 −> last operation generated a carryZ − Zero : 1 −> result zero, 0 −> result not zeroN − Negative : most significant bit of resultIf you add a positive and a negative number, on overflow never occurs.If you subtract two positive numbers, an overflow never occurs.If you subtract two negative numbers, and overflow never


View Full Document

NMT EE 308 - Binary, Hex and Decimal Numbers (4-bit representation)

Documents in this Course
Load more
Download Binary, Hex and Decimal Numbers (4-bit representation)
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Binary, Hex and Decimal Numbers (4-bit representation) and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Binary, Hex and Decimal Numbers (4-bit representation) 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?