chapter 2 parts of a computer system

21
Chapter 2 Parts of a Computer System

Upload: klarika-farkas

Post on 01-Jan-2016

71 views

Category:

Documents


0 download

DESCRIPTION

Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory. 80x86 Memory. Collection of “slots” each of which holds one byte (8 bits) Each slot identified by an address 32-bit systems use 32-bit addresses 64-bit systems use 64-bit addresses. Memory Units. - PowerPoint PPT Presentation

TRANSCRIPT

Chapter 2Parts of a Computer System

2.1 PC Hardware: Memory

80x86 Memory

• Collection of “slots” each of which holds one byte (8 bits)

• Each slot identified by an address– 32-bit systems use 32-bit addresses– 64-bit systems use 64-bit addresses

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)

2.1 PC Hardware: The CPU

CPU’s Function

• Fetch instruction from memory

• Decode instruction

• Execute instruction

• Store results

80x86 Registers

• Internal to CPU – rapidly accessed

• Used in arithmetic and other operations

• 64-bit CPUs have larger and more registers

General Registers, 32-bit CPUs

• 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

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

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

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

• Carry Flag (CF) is bit 0• Zero Flag (ZF) is bit 6• Sign Flag (SF) is bit 7• Overflow Flag (OF) is bit 11

Registers in 64-bit CPUs• RAX, RBX, RCX, RDX, RSI, RDI, RSP,

RBP, RIP, RFLAGS extend the 32-bit registers– Low-order 32 bits of RAX can be referenced by

EAX; similarly for other registers

• R8 – R15 are new 64-bit general-use registers– Low-order 32-bits of R8 can be referenced by

R8D– Low-order 16 bits by R8W; 8 bits by R8B

2.3 PC Hardware: I/O Devices

Input/Output

• At the hardware level, I/O ports are used– 64K port addresses

• Since the instructions that access ports are unavailable in ordinary application programming, I/O is typically done by calls to operating system routines

2.4 PC Software

Operating System

• Manages program execution

• Provides access to I/O devices

• Provide user interface– Command line interface (e.g., DOS)– Graphical user interface (e.g., Windows)

Text Editors

• Used to create source programs or data files

• Notepad comes with Windows

• Word processors add extra formatting information– not normally used for creating assembly

language source files

Language Translators

• Interpreters translate each high-level language source code line every time it is needed for execution

• Compilers translate HLL source code to object code that is almost ready for the CPU to execute

• Assemblers translate assembly language – a low level language – to object code

Linker

• Object code files produced by a compiler or assembler are not quite ready for execution

• A linker combines object code files and prepares them to be loaded into memory for execution

Debugger

• Allows the programmer to control execution of a program– Step through instructions one at a time– Stop at a preset breakpoint

• Lets you look at memory or register contents– Helps find programming errors– Helps understand how the computer works

Integrated Development Environment

• Single interface provides access to text editor, compiler or assembler, linker and debugger

• Microsoft Visual Studio is an IDE