CS 301 Fall 2001 Chapter 2 - PowerPoint PPT Presentation

About This Presentation
Title:

CS 301 Fall 2001 Chapter 2

Description:

Loading a .EXE program. The system loader. Accesses the .EXE program from the disk ... the operation, store results in register or memory, set any required flags. ... – PowerPoint PPT presentation

Number of Views:46
Avg rating:3.0/5.0
Slides: 13
Provided by: chrish66
Learn more at: https://www.cs.uaf.edu
Category:
Tags: chapter | fall | register

less

Transcript and Presenter's Notes

Title: CS 301 Fall 2001 Chapter 2


1
CS 301 Fall 2001 Chapter 2
  • Slides by Prof. Hartman, following IBM PC
    Assembly Language Programming by Peter Abel

2
Operating Systems
  • File management
  • Input/Output
  • Program Loading
  • Memory Management
  • Interrupt Handling

3
BIOS boot process
  • When you turn on the computer it resets, clears
    all memory to 0, performs a parity check of all
    memory, sets CSFFFF0H and IP0.
  • BIOS (in ROM) starting at FFFF0H checks ports to
    identify and initialize devices and then
    establishes the Interrupt Vector Table and the
    BIOS data areas. It then accesses a bootstrap
    loader from the disk for the operating system.
  • Programs access devices through the OS, through
    BIOS, or directly.

4
System loader
  • Executable programs are .EXE or .COM
  • .COM programs have one segment for code, data,
    and the stack
  • .EXE programs have separate segments.

5
Loading a .EXE program
  • The system loader
  • Accesses the .EXE program from the disk
  • Constructs a 256 byte program segment prefix
    (PSP)
  • Stores the program in memory following the PSP
  • Loads the address of the PSP into DS and ES
  • Loads the address of the code segment into CS and
    sets IP to the offset of the first instruction
    (usually zero).
  • Loads the address of the stack into SS and sets
    SP to the size of the stack.
  • Transfers control to the program

6
The Stack
  • Three main uses
  • Saving return addresses for subroutines
  • Passing data to subroutines
  • Temporarily saving contents of registers so the
    program can use those registers for computation.

7
The Stack 2
  • SS contains the address of the beginning of the
    stack, SP contains the size of the stack (and
    thus points to one address past the end of the
    stack)
  • The stack begins storing data at the highest
    location in the segment and stores data downward
    through memory using PUSH and POP (and other)
    instructions. (See example, page 25.)

8
Stack Instructions
  • PUSH, POP to and from general register, segment
    register, or memory
  • PUSHA, POPA save and restore contents of all
    general purpose registers (16 bytes)
  • PUSHF, POPF save and restore contents of the
    flags
  • PUSHAD, POPAD save and restore contents of all
    extended registers. (32 bytes)

9
Instruction Execution and Addressing
  • Processor steps in executing an instruction
  • Fetch next instruction from memory and place it
    in instruction queue
  • Decode the instruction calculate addresses for
    memory references, deliver data to the ALU,
    increment IP
  • Execute the instruction perform the operation,
    store results in register or memory, set any
    required flags.

10
Pipelining
  • The Pentium architecture overlaps operations, as
    in this (simplified) example

11
Instructions and Operands
  • Instructions are operations the CPU can perform
    such as PUSH, MOV, etc.
  • Each instruction can have zero, one, two, or
    three operands what it operates on.

12
Example of Assembly code
  • Note the difference between this and the example
    on page 29 of the text. In the third line,
    WORDX is used (NASM syntax) rather than WORDX
    (MASM syntax)
Write a Comment
User Comments (0)
About PowerShow.com