



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
o Binary numbers are a code, and represent what the programmer intends for the code o Convert binary and hex numbers to unsigned decimal.
Typology: Study notes
1 / 7
This page cannot be seen from the preview
Don't miss anything!




Binary Hex Decimal 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
What does a number represent? Binary numbers are a code, and represent what the programmer intends for the code. 0x72 Some possible meanings: ’r’ (ASCII) INC MEM (hh ll) (HC12 instruction) 2.26V (Input from A/D converter) 11410 (Unsigned number) 11410 (Signed number) Set temperature in room to 69 °F
Set cruise control speed to 120 mph Binary to Unsigned Decimal: Convert Binary to Unsigned Decimal (^1111011 ) 1 x 2^6 + 1 x 2 5 + 1 x 2 4 + 1 x 2 3 + 0 x 2 2 + 1 x 2 1 + 1 x 2 0 1 x 64 + 1 x 32 + 1 x 16 + 1 x 8 + 0 x 4 + 1 x 2 + 1 x 1 (^123 ) Hex to Unsigned Decimal Convert Hex to Unsigned Decimal 82D6 (^16) 8 x 16^3 + 2 x 16^2 + 13 x 16^1 + 6 x 16^0 8 x 4096 + 2 x 256 + 13 x 16 + 6 x 1 (^33494 ) Unsigned Decimal to Hex Convert Unsigned Decimal to Hex Division Q R Decimal Hex 721/ 45/ 2/
Unsigned Number Line: Numbers go from 0 to ∞ Unsigned Number Wheel: Numbers go from 0 to 2N − 1
Binary, Hex and Decimal (Signed & Unsigned) Numbers (4-bit representation) Binary Hex Decimal Unsigned Signed 0000 0 0 0 0001 1 1 1 0010 2 2 2 0011 3 3 3 0100 4 4 4 0101 5 5 5 0110 6 6 6 0111 7 7 7 1000 8 8 - 1001 9 9 - 1010 A 10 - 1011 B 11 - 1100 C 12 - 1101 D 13 - 1110 E 14 - 1111 F 15 -
Signed Number Representation in 2’s Complement Form: If the most significant bit (MSB) is 0 (most significant hex digit 0−7), then the number is positive. Get decimal equivalent by converting number to decimal, and use the + sign. Example for 8−bit number: 3A 16 −> + ( 3 x 16^1 + 10 x 16^0 ) (^10)
Note: Not all HC12 instructions change CCR bits. A bit in the CCR is the result of the last executed instruction which affects that bit. For example, consider the following instruction sequence: aba ; Add B to A staa $0900 ; Store A in address $ The ABA instruction will change the H, N, Z, V and C bits of the CCR. The STAA instruction will change the N and Z bit, and clear the V bit. After the two instructions, the H and C bits will reflect the result of the ABA instruction; the N and Z bits will reflect the result of the STAA instruction (was the number stored negative or zero?), and the V bit will be 0. Overflow occurs only under certain addition and subtraction operations