Assembly Language - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Assembly Language

Description:

Basic Concepts. Assembly Language is the oldest programming language ... C , C#, Java, or Visual Basic. What is an assembler? ... – PowerPoint PPT presentation

Number of Views:227
Avg rating:3.0/5.0
Slides: 21
Provided by: Wflo5
Category:

less

Transcript and Presenter's Notes

Title: Assembly Language


1
Assembly Language
  • Chapter 1

2
Basic Concepts
  • Assembly Language is the oldest programming
    language
  • Bears closest resemblance to the native language
    of a computer
  • Provides direct access to a computers hardware
  • Thus, you have to understand a great deal about
    the computers architecture and OS

3
Basic Concepts 1.1.1 Questions
  • What background should I have?
  • C, C, Java, or Visual Basic.
  • What is an assembler?
  • A program that converts source-code programs from
    assembly into machine language
  • A companion program, called a linker, combines
    individual files created by the assembler.
  • A third program called a debugger allows a
    programmer to trace the execution of a program
  • Most popular assemblers are TASM by Borland and
    MASM by Microsoft

4
Basic Concepts 1.1.1 Questions
  • What hardware and software do I need?
  • Editor simple text editor to create the
    assembly language code such as TextPad by Helios
    Software supplied in the CD-ROM or NotePad or the
    MS VS editor
  • Assembler --- MASM (6.15) supplied in the CD-ROM
    or TASM (by Borland)
  • Linker Two linkers are supplied LINK.EXE (16
    bit) or LINK32.EXE (32 bit)
  • Debugger For MS-DOS programs, MASM supplies a
    good 16-bit debugger called CodeView. Or MS
    (msdev.exe)

5
Basic Concepts 1.1.1 Questions
  • What types of programs will I create?
  • 16-Bit Real Address Mode If your running pure
    MS-DOS or a DOS emulator, you can create 16-bit
    Real address mode programs.
  • 32-Bit Protected Mode If your using Microsoft
    Windows, you can create 32-bit Protected mode
    programs that display both text and graphics

6
Basic Concepts 1.1.1 Questions
  • How does assembly language relate to machine
    language?
  • First, machine language is a numeric language
    that is specifically understood by a computers
    processor (the CPU). Intel processors for
    example, have a machine language that is
    automatically understood by other Intel
    processors. Machine language consists purely of
    numbers
  • Assembly Language --- consists of statements that
    use short mnemonics such as ADD, MOV, SUB, and
    CALL. An Assembly language instruction has a
    one-to-one relationship with a machine language
    instruction

7
Basic Concepts 1.1.1
  • How do C and Java relate to assembly language?
  • High-level languages such as C and Java have a
    one-to-many relationship with both assembly
    language and machine language. A single
    statement in C, for example, expands into
    multiple assembly language or machine
    instructions.

8
Basic Concepts Example one to many
relationship
  • C code example
  • X (Y 4 ) 3
  • Turns into .
  • mov eax, Y
  • add eax, 4
  • mov ebx, 3
  • imul ebx
  • mov X, eax

9
Basic Concepts
  • Is Assembly Language portable?
  • Assembly language instructions are tied to a
    specific processor thus it makes no attempt to be
    portable
  • Why learn assembly language?
  • Working towards a degree in computer engineering
  • May be a dedicated game programmer with stringent
    memory restrictions
  • Help you gain an overall understanding of
    interactions between computer hardware , OS and
    application prog
  • Working as a hardware manufacture to create
    device drivers

10
Chapter 1.3
  • Binary Numbers
  • A computer stores instructions and data in memory
    as collections of electronic charges
  • 1 for on or True 0 for off or False
  • Binary numbers are base 2 numbers each binary
    digit called a bit (either 0 or 1)
  • Bits are numbered at zero on the right side,
    increasing towards the left
  • The bit on the left is called the Most
    Significant bit (MSB)
  • The bit on the right is called the Least
    Significant Bit (LSB)

11
Chapter 1.3
  • Unsigned Binary Integers
  • 1 1 1 1 1 1
    1 1
  • 27 26 2 5 24 23 22 21
    20
  • Translating Unsigned Binary to Decimal
  • Dec (Dn-1 X 2n-1) (D1 X 21) (D0 X 20)
  • Short cut (exp) or Double dabble method

12
Chapter 1.3
  • Translating Unsigned Decimal Integers to Binary
  • Repeatedly divide the decimal value by 2, saving
    each remainder as a binary digit.
  • The first remainder is D0 then D1, D2, D3 so on

13
Chapter 1.3.2
  • Binary Addition
  • 0 0 0
  • 0 1 1
  • 1 0 1
  • 1 1 1 0

14
Chapter 1.3.3
  • Integer Storage Sizes
  • Basic storage Size in IA-32 based computer is a
    byte, containing 8 bits
  • Other storage sizes
  • Word (2 bytes) 16 bits
  • Doubleword (4 bytes) 32 bits
  • Quadword (8 bytes) 64 bits

15
Chapter 1.3.4 Hexadecimal Integer
  • Large binary numbers are cumbersome to read, so
    hexadecimal digits are usually used by assemblers
    and debuggers to represent binary data.
  • Each digit in a hexadecimal integer represents
    four binary bits and two hexadecimal digits
    together represent a byte.

16
Chapter 1.3.4 Hexadecimal Integers
  • A single hexadecimal digit can have a value from
    0 to 15, so the letters A to F are used, as well
    as the digits 0-9
  • The letter A10, B11, C12, D13, E14, and F
    15.
  • Example
  • 0001 0110 1010 0111 1001 0100
  • 1 6 A 7 9 4

17
Chapter 1.3.4.1 Converting Unsigned Hexadecimal
to Decimal
  • In hexadecimal, each digit position represents a
    power of 16. For example in a 4-digit hexadecimal
    integer
  • Dec(D3 X 163) (D2 X 162) (D1 X 161)
    (D0 X 160)
  • Example 3BA4 15,268

18
Chapter 1.3.4.2 Converting Unsigned Decimal to
Hexadecimal
  • To convert an unsigned decimal integer to
    hexadecimal
  • Repeatedly divide the decimal value by 16, and
    keep each remainder as a hexadecimal digit.
  • Example 422 to hexadecimal
  • Turns into 1A6 collecting the digits in reverse
    order. Last Reminder goes first and so on

19
Chapter 1.3.5 Signed Integers
  • Signed binary integers can be either positive or
    negative.
  • In general, the most significant bit (MSB)
    indicates the numbers sign.
  • A value of 0 indicates that the integer is
    positive, and 1 indicates that it is negative

20
1.3.5.1 Twos Complement Notation
  • Negative integers are represented using what is
    called twos complement representation.
  • The twos complement of an integer is simply its
    additive inverse.
  • The twos complement of a binary integer is found
    by reversing its bits and adding 1.
  • Twos complement representation is useful to
    processor designers because it removes the need
    for separate digital circuits to handle both
    addition and subtraction.
  • For example if faced with the expression A-B, the
    processor can simply convert it to an addition
    expression A (-B)
Write a Comment
User Comments (0)
About PowerShow.com