Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Chapter 1: Basic Concepts Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine 9/6/2003.

Similar presentations


Presentation on theme: "1 Chapter 1: Basic Concepts Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine 9/6/2003."— Presentation transcript:

1 1 Chapter 1: Basic Concepts Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine 9/6/2003

2 2 Introduction u 1.1 Welcome to Assembly Language (Important: Read this section!) u 1.2 Virtual Machine Concept u 1.3 Data Representation u 1.4 Boolean Operations

3 3 1.1 Welcome to Assembly Language: Why study assembly language? u Learn about computers –Computer architecture –Operating systems –Data representation –Hardware devices u Learn about assembly languages u Learn about compiling u Learn how to write embedded programs u Learn the assemble language for Intel 80x86

4 4 1.1 Welcome to Assembly Language: Uses of assembly language u Communicating with the operating system u Optimize critical areas of applications –Minimize size –Maximize speed u Avoid restrictions of high level languages u Access to hardware (drivers)

5 5 1.1 Welcome to Assembly Language: Definitions u Assembly language: machine-specific language with a one-to-one correspondence with the machine language for that computer u Machine language: The language a particular processor understands u Assembler: converts programs from assembly language to machine language

6 6 1.1 Welcome to Assembly Language: Example u u u u Assembly Language: High-Level Language: Machine language: x = a + b; MOV AX, a ADD AX, b MOV x, AX A1 0002 06 0004 A3 0000

7 7 1.1 Welcome to Assembly Language: Problems with assembly language u Provides no structure u Is not portable u Applications can be very long u “Hard” to read and understand u Lots of detail required

8 8 1.3 Data representation: Binary Numbers u Digital computers store information in binary u Binary allows two states –On yes true 1 –Off no false 0 u All information on digital computers is ultimately 0’s and 1’s

9 9 1.3 Data representation: Data types u byte: 8 bits: 00010101 u word: 16 bits or __ bytes: 0101011011000101 u double word: __ bits or __ bytes : 01010110110001011101011011001011 u quad word: __ bits or __ bytes: 01011110110101011101010011001011 01010110110001011101011011001101

10 10 1.3 Data representation: Range of a unsigned byte u Question: What is the range of numbers that can be represented with u 1 bit? u 2 bits? u 3 bits? u 4 bits? u 6 bits?

11 11 1.3 Data representation: Range of the data types u byte: 0 to 2 8 - 1 = 255 u word: 0 to 2 16 - 1 = 64K - 1 = 65,535 u double word: 0 to 4G - 1 = _____ u quad word: 0 to 18x10 18 Unsigned integers:

12 12 1.3 Data representation: Different bases u System Digits u Binary __ u Octal 0 1 2 3 4 5 6 7 u Decimal _______________ u Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F

13 13 1.3 Data representation: Number systems (bases) u Number systems used –Binary: The internal representation inside the computer. They may be represented in binary, decimal, or hexadecimal. –Decimal: The system people use. u ASCII representations of numbers used for I/O: –ASCII binary –ASCII octal –ASCII decimal –ASCII hexadecimal

14 14 1.3 Data representation: Binary Addition & Multiplication u Binary addition table + 0 1 0 0 1 1 1 10 u Binary multiplicaton * 0 1 0 0 0 1 0 1

15 15 1.3 Data representation: Binary Addition & Multiplication u Examples: 1101100b 1010b + 1101010b * 1101b u 10110100b 111101b + 1101101b * 1011b

16 16 1.3 Data representation: Hex Addition & Multiplication u Hex addition and multiplication tables are large u We can still do simple calculations by hand B852h 23Ah + 5A65h * 100h u ABCh 2B3h + E F 0 h * 102h

17 17 1.3 Data representation: Converting to decimal u 12345 = 1 * 10 4 + 2 * 10 3 + 3 * 10 2 + 4 * 10 1 + 5*10 0 u (Human) conversions: hex to decimal ABCh = 10*16 2 + 11*16 1 + 12 *16 0 = 10*256 + 11*16 + 12*1 = 2560 + 176 + 12 = 2748

18 18 1.3 Data representation: Converting to decimal u (Human) conversions to decimal ABCDh = (((10*16+11)*16+12)*16+13 = 43981 (easier on calculator)

19 19 1.3 Data representation: Conversion problems u 111010b = ________ 10 u 1234 base 5 or (1234) 5 =_________ 10

20 20 1.3 Data representation: Conversion from decimal u (Human) conversions from decimal 2748 10 = ??? In hex u 2748 = 171 * 16 + 12 u 171 = 10 * 16 + 11 10 = 0 * 16 + 10 so value is ABCh 2748 = 171 * 16 +12 = (10*16 + 11) * 16 + 12 = 10 * 16 2 + 11 * 16 1 + 12 * 16 0 = ABCh How do we know this is the Hex representation?

21 21 1.3 Data representation: Conversion problems u Write decimal 58 in binary. u Write decimal 194 in base 5

22 22 1.3 Data representation: Conversions: hex and binary u Conversion between base 10 and base 1000 = 10 3 u 1,234,567 = 1*1000 2 + 234*1000 1 + 567*1000 0 u Conversion between base 2 and base 16 = 2 4 111010b = 11 1010 = 3Ah u 3Ah = 11 1010b u Note: we often write binary numbers in hex because: –binary numbers can be very long –it is easy to convert back and forth

23 23 1.3 Data representation: Conversion problems u Write ABCh in binary. u Write 101110100010100b in hex. u Write 101110100010100b in octal

24 24 1.3 Data representation: Comments u It is EXTREMELY important to get good at hex and binary –conversion –addition.

25 25 1.3 Data representation: Signed numbers u Signed numbers: The number of bits must be fixed. In every case, the left hand bit is the sign bit. u 0 means + u 1 means -

26 26 1.3 Data representation: Signed numbers u We will look at 3 representations in 6 bits. u sign and magnitude 10d = 001010b -10d = 101010b u one’s complement 10d = 001010b -10d = 110101b (one’s complement)

27 27 1.3 Data representation: Two’s complement u two’s complement 10d = 001010b 110101 (one’s complement) + 1 -10d = 110110b (two’s complement) u 001001 (one’s complement) + 1 10d = 001010b (two’s complement) u Two’s complement is used for signed integers on most computers

28 28 1.3 Data representation: Practice problems u Find the 8 bit two’s complement representation of -2Ch u Find the 8 bit two’s complement representation of 2Ch u What is decimal representation of the two’s complement number 11110100?

29 29 1.3 Data representation: Signed numbers - Comments u The representation of positive numbers is the same in all three systems u The representation of negative numbers differs between the 3 systems u There are two ways to write 0 in sign and magnitude representations and in one’s complement

30 30 1.3 Data representation: Signed numbers - Comments u Two's complement: Sizes Signed byte: -128 to +127 = 2 7 - 1 Signed word: -32,768 to +32,767 = 2 15 - 1 Singed double word: -2,147,483,648 to +2,147,483,647 = 2 31 - 1 u Observe there is one more negative than positive value u There are (about) half as many positive signed values as unsigned values

31 31 1.3 Data representation: Signed numbers - Comments u Vocabulary: “Find the two’s complement of” vs. “Find the two’s complement representation of”

32 32 1.3 Data representation: Signed numbers - Comments u Why is two’s complement the most popular way of representing signed integers?

33 33 1.3 Data representation: Signed numbers - Comments u Algorithm to add in signed decimal (sign and magnitude) If both numbers have the same sign Add the two magnitudes Prefix with the common sign else Subtract the number with smaller magnitude from the number with the larger magnitude Prefix with the sign of the number with the larger magnitude.

34 34 1.3 Data representation: Signed numbers - Comments u Two's complement: Just add numbers even if one or both are negative u (Assume 6 bit two’s complement) 00 1011 = 11 -11 0101 = -11 + 11 1010 = -6 +00 0110 = + 6 00 0101 = 5 11 1011 = -5 u To subtract, take the two’s complement of the number being subtracted and add

35 35 1.3 Data representation: Character Storage u Characters are stored as numbers u Coding schemes –ASCII (7 or 8 bit) –EBCDIC (8 bit) –Unicode (16 bit) u ASCII Examples: “A” = 65d = 41h “a” = 97d = 61h “B” = 66d = 42h “b” = 98d = 62h “0” = 48d = 30h “1” = 49d = 31h “ “ = 32d = 20h “*” = 42d = 2Ah

36 36 1.3 Data representation: What does a number represent? u What is CD21h (1100 1101 0010 0001b)? u Unsigned integer: 52513 u Signed integer (two’s complement): -13023 u (one’s complement): -13022 u (sign and magnitude): -19745 u Instruction: INT 21h u MS-DOS characters: ! u Windows characters: Í! u Two 1 byte numbers: CDh, 21h Line drawing character

37 37 1.4 Boolean Operations Boolean Algebra u Values: true and false u Invented by George Boole u Boolean operations NOT AND OR

38 38 1.4 Boolean Operations Boolean Algebra u X Not X false true true false X Y X and Y X or Y false false false false false true false true true false true true true true true true

39 39 1.4 Boolean Operations Boolean Algebra Example: X and not Y X Y Not Y X and not Y false false true false false true false false true false true true true true false false

40 40 1.4 Boolean Operations Boolean Algebra u Problem: not (X and Y) or Z

41 41 u CSCE 380 u Department of Computer Science and Computer Engineering u Pacific Lutheran University u 9/6/2003


Download ppt "1 Chapter 1: Basic Concepts Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine 9/6/2003."

Similar presentations


Ads by Google