ASSEMBLY LANGUAGE FOR INTELBASED COMPUTERS DATA REPRESENTATION PART
ASSEMBLY LANGUAGE FOR INTEL-BASED COMPUTERS DATA REPRESENTATION PART 2 Web site Examples
OVERFLOW Fixed word size has a fixed range size Overflow: combination of numbers that adds to result outside the range End-around carry in modular arithmetic avoids problem Complementary arithmetic: numbers out of range have the opposite sign Web site Examples 2 • Test: If both inputs to an addition have the same sign and the output sign is different, an overflow occurred
OVERFLOW 8 -bit number • 256 different numbers • Positive numbers: 0 to 127 Add • Test for overflow • 2 positive inputs produced negative result overflow! • Wrong answer! 0100 0000 = 64 + 0100 0001 = 65 1000 0001 -129 0111 1110 Invert to get magnitude -12710 12910 Web site Examples 3 Programmers beware: some high-level languages, e. g. , some versions of BASIC, do not check for overflow adequately
OVERFLOW AND CARRY CONDITIONS Carry flag: set when the result of an addition or subtraction exceeds fixed number of bits allocated Web site Examples 4 Overflow: result of addition or subtraction overflows into the sign bit
OVERFLOW/CARRY EXAMPLES • Correct result • No overflow, no carry Example 2: 0 means positive 0100 = (+ 4) 0010 = + (+ 2) 0110 = (+ 6) • Incorrect result • Overflow, no carry 1 means negative Web site 0100 = (+ 4) 0110 = + (+ 6) 1010 = (– 6) (+10) Examples 5 Example 1:
Example 3: • Result correct ignoring the carry • Carry but no overflow Example 4: • Incorrect result • Overflow, carry ignored Web site 1100 = (– 4) 1110 = + (– 2) 11010 = (– 6) 1100 = (– 4) 1010 = + (– 6) 10110 = (-10) Examples 6 OVERFLOW/CARRY EXAMPLES
REPRESENTING CHARACTERS Web site Examples 7 ASCII - most widely used coding scheme EBCDIC: IBM mainframe (legacy) Unicode: developed for worldwide use Character sets ◦ Standard ASCII(0 – 127) ◦ Extended ASCII (0 – 255) ◦ ANSI (0 – 255) ◦ Unicode (0 – 65, 535) Null-terminated String ◦ Array of characters followed by a null byte Using the ASCII table ◦ back inside cover of book
ASCII Developed by ANSI (American National Standards Institute) Represents • Latin alphabet, Arabic numerals, standard punctuation characters • Plus small set of accents and other European special characters ASCII Web site Examples 8 • 7 -bit code: 128 characters
EBCDIC Extended Binary Coded Decimal Interchange Code developed by IBM ASCII EBCDIC Space 2016 4016 A 4116 C 116 b 6216 8216 Web site Examples 9 • Restricted mainly to IBM or IBM compatible mainframes • Conversion software to/from ASCII available • Common in archival data • Character codes differ from ASCII
UNICODE Most common 16 -bit form represents 65, 536 characters ASCII Latin-I subset of Unicode • Values 0 to 255 in Unicode table Multilingual: defines codes for • Nearly every character-based alphabet • Large set of ideographs for Chinese, Japanese and Korean • Composite characters for vowels and syllabic clusters required by some languages Web site Examples 10 Allows software modifications for locallanguages
- Slides: 10