Chapter 2 Parts of a Computer System - PowerPoint PPT Presentation

1 / 73
About This Presentation
Title:

Chapter 2 Parts of a Computer System

Description:

Chapter 2 Parts of a Computer System-----how the memory and CPU look to the assembly language programmer for IBM PC and compatible systems ... – PowerPoint PPT presentation

Number of Views:163
Avg rating:3.0/5.0
Slides: 74
Provided by: SUNF154
Category:

less

Transcript and Presenter's Notes

Title: Chapter 2 Parts of a Computer System


1
Chapter 2 Parts of a Computer System
  • -----how the memory(??) and CPU look to the
    assembly language programmer for IBM PC and
    compatible(??) systems which have Intel 80x86 CPU

2
Aims
  • Introduce memory system in IBM PC
  • Introduce registers(???) in 80X86 CPU
  • Introduce I/O device
  • Introduce software used in assembly language
    programming

3
Outcomes
  • Master the concepts , model of the memory in IBM
    PC
  • Master the registers in 80x86 CPU
  • Mater the software that used in programming with
    assembly language
  • Know I/O device in IBM PC

4
PC computer system
  • Hardware
  • Central processing unit (CPU), memory circuits,
    keyboard, monitor and other input/output device
  • Software
  • Refers to the programs that the hardware executes
  • System software
  • Application software

5
History of Intel CPU
  • We will discuss PC based on Intel CPU.So lets
    look at the history of Intel CPU.

6
The Microprocessor Age
  • 4-bit microprocessors
  • Intel 4004, the worlds first one, 1971
  • Intel 4040, an updated version of 4004
  • 8-bit microprocessors
  • Intel 8008, 8080,8085
  • Motorola MC6800, Zilog Z80

7
The Modern Microprocessor
  • In 1978, Intel released the 8086 microprocessor
    a year or so later, it released the 8088. Both
    devices are 16-bit microprocessors. They can run
    faster than 8085 and address(??) 1M bytes of
    memory.

16-bit CPU
8
The Intel family of microprocessors
  • 8086/8088, 80186/80188
  • 80286
  • 80386
  • 80486
  • Pentium, MMX Pentium
  • Pentium II, Pentium Pro
  • Pentium III
  • Pentium 4, Pentium TH

IA-32 Intel 32-bit Architecture
9
The Future of Microprocessors
  • Lots of new technology, used for parallel
    processing (????)
  • Superscalar (???)
  • Superpipelining (?????)
  • SIMD (Single instruction multiple data)
  • Hyper-Threading(???)
  • 64-bit microprocessor
  • EPIC (Explicitly Parallel Instruction Computing)
    in Itanium

10
Personal Computer System
  • Memory system (?????)DRAM, SRAM, Cache, ROM,
    EEPROM, Flash memory
  • I/O system (??????)Mouse, Keyboard, Monitor ,
    Disk drive, DVD drive, Printer, Plotter, Scanner
  • Microprocessor (????) CPU (central processing
    unit ??????)
  • Bus (??)
  • Data bus, control bus,address bus

11
2.1 PC hardware Memory
  • Memory in an IBM PC or compatible microcomputer
    is logically a collection of slots, each of
    which can store one byte(??) of instructions or
    data

12
Little Endian
  • How to store a word (two bytes) in the
    memory?--Intels method little endian (????)
  • The low byte goes to the low memory location, and
    the high byte goes to the high memory address.
  • An alternate method big endian (????)

13
Data in memory
low
34h
12h
78h
56h
high
14
RAM ROM
  • Read-only memory (ROM)
  • Permanently retain their contents and can be read
    from but not written to.
  • Random access memory (RAM)
  • Can be written to read from by program
    instructions
  • The contents of RAM chips are lost when the
    computers power is turned off

15
Physical address (????)
  • Each memory byte has a 32-bit/20-bit numeric
    label called physical address

16
Prior to the 80386 chip
  • Processors has 20-bit address bus, so they can
    only directly address 220 bytes of memory.
  • Range from 00000h to FFFFFh
  • 1M

17
Up to 80386
  • Processors has 32-bit address bus, so they can
    only directly address 232 bytes of memory.
  • From 00000000h to FFFFFFFFh
  • A PC can contain up to four gigabytes memory

We'll mainly discuss IA-32
18
Memory models (????)
  • 32-bit memory model
  • Flat memory model (??????)
  • Segmented memory model (??????)
  • 16-bit memory model
  • Real address mode memory model(???????)

19
Real address memory mode(?????)
  • Real address allows the CPU to address only the
    first 1M bytes of memory space, which is called
    either the real memory (????) or conventional
    memory (?????).
  • Memory is visualized as a collection of segments,
    each segment 64Kbytes long, starting on an
    address that is multiple of 16.(paragraph)
  • A segment is a section (an area) of memory.

20
Segment (?)
  • The CPU may use many segments in the program. For
    instance, a typical assembly language program
    consists of at least three segments
  • code segment (???)
  • (holds the code, i.e. programs or procedures)
  • data segment (???)
  • (contains the most data used in a program)
  • stack segment (???)
  • (the area of memory used for the stack)

21
Memory reference
  • Memory reference depends on its segment number
    and a 16-bit offset from the beginning of the
    segment.
  • Normally only offset is encoded, and the segment
    number is deduced from the context.

22
Logical address and physical address
  • In the real mode, the physical address (????) is
    the 20-bit address that is actually put on the
    address bus. This address can have a range of
    00000H FFFFFH.
  • The logical address (????) consists of a segment
    address and an offset address.
  • Well use logical address in programming.
  • Segment address offset address

23
Segments and offsets
  • A combination of a segment address and an offset
    address access a memory location in the real
    mode.
  • segment address (???) the beginning address of
    any 64K-byte memory segment
  • offset address (????) the location within the
    64K-byte segment range, the distance or
    displacement (???) above the start of the segment

24
Segment address
  • In real mode, a segment is 64K in length and can
    begin only at a 16-byte boundary.
  • 16-byte boundary means that least significant
    four bits are 0000b. This 16-byte boundary (such
    an address ends in 0H) is often called a
    paragraph (?).
  • Segment address
  • is most significant 16 bits of starting address
  • Segment number consists of the first four hex
    digits of its physical address.

25
Offset address
  • Offset is the distance from the first byte of the
    segment to the byte being addressed.
  • A segment is limited to 64K byte (16-bit) in the
    real mode, therefore an offset address can range
    from 0000H to FFFFH.
  • The offset address is added to the start of the
    segment to address a memory location (physical
    address) within the memory segment.

Segment address Starting address Offset address Memory location
1000H AB00H 1234H 10000H AB000H 12340H 2000H 3405H 0100H 12000H AE405H 12440H
26
Conversion from logical address to physical
address
  • Add the starting address of the segment and the
    offset

logical address segment address offset address physical address
1000H 2000H AB00H 3405H 1234H 0100H 12000H AE405H 12440H
  • The physical address is calculated by shifting
    segment value one hex digit and adding the offset
    value.

27
32-bit segmented memory model (from 386)
  • segment numbers are 16-bit long and used as an
    index into a table that contains the actual
    32-bit starting addressing of the segment
  • add 32-bit offset and starting address to compute
    the actual 32-bit address
  • map the 32-bit address into physical addresses by
    paging mechanism

28
segmentation
selector(???)
Logical address
offset(32bit)
segment number(16bit)
Linear address space (??????)
Global descriptor table (GDT)
segment

line address



global descriptor (???)

segment base address (????)
29
Paging is optional. If paging is not used, the
linear address can be directly mapped into
physical address.
paging
Linear address space (??????)
physical address space
Line address
page

physical address


segment

line address


Dir. table offset
page table

Entry

page directory

Entry

page
30
paging mechanism
  • Layer of memory management performed by the
    operating system and the Intel 80x86 CPU
  • Paging mechanism is transparent to programmer
  • Useful when logical address generated by the
    program exceeds the physical memory address

31
for programmer
  • assigns different memory segments to code ,data
    and a system stack.

32
Flat memory model
  • Programs will actually encode 32-bit addresses to
    logically reference locations in a single memory
    space where data and instructions are stored.
  • Is really a 32-bit segmented model with all
    segment registers containing the same value.

33
2.2 PC Hardware CPU
  • The X86 CPUs contain 16 program-visible
    registers.
  • Registers is internal storage location that can
    be accessed much more rapidly than a locations in
    RAM.
  • They are used during application programming and
    are specified by the instructions using their
    names.They are used to store information
    temporarily.

34
Application registers
  • Multipurpose (or general-purpose)
    registers(?????)
  • Special-purpose registers(?????)
  • Segment registers(????)

35
IA-32 operating modes(????)
  • Protected mode(????)
  • Real address mode(?????)
  • System management mode SMM(??????)

36
Protected mode
  • Native state of IA-32.
  • Cab directly execute 16-bit software in
    protected, multitasking environment.
  • Virtual 8086 mode(??8086??)

37
Real address mode
  • Implementing the programming environment of 8086
    CPU with extension.
  • Can switch to protected mode
  • Original mode following power-up or reset.

38
System management mode SMM
  • This mode provides an operating system or
    executive with a transparent mechanism for
    implementing platform-specific functions such as
    power management and system security.

39
Data registers / general registers
  • EAX (AX) accumulator ???
  • EBX (BX) base index ?????
  • ECX (CX) count ???
  • EDX (DX) data ?????

40
8-, 16- and 32-bit registers
  • Eight 8-bit general-purpose registers
  • AH, AL, BH, BL, CH, CL, DH, DL
  • H means high byte in the 16-bit register
  • L means low byte in the 16-bit register
  • AH and AL form AX,
  • Eight 16-bit general-purpose registers
  • AX, BX, CX, DX, BP, DI, SI, SP
  • Eight 32-bit general-purpose registers
  • EAX, EBX, ECX, EDX, EBP, EDI, ESI, ESP
  • E means 32-bit extended

41
Special purpose registers
  • EIP (IP) instruction pointer ????
  • ESP (SP) stack pointer ????
  • EDI (DI) destination index ???????
  • ESI (SI) source index ??????
  • EBP (BP) base pointer ????

42
EIP (IP)
  • EIP addresses the next instruction to be fetched
    in a section of memory defined as a code segment
    (???).
  • EIP points to the next instruction, but can be
    modified with a jump (??) or call (??)
    instruction.
  • Cannot be directly accessed by programmer
  • This register is IP (16 bits) in the real mode
    (???) and EIP (32 bits) in the protected mode
    (????).

43
Pipelining mechanism(?????)
  • Prefetching(??) instruction
  • Starting execution of an instruction before it
    finishes execution of prior instructions
  • Increase effective processor speed

44
ESP (SP)
  • ESP addresses an area of memory called stack.
  • The stack (??) memory is accessed using a LIFO
    (last-in, first-out ????) method.
  • ESP points to the top of the stack, but will be
    modified with a push or pop instruction.
  • This register is SP (16 bits) in the real mode
    and ESP (32 bits) in the protected mode.

45
EBP(BP)
  • Mark a fixed slot in the stack
  • This register is BP (16 bits) in the real mode
    and EBP (32 bits) in the protected mode.

46
EFLAGS (?????)
  • EFLAGS indicate the condition of the
    microprocessor and control its operation.
  • The 16-bit CPU only contain a 16-bit FLAG
    register, which has nine flags
  • CF, PF, AF, ZF, SF and OF are called conditional
    flags (???????)
  • indicate condition that resulted after an
    instruction was executed.
  • TF, DF, and IF are called control flags (????)
  • control the operation of instructions before they
    are executed.

47
CF (carry flag ????)
  • Carry holds the carry after addition or the
    borrow after subtraction.
  • The carry flag also indicates error conditions as
    dictated by some programs and procedures.

48
PF (parity flag ????)
  • Parity is a count of ones in a number expressed
    as even (??) or odd (??).
  • Parity is a logic 0 for odd parity and a logic 1
    for even parity.
  • If a number contains odd binary one bits, it has
    odd parity. If a number contains zero or even
    binary one bits, it has even parity.

49
ZF (zero flag ???)
  • The zero flag shows that the result of an
    arithmetic (??) or logic (??) operation is zero.
  • If the result is zero, ZF1 If the result is not
    zero, ZF0.

50
SF (sign flag ????)
  • The sign flag holds the arithmetic sign of the
    result after an arithmetic or logic instruction
    executes.
  • If SF1, the sign bit (leftmost bit of a number)
    is set (??) or negative (?) If SF0, the sign
    bit is cleared (?????) or positive (?) .

51
OF (overflow flag ????)
  • Overflow occurs when signed numbers are added or
    subtracted. For unsigned operation, the overflow
    flag is ignored.
  • An overflow indicates that the result has
    exceeded the capacity of the machine.

52
Segment registers
  • A segment register (16-bit) defines the starting
    address of a segment.
  • CS code segment
  • DS data segment
  • SS stack segment
  • ES extra segment (an additional data segment
    ???)
  • FS and GS supplemental segment registers
    available in the 80386 and above

53
Numbers in segment registers
  • Real address memory mode
  • Number in segment registers are segment address.
  • Segmented memory mode
  • Number in segment registers are selectors
  • Flat memory mode
  • Irreverent to programmer
  • All segment register have the same number.

54
2.3 PC Hardware Input/Output Devices
  • separate port address
  • port address are distinct from ordinary memory
    addresses, use instruction to output data or read
    data from these ports.
  • Memory-mapped input/output
  • Use addresses in the regular memory address space
    for I/O device access.

55
80x86 architecture
  • separate port address
  • 64K port addresses
  • a typical I/O device uses three or eight ports

56
2.4 PC Software
  • Software refers to the programs or procedures
    executed by the hardware.
  • System software(????)
  • Operating system(????)
  • Application software (????)
  • Text Editors (?????)
  • Language Translators and Linker

57
Operating system
  • Software to run other programs.
  • DOS
  • Command line interface, prompt
  • Windows
  • Graphical user interface
  • Linux
  • Open codes

58
Text Editors (?????)
  • Software to create or modify text files that are
    stored on the disk
  • Text file is a collection of ASCII codes.
  • Source code files are text file
  • Notepad, Word processor,Edit
  • The extension name of assembly source file is
    .ASM
  • Example test.asm

59
Language Translators
  • Language translators are programs that translate
    a programmers source code into a form that can
    be executed by the computer.
  • Interpreters(???)
  • Compliers(???)

60
Interpreters
  • Interpretersdirectly decipher(??) a source
    program
  • Interpreter looks at a line of source code and
    follows the instructions of that line
  • Slowly

61
Compliers(???)
  • Compliers starts with source code and produce
    object code that consists mostly of instructions
    to be executed by the intended CPU.
  • Assembler(????) like a complier, translates
    assembly language into machine code.
  • ML.exe

62
How to use ML.EXE
63
LINKER(????)
  • LINKER link object code to make a program that
    can be executed.
  • Link.exe
  • 16-bit
  • 32-bit

64
How to use link
65
Debugger(???,????)
  • Debugger allows a programmer to control
    execution of a program, pausing after each
    instruction or at a preset breakpoint.
  • Debug.exe
  • Windbg.exe
  • SoftIce.exe

66
Integrated Development Environments IDE(??????)
  • Use a single interface to access an editor, a
    complier, and a linker.
  • MASM32

67
MASM32
68
BUILDbuildc.bat 1
_at_echo off if exist "1.obj" del "1.obj" if
exist "1.exe" del "1.exe" REM
?? \masm32\bin\ml /c /coff "1.asm" if errorlevel
1 goto errasm
69
BUILDbuildc.bat 2
REM ?? \masm32\bin\Link /SUBSYSTEMCONSOLE
/OPTNOREF "1.obj" if errorlevel 1 goto
errlink dir "1." goto TheEnd
70
BUILDbuildc.bat 3
errlink echo Link error goto TheEnd errasm echo
Assembly Error goto TheEnd TheEnd pause
71
After build
72
Run program
73
Exercises
  • P30. Exercises 2.1-- 2,3
  • P34. Exercises 2.2--1, 2, 3
  • P34 Exercises 2.3--1, 2
Write a Comment
User Comments (0)
About PowerShow.com