Sie sind auf Seite 1von 6

Computer Registers

A register is a very small amount of very fast memory that is built into the CPU (central processing unit) in order
to speed up its operations by providing quick access to commonly used values. Registers refers to
semiconductor devices whose contents can be accessed (i.e., read and written to) at extremely high speeds
but which are held there only temporarily (i.e., while in use or only as long as the power supply remains on).
Registers are the top of the memory hierarchy and are the fastest way for the system to manipulate data.
Registers are normally measured by the number of bits they can hold, for example, an 8-bit register means it
can store 8 bits of data or a 32-bit register means it can store 32 bit of data.
Registers are used to store data temporarily during the execution of a program. Some of the registers are
accessible to the user through instructions. Data and instructions must be put into the system. So we need
registers for this.
The basic computer registers with their names, size and functions are listed below
Register Symbol
AC
DR
TR
IR
AR
PC
INPR
OUTR

Register Name
Accumulator
Data Register
Temporary Register
Instruction Register
Address Register
Program Counter
Input Register
Output Register

Number of Bits
16
16
16
16
12
12
8
8

Description
Processor Register
Hold memory data
Holds temporary Data
Holds Instruction Code
Holds memory address
Holds address of next instruction
Holds Input data
Holds Output data

Registers are the most important components of CPU. Each register performs a specific function. A brief
description of most important CPU's registers and their functions are given below:
1. Memory Address Register (MAR):
This register holds the address of memory where CPU wants to read or write data. When CPU wants to store
some data in the memory or reads the data from the memory, it places the address of the required memory
location in the MAR.
2. Memory Buffer Register (MBR):
This register holds the contents of data or instruction read from, or written in memory. The contents of
instruction placed in this register are transferred to the Instruction Register, while the contents of data are
transferred to the accumulator or I/O register.
In other words you can say that this register is used to store data/instruction coming from the memory or going
to the memory.
3. I/O Address Register (I/O AR):
I/O Address register is used to specify the address of a particular I/O device.
4. I/O Buffer Register (I/O I3R):
I/O Buffer Register is used for exchanging data between the I/O module and the processor.
5. Program Counter (PC)

Program Counter register is also known as Instruction Pointer Register. This register is used to store the
address of the next instruction to be fetched for execution. When the instruction is fetched, the value of IP is
incremented. Thus this register always points or holds the address of next instruction to be fetched.
6. Instruction Register (IR):
Once an instruction is fetched from main memory, it is stored in the Instruction Register. The control unit takes
instruction from this register, decodes and executes it by sending signals to the appropriate component of
computer to carry out the task.
7. Accumulator Register:
The accumulator register is located inside the ALU, It is used during arithmetic & logical operations of ALU. The
control unit stores data values fetched from main memory in the accumulator for arithmetic or logical operation.
This register holds the initial data to be operated upon, the intermediate results, and the final result of
operation. The final result is transferred to main memory through MBR.
8. Stack Control Register:
A stack represents a set of memory blocks; the data is stored in and retrieved from these blocks in an order,
i.e. First In and Last Out (FILO). The Stack Control Register is used to manage the stacks in memory. The size
of this register is 2 or 4 bytes.
9. Flag Register:
The Flag register is used to indicate occurrence of a certain condition during an operation of the CPU. It is a
special purpose register with size one byte or two bytes. Each bit of the flag register constitutes a flag (or
alarm), such that the bit value indicates if a specified condition was encountered while executing an instruction.
For example, if zero value is put into an arithmetic register (accumulator) as a result of an arithmetic operation
or a comparison, then the zero flag will be raised by the CPU. Thus, the subsequent instruction can check this
flag and when a zero flag is "ON" it can take, an appropriate route in the algorithm.

Debugging Definition
Posted by Margaret Rouse
WhatIs.com

Contributor(s): Tom Davis

In computers, debugging is the process of locating and fixing or


bypassing bugs (errors) in computer program code or the engineering of
a hardware device. To debug a program or hardware device is to start with a
problem, isolate the source of the problem, and then fix it. A user of a program
that does not know how to fix the problem may learn enough about the
problem to be able to avoid it until it is permanently fixed. When someone

says they've debugged a program or "worked the bugs out" of a program, they
imply that they fixed it so that the bugs no longer exist.
Debugging is a necessary process in almost any new software or hardware
development process, whether a commercial product or an enterprise or
personal application program. For complex products, debugging is done as
the result of the unit test for the smallest unit of a system, again at component
test when parts are brought together, again at system test when the product is
used with other existing products, and again during customer beta test, when
users try the product out in a real world situation. Because most computer
programs and many programmed hardware devices contain thousands of
lines of code, almost any new product is likely to contain a few bugs.
Invariably, the bugs in the functions that get most use are found and fixed first.
An early version of a program that has lots of bugs is referred to as "buggy."
Debugging tools (called debuggers) help identify coding errors at various
development stages. Some programming language packages include a facility
for checking the code for errors as it is being written.
Getting started with debugging
To explore how debugging is used in the enterprise, here are some additional
resources for getting started:
Better software through debugging and unit testing
Bugs plague software project big and small, and today's complicated software makes
debugging more difficult than ever. Let these tips, tutorials, podcasts and articles help
you debug your software.

Debugging in Assembly Mode


If you have C or C++ source files for your application, you can use the debugger much more
powerfully if you debug in source mode.
However, there are many times you cannot perform source debugging. You might not have the
source files for your application. You might be debugging someone else's code. You might not
have built your executable files with full .pdb symbols. And even if you can do source debugging
on your application, you might have to trace Microsoft Windows routines that your application
calls or that are used to load your application.
In these situations, you have to debug in assembly mode. Moreover, assembly mode has many
useful features that are not present in source debugging. The debugger automatically displays
the contents of memory locations and registers as they are accessed and displays the address of
the program counter. This display makes assembly debugging a valuable tool that you can use
together with source debugging.

Disassembly Code
The debugger primarily analyzes binary executable code. Instead of displaying this code in raw
format, the debuggerdisassembles this code. That is, the debugger converts the code from
machine language to assembly language.
You can display the resulting code (known as disassembly code) in several different ways:
The u (Unassemble) command disassembles and displays a specified section of machine
language.
The uf (Unassemble Function) command disassembles and displays a function.
The up (Unassemble from Physical Memory) command disassembles and displays a specified
section of machine language that has been stored in physical memory.
The ur (Unassemble Real Mode BIOS) command disassembles and displays a specified 16-bit
real-mode code.
The ux (Unassemble x86 BIOS) command disassembles and displays the x86-based BIOS code
instruction set at a specified address.
(WinDbg only) The Disassembly window disassembles and displays a specified section of
machine language. This window is automatically active if you select the Automatically Open
Disassembly command on the Window menu. You can also open this window by
clicking Disassembly on the View menu, pressing ALT+7, or pressing theDisassembly
(Alt+7) button (
) on the WinDbg toolbar.
The disassembly display appears in four columns: address offset, binary code, assembly
language mnemonic, and assembly language details. The following example shows this display.
0040116b

45

inc

0040116c

fc

cld

0040116d

8945b0

mov

ebp
eax,[ebp-0x1c]

To the right of the line that represents the current program counter, the display shows the
values of any memory locations or registers that are being accessed. If this line contains a
branch instruction, the notation [br=1] or [br=0]appears. This notation indicates a branch that
is or is not taken, respectively.
You can use the .asm (Change Disassembly Options) command to change how the
disassembled instructions are displayed.
In WinDbg's Disassembly window, the line that represents the current program counter is
highlighted. Lines where breakpoints are set are also highlighted.
You can also use the following commands to manipulate assembly code:
The # (Search for Disassembly Pattern) command searches a region of memory for a specific
pattern. This command is equivalent to searching the four columns of the disassembly display.
The a (Assemble) command can take assembly instructions and translate them into binary
machine code.
Assembly Mode and Source Mode
The debugger has two different operating modes: assembly mode and source mode.
When you are single-stepping through an application, the size of a single step is one line of
assembly code or one line of source code, depending on the mode.
Several commands create different data displays depending on the mode.
In WinDbg, the Disassembly window automatically moves to the foreground when you run or
step through an application in assembly mode. In source mode, the Source window moves to
the foreground.
To set the mode, you can do one of the following:
Use the l+, l- (Set Source Options) command to control the mode. The l-t command activates
assembly mode.
(WinDbg only) Clear the Source Mode command on the Debug menu to cause the debugger to
enter assembly mode.You can also click the Source mode off button (
) on the toolbar.
In WinDbg, when you are in assembly mode, ASM appears visible on the status bar.
The shortcut menu in WinDbg's Disassembly window includes the Highlight instructions from
the current source linecommand. This command highlights all of the instructions that
correspond to the current source line. Frequently, a single source line corresponds to multiple
assembly instructions. If code has been optimized, these assembly instructions might not be
consecutive. The Highlight instructions from the current source line command enables you
to find all of the instructions that were assembled from the current source line.
Assembly Language Source Files
If your application was written in assembly language, the disassembly that the debugger
produces might not exactly match your original code. In particular, NO-OPs and comments will
not be present.

If you want to debug your code by referencing the original .asm files, you must use source mode
debugging. You can load the assembly file like a C or C++ source file. For more information
about this kind of debugging, see Debugging in Source Mode.

Das könnte Ihnen auch gefallen