Essentials of 80x86 Assembly Language - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

Essentials of 80x86 Assembly Language

Description:

Collection of flags, or status bits. Records information about many operations ... Printable characters. Uppercase M codes as 4D16 = 10011012. Lowercase m codes ... – PowerPoint PPT presentation

Number of Views:206
Avg rating:5.0/5.0
Slides: 31
Provided by: richard101
Category:

less

Transcript and Presenter's Notes

Title: Essentials of 80x86 Assembly Language


1
Chapter 1 Data in a Computer
2
1.1 Binary and Hexadecimal Numbers
3
Decimal Numbers
  • Base 10
  • 4053 3 x 1 5 x 10 0 x 102 4 x 103

1s
10s
100s
1000s
4
Binary Numbers
  • Base 2, using bits (binary digits) 0 and 1
  • 10111 1 x 1 1 x 2 1 x 22 0 x 23 1 x 24

1s
101112 2310
2s
4s
8s
16s
5
Hexadecimal Numbers
  • Base 16
  • Digits
  • 0-9 same as decimal
  • A for 10
  • B for 11
  • C for 12
  • D for 13
  • E for 14
  • F for 15

6
Hexadecimal to Decimal
  • Base 16
  • 5CB 11 x 1 12 x 16 5 x 162

5CB16 148310
1s
16s
256s
7
Converting decimal to hex
  • Use a calculator that does hex calculations, or
  • Use this algorithm
  • until DecimalNumber 0 loopdivide DecimalNumber
    by 16, getting Quotient and RemainderRemainder
    (in hex) is the next digit (right to
    left)DecimalNumber Quotient
  • end until

8
1.2 80x86 Memory
9
80x86 Memory
  • Collection of slots each of which holds one
    byte (8 bits)
  • Each slot identified by a 32-bit physical address
  • The flat memory model encodes 32 bit addresses in
    instructions

10
Memory Units
  • 1Kb 210 1,024 (about a thousand),
  • 1Mb 220 1,048,576 (about a million)
  • 1Gb 230 1,073,741,824 (about a billion)

11
1.3 80x86 Registers
12
80x86 Registers
  • Internal to CPU rapidly accessed
  • Used in arithmetic and other operations

13
General Registers
  • EAX, EBX, ECX, EDX, each 32 bits long
  • The low-order 16 bits can be referenced by AX,
    BX, CX and DX, respectively
  • The low-order 8 bits can be referenced by AL, BL,
    CL and DL, respectively
  • Bits 8-15 can be referenced by AH, BH, CH and CH,
    respectively
  • EAX is called the accumulator and sometimes has
    special instruction formats associated with it

14
Index Registers
  • ESI, 32-bit source index used for
  • Source address in string moves
  • Array index
  • General purposes
  • EDI, 32-bit destination index used for
  • Address of destination in string moves
  • Array index
  • General purposes

15
Stack Pointer, Base Pointer and Segment Registers
  • ESP, 32-bit stack pointer
  • Holds address of top of stack
  • EBP, 32-bit base pointer
  • Used in procedure calls to hold address of
    reference point in the stack
  • Segment Registers used in segmented memory model
  • CS, DS, ES, FS, SS, GS
  • Each 16 bits long holding a segment selector
  • Managed by the operating system with flat memory
    model programming

16
Other Registers
  • EIP, 32-bit instruction pointer
  • Holds address of next instruction to be fetched
    for execution
  • EFLAGS, 32-bit
  • Collection of flags, or status bits
  • Records information about many operations

17
1.4 Character Codes
18
Character Codes
  • Letters, numerals, punctuation marks and other
    characters are represented in a computer by
    assigning a numeric value to each character
  • The system commonly used with microcomputers is
    the American Standard Code for Information
    Interchange (ASCII)

19
Examples of ASCII Codes
  • Printable characters
  • Uppercase M codes as 4D16 10011012
  • Lowercase m codes as 6D16 11011012
  • Numeral 5 codes as 3516
  • Space codes as 2016
  • Control characters
  • Backspace codes as 0816

20
1.5 2's Complement Representation for Signed
Integers
21
Standard Number Lengths
  • Byte 8 bits
  • Word 16 bits
  • Doubleword 32 bits
  • Quadword 64 bits

22
Unsigned Representation
  • Just binary in one of the standard lengths
  • E47A is the word-length unsigned representation
    for the decimal number 58490

23
Signed Representation
  • 2s complement representation used in 80x86
  • One of the standard lengths
  • High-order (leading) bit gives sign
  • 0 for positive
  • 1 for negative
  • Must perform 2s complement operation to find
    corresponding positive number

24
2s Complement Operation
  • /- button on many calculators
  • Manually by subtracting from 1000
  • E47A represents a negative word-length signed
    number since E 1110
  • 10000 E47A 1B86 704610,so E47A is the 2s
    complement signed representation for -7046

minus
25
1.6 Integer Addition and Subtraction
26
Addition
  • Same for unsigned and 2s complement signed
    numbers, but the results may be interpreted
    differently
  • The two numbers will be byte-size, word-size or
    doubleword-size
  • Add the bits and store the sum in the same length
    as the operands, discarding an extra bit (if any)

27
Carry
  • If the sum of two numbers is one bit longer than
    the operands, the extra 1 is a carry (or carry
    out).
  • A carry is recorded in the carry flag CF (bit 0
    in the EFLAGS register), not in the standard
    length result.
  • For unsigned numbers, a carry means that the
    result is too large to be stored in the length of
    the operands.

28
Carry In
  • A 1 carried into the high-order (sign, leftmost)
    bit position during addition is called a carry
    in.
  • Byte-length example

carry in
carry out
29
Overflow
  • Overflow occurs when there is a carry in but no
    carry out, or when there is a carry out but no
    carry in. It is recorded in OF (bit 11 of
    EFLAGS).
  • If overflow occurs when adding two signed
    numbers, then the result will be incorrect.
  • Word-length example
  • Overflow, so AC99 incorrectif viewed as sum of
    signed numbers
  • No carry, so AC99 correct ifviewed as sum of
    unsigned numbers

483F 645A AC99
30
Subtraction
  • Take the 2s complement of second number and add
    it to the first number
  • Overflow occurs in subtraction if it does not
    occur in the corresponding addition
  • CF is set for a borrow in subtraction when the
    second number is larger than the first as
    unsigned numbers
Write a Comment
User Comments (0)
About PowerShow.com