Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Agenda 1. Data Types 2. Unsigned & Signed Integers 3. Arithmetic Operations Chapter 2 4. Logical Operations 5. Shifting Bits, Data Types, 6. Hexadecimal & Octal Notation and Operations 7. Other Data Types
COMPSCI210 S1C 2009 2
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1. Data Types Computer is a binary digital system. How do we represent data in a computer? Digital system: Binary (base two) system: At the lowest level, a computer is an electronic machine. • finite number of symbols • has two states: 0 and 1 • works by controlling the flow of electrons
Easy to recognize two conditions: 1. presence of a voltage – we’ll call this state “1” 2. absence of a voltage – we’ll call this state “0” Basic unit of information is the binary digit, or bit. Values with more than two states require multiple bits. • A collection of two bits has four possible states: Could base state on value of voltage, 00, 01, 10, 11 but control and detection circuits more complex. • A collection of three bits has eight possible states: • compare turning on a light switch to 000, 001, 010, 011, 100, 101, 110, 111 measuring or regulating voltage • A collection of n bits has 2n possible states. COMPSCI210 S1C 2009 3 COMPSCI210 S1C 2009 4
1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. What kinds of data do we need to represent? 2. Unsigned & Signed Integers
Decimal Numbers • Numbers – signed, unsigned, integers, floating point, complex, rational, irrational, … “decimal” means that we have ten digits to use in our • Text – characters, strings, … representation (the symbols 0 through 9) • Images – pixels, colors, shapes, … • Sound What is 3,546? • Logical – true, false • it is three thousands plus five hundreds plus four tens plus six ones. • Instructions • i.e. 3,546 = 3.103 + 5.102 + 4.101 + 6.100 • … How about negative numbers? • we use two more symbols to distinguish positive and negative: Data type: + and – • representation and operations within the computer Note that not everyone uses base 10 We’ll start with numbers… • Vigesimal (base 20)http://en.wikipedia.org/wiki/Vigesimal
COMPSCI210 S1C 2009 5 COMPSCI210 S1C 2009 6
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Unsigned Integers Unsigned Binary Integers Non-positional notation Y = “abc” = a.22 + b.21 + c.20 • could represent a number (“5”) with a string of ones (“11111”) • problems? (where the digits a, b, c can each take on the values of 0 or 1 only)
N = number of bits 3-bits 5-bits 8-bits Weighted positional notation 0 000 00000 00000000 • like decimal numbers: “329” Range is: • “3” is worth 300, because of its position, while “9” is only worth 9 0 i < 2N - 1 1 001 00001 00000001 2 010 00010 00000010 most least significant significant 3 011 00011 00000011 329 101 Problem: 4 100 00100 00000100 102 101 100 22 21 20 • How do we represent 3x100 + 2x10 + 9x1 = 329 1x4 + 0x2 + 1x1 = 5 negative numbers?
COMPSCI210 S1C 2009 7 COMPSCI210 S1C 2009 8
2 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Unsigned Binary Arithmetic Signed Integers Base-2 addition – just like base-10! With n bits, we have 2n distinct values. • add from right to left, propagating carry • assign about half to positive integers (1 through 2n-1) and about half to negative (- 2n-1 through -1) carry • that leaves two values: one for 0, and one extra Positive integers • just like unsigned – zero in most significant (MS) bit 00101 = 5 Negative integers • sign-magnitude – set MS bit to show negative, other bits are the same as unsigned 10101 = -5 -1 * (0×23 + 1×22 + 0×21 + 1×20) • one’s complement – flip every bit to represent negative 11010 = -5 (-00101) Subtraction, multiplication, division,… • in either case, MS bit indicates sign: 0=positive, 1=negative COMPSCI210 S1C 2009 9 COMPSCI210 S1C 2009 10
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Signed Magnitude One’s Complement Leading bit is the sign bit -3 111 Invert all bits -3 100 -2 110 -2 101
Y = “abc” = (-1)a (b.21 + c.20) -1 101 If msb (most significant bit) is 1 then the -1 110 -0 100 number is negative (same as signed -0 111 Range is: magnitude) -2N-1 + 1 <= i <= 2N-1 - 1 +0 000 +0 000 +1 001 Range is: +1 001 E.g. 3 bits: -3 <= i <= 3 +2 010 -2N-1 + 1 <= i <= 2N-1 - 1 +2 010 Problems: +3 011 +3 011 E.g. 3 bits: -3 <= i <= 3 • How do we do addition/subtraction? Problems: • We have two numbers for zero (+/-)! •Same as for signed magnitude
COMPSCI210 S1C 2009 11 COMPSCI210 S1C 2009 12
3 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Two’s Complement Two’s Complement Representation Problems with sign-magnitude and 1’s complement If number is positive or zero, • two representations of zero (+0 and –0) • normal binary representation, zeroes in upper bit(s) • arithmetic circuits are complex If number is negative, How to add two sign-magnitude numbers? – e.g., try 2 + (-3) • start with positive number How to add to one’s complement numbers? • flip every bit (i.e., take the one’s complement) – e.g., try 4 + (-3) • then add one Two’s complement representation developed to make circuits easy for arithmetic. (5) (9) • for each positive number (X), assign value to its negative (-X), such that X + (-X) = 0 with “normal” addition, ignoring carry out (1’s comp) (1’s comp)
(5) (9) (-5) (-9) (-5) (-9) (0) (0) COMPSCI210 S1C 2009 13 COMPSCI210 S1C 2009 14
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Two’s Complement Shortcut Two’s Complement Signed Integers MS bit is sign bit – it has weight –2n-1. To take the two’s complement of a number: n-1 n-1 • copy bits from right to left until (and including) the first “1” Range of an n-bit number: -2 through 2 – 1. • flip remaining bits to the left • The most negative number (-2n-1) has no positive counterpart. -23 22 21 20 -23 22 21 20 0 0 0 0 0 1 0 0 0 -8 0 0 0 1 1 1 0 0 1 -7 (1’s comp) (flip) (copy) 0 0 1 0 2 1 0 1 0 -6 0 0 1 1 3 1 0 1 1 -5 0 1 0 0 4 1 1 0 0 -4 0 1 0 1 5 1 1 0 1 -3 0 1 1 0 6 1 1 1 0 -2 0 1 1 1 7 1 1 1 1 -1
COMPSCI210 S1C 2009 15 COMPSCI210 S1C 2009To go from n to –n: Two’s Complement conversion 16
4 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Applet: Bin2Dec.html Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Converting Binary (2’s C) to Decimal More Examples 1. If leading bit is one, take two’s complement to get a positive number. X = 00100111two 5 2 1 0 2. Add powers of 2 that have “1” in the n 2n = 2 +2 +2 +2 = 32+4+2+1 n 2n corresponding bit positions. 0 1 = 39 0 1 1 2 ten 1 2 3. If original number was negative, 2 4 2 4 add a minus sign. 3 8 X = 11100110 3 8 4 16 two 4 16 5 32 -X = 00011010 5 32 4 3 1 X = 01101000two 6 64 = 2 +2 +2 = 16+8+2 6 64 6 5 3 7 128 7 128 = 2 +2 +2 = 64+32+8 8 256 = 26ten 8 256 = 104ten 9 512 X = -26 9 512 10 1024 ten 10 1024
Assuming 8-bit 2’s complement numbers. Assuming 8-bit 2’s complement numbers. COMPSCI210 S1C 2009 17 COMPSCI210 S1C 2009 18
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Applet: Dec2Bin.html Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Converting Decimal to Binary (2’s C) Converting Decimal to Binary (2’s C) n 2n First Method: Division Second Method: Subtract Powers of Two 0 1 1. Find magnitude of decimal number. (Always positive.) 1 2 1. Find magnitude of decimal number. 2 4 2. Divide by two – remainder is least significant bit. 2. Subtract largest power of two 3 8 3. Keep dividing by two until answer is zero, less than or equal to number. 4 16 writing remainders from right to left. 5 32 4. Append a zero as the MS bit; 3. Put a one in the corresponding bit position. 6 64 if original number was negative, take two’s complement. 4. Keep subtracting until result is zero. 7 128 8 256 5. Append a zero as MS bit; 9 512 X = 104ten 104/2 = 52 r0 bit 0 52/2 = 26 r0 bit 1 if original was negative, take two’s complement. 10 1024 26/2 = 13 r0 bit 2 13/2 = 6 r1 bit 3 X = 104ten 104 - 64 = 40 bit 6 6/2 = 3 r0 bit 4 40 - 32 = 8 bit 5 3/2 = 1 r1 bit 5 8 - 8 = 0 bit 3 X = 01101000 1/2 = 0 r1 bit 6 two X = 01101000two COMPSCI210 S1C 2009 19 COMPSCI210 S1C 2009 20
5 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Examples: (Decimal -> Binary) Examples: (Binary -> Decimal)
Convert –2310 to binary numbers in Convert 10101010 to Decimal if the number is • 8-bit, Signed Magnitude represented as 10010111 • 8-bit, Signed Magnitude 10101010 -> Negative numbers • 8-bit, One’s complement = -42 23 -> Binary: 00010111 One’s complement -> 11101000 • Signed 8-bit in two’s complement 10101010 -> Negative numbers => Complement it = 01010101 = 85 • 8-bit, Two’s complement: => Add 1 = 86 23 -> Binary: 00010111 = -86 One’s complement -> 11101000 Two’s complement -> 11101001 • Unsigned 8-bit 10101010 = 170
COMPSCI210 S1C 2009 21 COMPSCI210 S1C 2009 22
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Exercises (Decimal -> Binary) Exercises (Binary -> Decimal) Convert Decimal –17 to 8-bit binary numbers in Convert 10110011 to Decimal if the number is represented • Signed Magnitude as • Signed Magnitude
• One’s complement: • Signed 8-bit two’s complement
• Two’s complement: • Unsigned 8-bit
COMPSCI210 S1C 2009 23 COMPSCI210 S1C 2009 24
6 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Applet: NumOps.html 3. Arithmetic Operations Addition Recall: As we’ve discussed, 2’s comp. addition is just a data type includes representation and operations. binary addition. We now have a good representation for signed integers, • assume all integers have the same number of bits so let’s look at some arithmetic operations: • ignore carry out • Addition • for now, assume that sum fits in n-bit 2’s comp. representation • Subtraction • Sign Extension We’ll also look at overflow conditions for addition. (104) (-10) Multiplication, division, etc., can be built from these basic operations. (-16) (-9) (98) (-19)
Assuming 8-bit 2’s complement numbers. COMPSCI210 S1C 2009 25 COMPSCI210 S1C 2009 26
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Subtraction Exercise Negate subtrahend (2nd no.) and add. 01101011 – 00010110 • assume all integers have the same number of bits • ignore carry out • for now, assume that difference fits in n-bit 2’s comp. representation
(104) (-10) 00101100 – 01101001 (16 (-9) (104) (-10) (-16) (9) (88) (-1)
Assuming 8-bit 2’s complement numbers. COMPSCI210 S1C 2009 27 COMPSCI 105 28
7 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Sign Extension Sign extension: How it works To add two numbers, we must represent them The sign bit is replicated: with the same number of bits. 0x9876: 1001 1000 0111 0110: -2^15 + 2^12+…… If we just pad with zeroes on the left: 0xff9876: 1111 1111 1001 1000 0111 0110: 4-bit 8-bit (4) (still 4) -2^23+2^22+2^21+2^20+2^19+…+2^15+2^12+…. = (-4) (12, not -4) -2^22 +2^21+………………………………… = -2^21 +2^20+………………………….. =
Instead, replicate the MS bit -- the sign bit: 2^16+2^15+2^12+………. = -2^15+2^12+………. = 0x9876 4-bit 8-bit By the same way you can demonstrate that the quadword 0xff…ff9876 is (4) (still 4) equal to the word 0x9876. Using 2’s representation convention you can (-4) (still -4) also see that the quadword 0xff…ff9876 (which is a negative number) is equal to the word –0x678a
COMPSCI210 S1C 2009 29 COMPSCI210 S1C 2009 30
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Overflow Examples (4-bit) If operands are too big, then sum cannot be represented Assuming 4-bit 2’s complement numbers as an n-bit 2’s comp number. • Range - 8 <= x <= 7 -6 -6 + -7 = -13 1010 (outside the range) -7 6 6 + 7 = 13 + 1001 (8) (-8) 0110 (outside the range) 7 10000 carries (9) (-9) + 0111 01100 carries 10011(4-bit)= 0011 (-15) (+15) 01101 (4-bit) => 1101 Answer = 3 Answer = -3 Invalid answer We have overflow if: Invalid answer 2 • signs of both operands are the same, and -2 -2 + 3 = 1 0010 2 + 3 = 5 1110 3 • sign of sum is different. 3 +0011 + 0011 Answer = 1 0100carries Another test -- easy for hardware: 11100 carries valid answer • carry into MS bit does not equal carry out 0101 Answer = 5 10001 (4-bit)=0001 Valid answer
COMPSCI210 S1C 2009 31 COMPSCI210 S1C 2009 32
8 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Valid or invalid? Examples Overflow occurs if • Look at the carries into and out of the sign bit. If they • +ve number add +ve number => -ve number are not equal, there is an overflow. • -ve number add –ve number => +ve number 0110 1010 Carry out of Example: Carry into + 0111 + 1001 the sign bit the sign bit • 6 + 7 = -3 (actual answer = 13) 01100 carries 10000 carries • -6 + -7 = 3 (actual answer = -13) 01101 10011
A better way: 1110 0010 • Look at the carries into and out of the sign bit. If they are not Carry into & Carry out + 0011 + 0011 equal, there is an overflow. No carry 11100 carries 00100 carries • Not equal: -> overflow 10001 0101 • Equal = No Overflow
COMPSCI210 S1C 2009 33
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Applet: BinOps.html Exercises 4. Logical Operations 0111 Logical operations are also useful: 1001 • AND + 0101 + 1100 • OR • NOT • XOR
1100 1001 + 0111 + 0011
COMPSCI 105 35 COMPSCI210 S1C 2009 36
9 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Logical Operations Examples of Logical Operations Operations on logical TRUE or FALSE AND • useful for clearing bits • two states -- takes one bit to represent: TRUE=1, FALSE=0 AND AND with zero = 0 A NOT A A B A OR B AND with one = no change 0 1 0 0 0 1 0 0 1 1 OR 1 0 1 A B A AND B A B A XOR B • useful for setting bits OR with zero = no change OR 0 0 0 1 1 1 0 0 0 OR with one = 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 1 1 1 0 View n-bit number as a collection of n logical values • operation applied to each bit independently COMPSCI210 S1C 2009 37 COMPSCI210 S1C 2009 38
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Examples of Logical Operations Exercises NOT • unary operation -- one argument NOT • flips every bit
XOR • Same = 0 • Different = 1 XOR
COMPSCI210 S1C 2009 39 COMPSCI 105 Handout 04 40
10 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. -43 5. Shifting Sll << x 1 1 0 1 0 1 0 1 -86 Shift operators move bits to the left or to the right. Examples 0 • Used to shift the bit patterns left and right. • 1101 0101 << 1 1 0 1 0 1 0 1 0 • Shift corresponds to division/multiplication by powers of 2 (no • 0001 0101 << 2 21 overflow problem) • Three shift instructions: “ sll” (shift left logical), “ sra” (shift right • 0000 0101 << 3 0 0 0 1 0 1 0 1 arithmetic), and “srl” (shift right logical), corresponding to <<, >> 84 and >>>. Exercise 0 1 0 1 0 1 0 0 • The shift logical instructions fill the vacated bits with 0 • 0000 1100 << 3 • The shift right arithmetic instruction fills the vacated 5 bits with the sign bit. 0 0 0 0 0 1 0 1 • These instructions can be used to extract fields out of a 40 bit pattern, and interpret them as either unsigned or 0 0 1 0 1 0 0 0 signed numbers.
COMPSCI210 S1C 2009 41 COMPSCI210 S1C 2009 42
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. -43 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. SRA (sign fill) >> x 1 1 0 1 0 1 0 1 SRL (zero fill) >>> x 1 1 0 1 0 1 0 1 Examples -22 Example 1 1 1 0 1 0 1 0 0 1 1 0 1 0 1 0 • 1101 0101 >> 1 • 11010101 >>> 1 • 0001 0101 >> 2 21 • 0001 0101 >>> 2 22 • 1001 0011 >> 3 x 0 0 0 1 0 1 0 1 • 1001 0011 >>> 2 x 0 0 0 1 0 1 0 1
5 5 Exercise 0 0 0 0 0 1 0 1 Exercise 0 0 0 0 0 1 0 1 • 1010 0001 >> 3 • 1010 0001 >>> 3 -109 -109 x 1 0 0 1 0 0 1 1 x 1 0 0 1 0 0 1 1 -14 36 1 1 1 1 0 0 1 0 0 0 1 0 0 1 0 0 -14 -13 5 6 5.25 -13.625 COMPSCI210 S1C 2009 43 COMPSCI210 S1C 2009 44
11 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 6. Hexadecimal & Octal Notation 6. Hexadecimal & Octal Notation Hexadecimal Notation Octal Notation It is often convenient to write binary (base-2) numbers It is often convenient to write binary (base-2) numbers as hexadecimal (base-16) numbers instead. as octal (base-8) numbers instead. • fewer digits -- four bits per hex digit • fewer digits – three bits per octal digit • less error prone -- easy to corrupt long string of 1’s and 0’s Binary Octal Decimal 000 0 0 Binary Hex Decimal Binary Hex Decimal 001 1 1 0000 0 0 1000 8 8 010 2 2 0001 1 1 1001 9 9 011 3 3 0010 2 2 1010 A 10 100 4 4 0011 3 3 1011 B 11 101 5 5 0100 4 4 1100 C 12 110 6 6 0101 5 5 1101 D 13 111 7 7 0110 6 6 1110 E 14 0111 7 7 1111 F 15 COMPSCI210 S1C 2009 45 COMPSCI210 S1C 2009 46
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Converting from Decimal to Octal/Hexadecimal Converting from Octal/Hexadecimal to Decimal Decimal -> Octal Octal to Decimal • 127 • 122 8 = 1 x 82 + 2 x 81 + 7 x 80 = 64 + 16 + 7 = 87
• 220 • 2358 = 2 x 82 + 3 x 81 + 5 x 80 = 128 + 24 + 5 = 157 Decimal -> Hexadecimal • 1940 Hexadecimal to Decimal
• 1A716 = 1 x 162 + 10 x 161 + 7 x 160 • 175 = 256 + 160 + 7 = 423
• 23E16 = 2 x 162 + 3 x 161 + 14 x 160 = 512 + 48 + 14 = 574
COMPSCI210 S1C 2009 47 COMPSCI 105 Handout 02 48
12 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Exercise Binary -> Octal/Hexadecimal Decimal -> Octal Binary -> Octal • 1234 • Every three bits is a octal digit • Start grouping from right-hand side Decimal -> Hexadecimal • 0101 1111 • 689 • 1101 0001 • Exercise: 101101001 Octal to Decimal • 151 Binary -> Hexadecimal • Every four bits is a hex digit Hexadecimal to Decimal • Start grouping from right-hand side • 0101 1111 • 15B • 1101 0001 • Exercise: 101001101
COMPSCI210 S1C 2009 49 COMPSCI210 S1C 2009 50
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Octal -> Binary/Hexadecimal Hexadecimal -> Binary/Octal Octal -> Binary Hexadecimal -> Binary • 363 • EA3 • 247 • 2A7 • Exercise: 123 • Exercise: 1F3
Octal -> Hexadecimal Hexadecimal -> Octal • EA3 • 363 • 2A7 • 247 • Exercise: 1F3 • Exercise: 123
COMPSCI210 S1C 2009 51 COMPSCI210 S1C 2009 52
13 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Text: ASCII Characters Interesting Properties of ASCII Code •What is relationship between a decimal digit ('0', '1', …) ASCII: Maps 128 characters to 7-bit code. and its ASCII code? • both printable and non-printable (ESC, DEL, …) characters •What is the difference between an upper-case letter ('A', 'B', …) and its lower-case equivalent ('a', 'b', …)?
•Given two ASCII characters, how do we tell which comes first in alphabetical order?
Minimal memorizing effort allows you to retain more than 50 character ASCII code!!
Are 128 characters enough? (http://www.unicode.org/) No new operations -- integer arithmetic and logic.
COMPSCI210 S1C 2009 53 COMPSCI210 S1C 2009 54 Hexadecimal characters ASCII code
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Other Data Types LC-3 Data Types Text strings Some data types are supported directly by the • sequence of characters, terminated with NULL (0) instruction set architecture. • typically, no hardware support Image For LC-3, there is only one hardware-supported data type: • array of pixels • 16-bit 2’s complement signed integer monochrome: one bit (1/0 = black/white) • Operations: ADD, AND, NOT color: red, green, blue (RGB) components (e.g., 8 bits each) other properties: transparency Other data types are supported by interpreting • hardware support: 16-bit values as logical, text, fixed-point, etc., typically none, in general-purpose processors in the software that we write. MMX -- multiple 8-bit operations on 32-bit word Sound • sequence of fixed-point numbers
COMPSCI210 S1C 2009 55 COMPSCI210 S1C 2009 56
14