chapter 2 parts of a computer system. 2.1 pc hardware: memory

21
Chapter 2 Parts of a Computer System

Upload: matilda-pearson

Post on 29-Jan-2016

255 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

Chapter 2Parts of a Computer System

Page 2: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

2.1 PC Hardware: Memory

Page 3: 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

Page 4: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

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)

Page 5: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

2.1 PC Hardware: The CPU

Page 6: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

CPU’s Function

• Fetch instruction from memory

• Decode instruction

• Execute instruction

• Store results

Page 7: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

80x86 Registers

• Internal to CPU – rapidly accessed

• Used in arithmetic and other operations

• 64-bit CPUs have larger and more registers

Page 8: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

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

Page 9: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

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

Page 10: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

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

Page 11: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

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

Page 12: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

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

Page 13: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

2.3 PC Hardware: I/O Devices

Page 14: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

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

Page 15: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

2.4 PC Software

Page 16: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

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)

Page 17: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

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

Page 18: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

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

Page 19: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

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

Page 20: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

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

Page 21: Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory

Integrated Development Environment

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

• Microsoft Visual Studio is an IDE