Uploaded by Mark Banana

Computer Systems Module 1 to 4 FEU TECH

advertisement
COMPUTER SYSTEMS AND
PLATFORM TECHNOLOGIES
IT0047
MODULE 3
DOS & DEBUG Commands
MODULE 3.1
DOS Commands
At the end of the lesson, the student should be able to :
• Define MSDOS
• Identify the types of DOS Commands
• Identify the most used DOS Commands
This tutorial gives you an opportunity to try basic MS-DOS commands. By
following the procedures in this section, you will learn to:
• View the contents of a directory
• Change from one directory to another
• Create and delete directories
• Change from one drive to another
• Copy files o Rename files
• Delete files o Format a floppy disk
When you first turn on your computer, you will see some cryptic
information flash by. MS-DOS displays this information to let you know
how it is configuring your computer. You can ignore it for now. When the
information stops scrolling past, you'll see the following:
C:\>
This is called the command prompt or DOS prompt. The flashing
underscore next to the command prompt is called the cursor. The cursor
shows where the command you type will appear.
This section explains how to type a command at the command prompt
and demonstrates the "Bad command or file name" message.
1. To type a command at the command prompt
Type the following at the command prompt (you can type the command in
either uppercase or lowercase letters):
nul
If you make a typing mistake, press the BACKSPACE key to erase the
mistake, and then try again.
2. Press ENTER
You must press ENTER after every command you type.
The following message appears:
Bad command or file name
The "Bad command or file name" message appears when you type
something that MSDOS does not recognize. Because nul is not a valid MSDOS command, MS-DOS displays the "Bad command or file name"
message.
3. Now, type the following command at the command prompt:
ver
The following message appears on your screen:
MS-DOS version 6.22
In this section, you will view the contents of a directory by using the dir
command. The dir command stands for "directory.“
• To view the contents of a directory
1. Type the following at the command prompt:
dir
A list similar to the following appears:
This is called a directory list. A directory list is a list of all the files and
subdirectories that a directory contains. In this case, you see all the files
and directories in the main or root directory of your drive. All the files and
directories on your drive are stored in the root directory.
Look at the list on your screen. All the names that have
beside them are directories. You can see a list of the files in another
directory by changing to that directory, and then using the dir command
again. In this case, you will change to the DOS directory
Before you begin this section, make sure you have a directory named DOS
by carrying out the following procedure
• To make sure you have a directory named Windows
If you do not see a line in the directory list indicating that you have a
directory named Windows, type the following at the command prompt:
dir /s Windows
• You will see a message that includes a line such as the following:
Directory of C:\DIRNAME
To change from the root directory to the WINDOWS directory
• To change directories, you will use the cd command. The cd command
stands for "change directory.“
• Type the following at the command prompt:
cd windows
• The command prompt changes. It should now look like the following:
C:\WINDO
Next, you will use the dir command to view a list of the files in the DOS
directoryWS>
To view a list of the files in the WINDOWS directory
1. Type the following at the command prompt:
Dir
A list of the files in the WINDOWS directory appears, but scrolls by too
quickly to read. You can modify the dir command so that it displays only
one screen of information at a time.
To view the contents of a directory one screen at a time
• Type the following at the command prompt:
dir /p
One screen of information appears. At the bottom of the screen, you will
see the following message:
Press any key to continue
• To view the next screen of information, press any key on your keyboard.
Repeat this step until the command prompt appears at the bottom of
your screen
When you typed the dir command this time, you included the /p switch
after the command. A switch modifies the way MS-DOS carries out a
command. Generally, a switch consists of a forward slash (/) that is
followed by one or more letters or numbers. When you used the /p switch
with the dir command, you specified that MS-DOS should pause after it
displays each screen of directory list information. The p actually stands for
"page
Another helpful switch you can use with the dir command is the /w switch.
The /w switch indicates that MS-DOS should show a wide version of the
directory list.
o To view the contents of a directory in wide format
1. Type the following at the command prompt:
Dir
The directory list appears, with the filenames listed in wide format. Note
that only filenames are listed. No information about the files' size or date
and time of creation appears.
/w
If the directory contains more files than will fit on one screen, you can
combine the /p and /w switches as follow
dir /w /p
Next, you will change from the DOS directory to the root directory. The
root directory is the directory you were in before you changed to the DOS
directory. Before you begin this section, make sure your command prompt
looks like the following:
C:\DOS>
o To change to the root directory
1. Type the following at the command prompt:
cd \
Note that the slash you type in this command is a backslash (\), not a
forward slash (/)
No matter which directory you are in, this command always returns you to
the root directory of a drive. The root directory does not have a name. It is
simply referred to by a backslash (\).
The command prompt should now look like the following:
C:\>
When your command prompt appears similar to this---that is, when it
does not contain the name of a directory---you are in the root directory.
In this section, you will create two directories. Creating a directory is
helpful if you want to organize related files into groups to make them easy
to find. Before you begin this section, make sure the command prompt
looks like the following
C:\>
To create a directory, you will use the md command. The md command
stands for "make directory."
To create and change to a directory named FRUIT
Type the following at the command prompt:
md fruit
You have now creat ed a directory named FRUIT. You won't see the new
FRUIT directory until you carry out the dir command in the next step.
2. To confirm that you successfully created the FRUIT directory, type the
following at the command prompt:
Dir
Or
dir /p
To create and work with a directory named GRAPES
Type the following at the command prompt:
md grapes
r
You will not see the new GRAPES directory until you carry out the dir
command in the next step.
To confirm that you successfully created the GRAPES directory, type the
following at the command prompt:
r
Note that there are three entries in the FRUIT directory. One is the
GRAPES directory that you just created. There are two other
entries---one looks like a single period (.) and the other looks like a
double period (..). These directory entries are important to
MSDOS, but you can ignore them. They appear in every directory
and cont ain information
The GRAPES directory is a subdirectory of the FRUIT directory. A
subdirectory is a directory within another directory. Subdirectories
are useful if you want to further subdivide information.
To change to the GRAPES directory,
type the following at the
r
command prompt:
cd grapes
The command prompt should now look like the following:
C:\FRUIT\GRAPES>
. To switch back to the FRUIT directory, type the following:
cd ..
The command prompt should now look like the following
C:\FRUIT>
r
When the cd command is followed by two periods (..), MS-DOS
moves up one level in the directory structure. In this case, you
moved up one level from the GRAPES directory to the FRUIT
directory
If you no longer use a particular directory, you may want to delete
it to simplify your directory structure. Deleting a directory is also
useful if you type the wrong name when you are creating a
directory and you want to delete ther incorrect directory before
creating a new one.
In this section, you will delete the GRAPES directory. Before you
begin this section, make sure the command prompt looks like the
following:
C:\FRUIT>
To delete a directory, use the rd command. The rd command
stands for "remove directory.“
To delete the GRAPES directory
To delete the GRAPES directory
Type the following at the command prompt:
rd grapes
To confirm that you successfully deleted
the GRAPES directory,
r
type the following at the command prompt:
dir
The GRAPES directory should no longer appear in the directory
list.
Note You cannot delete a directory if you are in it. Before you can
delete a directory, you must make the directory that is one level
higher the current directory. To do this, type cd.. at the command
prompt.
This section describes how to change drives. Changing drives is
useful if you want to work with files that are on a different drive.
So far, you have been working with driveC. You have other drives
you can use to store information. For
example, drive A is your first
r
floppy disk drive. The files and directories on drive A are located
on the floppy disk in the drive. (You might also have a drive B,
which contains the files and directories stored on the floppy disk in
that drive.)
Before you begin this section, make sure your command prompt
looks like the following:
C:\FRUIT>
To change to and view files on a different drive
1. Insert a 3.5" floppy disk in drive A label- side up. Make sure the
disk clicks into the drive.
Type the following at the command rprompt:
a:
Note that the command prompt changed to the following:
A:\>
This message may appear:
Not ready reading drive
A Abort, Retry, Fail?
If you see this message, the disk may not be inserted properly.
Place the disk label-side up in the disk drive, and make sure the
disk clicks into the disk drive. Then, type r for Retry. If this
message appears again, press F forr Fail, and then type b: at the
command prompt. If you no longer see this message, type b:
instead of a: throughout the rest of the tutorial.
There must be a floppy disk in the drive that you want to change
to.
Change back to drive C by typing the following at the command
prompt:
c:
Your command prompt should return
to the following:
r
C:\FRUIT>
When you type a drive letter followed by a colon, you change to
that drive. The drive letter that appears in the command prompt
shows which drive is the current drive. Unless you specify
otherwise, any commands you type are carried out on the current
drive and in the current directory
This section describes how to copy a single file and a group of files.
Copying files creates a duplicate of the original file and does not
remove the original file. This is useful for many reasons. For example,
if you want to work on a document at
home, you can copy it from your
r
computer at work to a floppy disk and then take the floppy disk home.
To copy a file, you will use the copy command. When you use the copy
command, you must include two parameters. The first is the location
and name of the file you want to copy, or the source. The second is the
location to which you want to copy the file, or the destination. You
separate the source and destination with a space. The copy command
follows this pattern:
copy source destination
Copying a Single File
In this section, you will copy the notepad.exe files from the WINDOWS
directory to the FRUIT directory. You will specify the source and
r
destination of these files in two different
ways. The difference between
the two methods is explained at the end of this section.
Before you begin this section, make sure the command prompt looks
like the following:
C:\FRUIT>
To copy the NOTEPAD.EXE files from the WINDOWS directory to the
FRUIT directory
Return to the root directory by typing the following at the command
prompt:
cd\
The command prompt should now look like the following:
r
C:\>
Change to the DOS directory by typing the following at the command
prompt:
cd windows
Make sure the file you are going to copy, NOTEPAD.EXE, is located in
the WINDOWS directory by using the dir command followed by a
filename.
dir notepad.exe
To copy the NOTEPAD.EXE file from the WINDOWS directory to the
FRUIT directory, type the following at the command prompt:
copy c:\windows\notepad.exe c:\fruit
The following message appears:
r
1 file(s) copied
To confirm that you copied the files successfully, view the contents of
the FRUIT directory by typing the following at the command prompt:
dir \fruit
You should see the file listed in the FRUIT directory
This section explains how to rename files. You may want to rename a
file if the information in it changes or if you decide you prefer another
name.
To rename a file, you will use the ren command. The ren command
stands for "rename." When you user the ren command, you must
include two parameters.
The first is the file you want to rename, and the second is the new
name for the file. You separate the two names with a space. The ren
command follows this pattern:
ren oldname newname
• Renaming a File
In this section, you will rename the README.TXT file
Before you begin this section, make sure your command prompt looks
like the following:
C:\FRUIT>
1. To rename the NOTEPAD.EXE file to PADNOTE.TXT, type the
r
following at the command prompt:
ren notpad.exe padnote.txt
2. To confirm that you renamed the file successfully, type the following
at the command prompt:
dir
This section explains how to delete, or remove, a file that you no
longer want on your disk. If you don’t have very much disk space,
deleting files you no longer use is essential.
To delete a file, you will use the del command. The del command
r
stands for "delete."
• Deleting a File
In this section, you will delete two files using the del command.
Before you begin, make sure your command prompt looks like the
following:
C:\FRUIT>
To delete the PEARCOM and PEAR.HLP files
1. Delete the PADNOTE.TXT file by typing the following at the
command prompt:
del PADNOTE.TXT
r files successfully, type the
2. To confirm that you deleted the
following at the command prompt:
dir
• Deleting a Group of Files
In this section, you will use wildcards to delete a group of files.
Before you begin this section, make sure your command prompt
looks like the following:
C:\FRUIT>
To delete files in the current directory that end with the extension
OLD by using wildcards
1. View all files that end with the extension OLD by typing the
following at the command prompt:
r
dir *.old
A list of all the files that end with the extension OLD appears. Make
sure that these are the files you want to delete. When you are
deleting files by using wildcards, this step is very important. It will
prevent you from deleting files accidentally.
2. Delete all files ending with OLD by typing the following at the
command prompt: del *.old 3. To confirm that all the files with the
extension OLD have been deleted, type the following at the
2. Delete all files ending with OLD by typing the following at the
command prompt:
del *.old
3. To confirm that all the files with the extension OLD have been
deleted, type the following at ther command prompt:
dir
The FRUIT directory should contain no files.
Now that the FRUIT directory is empty, you can delete it by using
the rd (remove directory) command that you learned to use in
"Deleting a Directory" earlier in this chapter.
2. Delete all files ending with OLD by typing the following at the
command prompt:
del *.old
3. To confirm that all the files with the extension OLD have been
deleted, type the following at ther command prompt:
dir
The FRUIT directory should contain no files.
Now that the FRUIT directory is empty, you can delete it by using
the rd (remove directory) command that you learned to use in
"Deleting a Directory" earlier in this chapter.
To delete the FRUIT directory
1. Return to the root directory by typing the following at the
command prompt:
cd \
r
2. You can see the FRUIT directory in the directory list by typing
the following at the command prompt:
dir or dir /p
3. Remove the FRUIT directory by typing the following at the
command prompt:
rd fruit
To verify that the FRUIT directory has been removed, type the
following at the command prompt:
dir or dir /p
The FRUIT directory should not appear
in the directory list.
r
MODULE 3.2
DEBUG
At the end of the lesson, the student should be able to :
• Define DEBUG
• Identify the most used DEBUG Commands
• Write a program with string manipulation using DEBUG
DOS offers a debugging utility as one of its external commands. The
DEBUG program is used for testing and debugging executable
programs. A feature of DEBUG is that it displays all program code and
data in hexadecimal format, and any
data that you enter into memory
r
must also be in hex format. DEBUG also provides a single-step mode,
which allows you to execute a program one instruction at a time, so
that you can view the effect of each instruction on memory locations
and registers.
• The prompt from the DEBUG program is a hyphen (-).
• A command is a single letter, usually followed by one or more
parameters. Commands become effective only after
ENTE00000000000R key is pressed.
r
• Commands are not case sensitive, can be uppercase or lowercase
letter or combination of both.
• Delimiters may separate commands and parameters. Delimiters are
only required, however, between two consecutive hexadecimal
values.
r
• R - Display the hexadecimal contents of all the register, and the flag
register current status and the next instruction to be executed.
r
• R <registername> - Display the contents of internal register and
with the option of changing those contents.
r
• The last line of the Register(R) command indicates the location in
memory of the next instruction to be executed and its machine
mnemonic code (unassembled) codesThe E (Enter) Command
displays and allows modification of bytes in a sequential manner.
Format: E <address>
Note: Address should contain
the code segment and
instruction pointer where you
want to modify.
To change the content of the address specified above, from 19h to
FFh, enter FF after the dot (.).
• The U (unassembled) command translates the contents of the
memory into its equivalent mnemonic code assembler – like
statements and displays their addresses.
Format: U <address>
Unassembled from the first address to last address specified in
Enter Command activity and translate each machine code into its
equivalent mnemonic code. Write down on the data sheet the
results of this activity.
Writing Down Program in DEBUG
Environment
The A instructions.
(Assemble) command lets you
enter mnemonic code assembly
language
Format: A <address>
• Assume for the address that will
serve as the offset address.
Assemble the following code into
memory location 1365:0100.
Saving the Program into the Disk
To write a file, you must first
initialize the name of the file.
Format: N <filename>.<ext>
The N command initializes a
filename in memory before using
load or write command.
In writing the program to the disk,
computer for the byte consumed by
the program then, store it in CX
(Count) Register. To compute,
subtract the starting address to the
last address covered by the
program plus 2.
Note: Computation is in
hexadecimal Arithmetic Operation
Consumed byte = (0118 – 0100) + 2
In writing the program to the disk,
computer for the byte consumed by
the program then, store it in CX
(Count) Register. To compute,
subtract the starting address to the
last address covered by the
program plus 2.
Note: Computation is in
hexadecimal Arithmetic Operation
Consumed byte = (0118 – 0100) + 2
The W ( write ) command writes a
block of memory to a file.
Executing the Program
Using the G (GO) command, it will
execute the assembled program.
Format: G
The T (trace) command executes one or
more instructions starting with the
instruction at CS:IP. The contents of all
register and flags after each execution
are also displayed.
Format: T
To make the task of programming in Assembly Programming easier,
DOS provides a set of instruction for character device I/O, file management,
memory management, data and time functions, execution of the other
programs, and others. This set of instructions is assigned as interrupt vector
21h, and each function can be called upon by the INT 21H instruction.
Using DOS Function
DOS Function INT 21H (“Function Dispatcher”) requires the function
number in register AH on entry only. Most of the function calls require input
to be passed to them in the other register.
1.
2.
3.
Set the proper register values required.
Place the function number in AH.
Issue interrupt type 21H.
Function : Direct Console Input without Echo
Purpose : Waits for a character to be read from the keyboard
then returns with the character in AL.
On Entry : AH = 07H
On Exit
: Character read from the keyboard.
Function : Character Output
Purpose : Outputs a character to the standard output device,
usually monitor screen. On Entry : AH = 02H
DL = ASCII code of the character to be output
On Exit
: NONE
Function : Character Input with Echo
Purpose : Waits for a character to be read from the keyboard, then
echoes it to the screen and return with the character in AL.
On Entry : AH = 01H
On Exit
: AL = Character read from the keyboard
Displaying strings on the screen and reading them from the keyboard
is entirely different from displaying or reading characters. ASCII codes
of all characters are only a byte, which would easily fit inside any of
the internal registers of the 8088. A function that displays a character
only needs the character to be displayed to be put in the DL register,
e.a. function 02h. Similarly, a function that reads a character from the
keyboard can easily get the character read in the register AL, e.a.
functions 01h and 07h.
A string is usually more than one character length. This leaves us
with the question: “Where then can a function that displays a string
put the string to be displayed?” The answer is
– the memory. Since string’s can’t usually fit in a register, strings are
then placed in the memory then pass the address of the string in
memory to two of the registers – the segment address and offset
address in DX.
Function : String Output
Purpose : Sends a string of characters to the standard output
device On Entry : AH = 09h
DS = Segment address of the first character of the string DX = Offset
address of the first character of the string
On Exit
: NONE
Note: Function 09h displays a string of characters starting with the
first character (address in DS:DX) output, but not including the
character “$” (ASCII -24h)
ASK ANY QUESTION RELATED TO OUR TOPIC
FOR TODAY.
COMPUTER SYSTEMS AND
PLATFORM TECHNOLOGIES
IT0047
MODULE 1
Data Manipulation
MODULE 1.1
Number System - Conversion
At the end of the lesson, the student should be able to :
• Identify the different number system as they relate to computers
• Identify the unit, number, base/radix, positional notation, least significant digit and
most significant digit
• Convert values from any number system to each other and back to other systems
Number Base
• What is a number base?
A number base is a specific collection of symbols on which a
number system can be built.
• The number base familiar to us is base 10, upon which the
decimal number system is built. There are ten symbols - 0 to 9 used in the decimal system.
4
Place Value
• What is the concept of place value?
Place value means that the value of a digit in a number
depends not only on its own natural value but also on its location
in the number.
It is used interchangeably with the term positional notation.
• Place value tells us that the two 4s in the number 3474 have
different values, that is, 400
and 4, respectively.
5
A Review of the Decimal Number System
• The word “decimal” comes from the Latin word decem, meaning
ten.
• Thus, the number base of the decimal number system is base 10.
• Since it is in base 10, ten symbols are used in the decimal number
system.
{0,1,2,3,4,5,6,7,8,9}
• This means that only the digits in the above set can be used for
each position in every place
value in a given decimal number.
6
A Review of the Decimal Number System
2
7
0
• Note that the highlighted place value can be filled by the digits in
the set {0,1,2,3,4,5,6,7,8,9}.
• Thus, it can be increased by 1 until it reaches 2
7
9
• At this point, the symbols that can be used to fill the highlighted
position has been exhausted. Increasing it further causes a shift in
place value and resets the initial place value to zero. Thus 2
8
0
7
A Review of the Decimal Number System
Case Study: 3474
Using place values, the number 3474 is understood to mean,
3000 + 400 + 70 + 4 = 3474
This can also be expressed as –
(3x1000) + (4x100) + (7x10) + 4 = 3474
Note that each digit is multiplied by powers of 10, so that the
above is equal to –
(3x103) + (4x102) + (7x101) + (4x100) = 3474
Note that the rightmost exponent starts from zero and increases
by 1 as the place value increases.
Hence, the decimal number system is said to be in base 10.
8
Base 2: The Binary Number System
• The word “binary” comes from the Latin word bis, meaning
double.
• Thus, the number base of the binary number system is base 2.
• Since it is in base 2, two symbols are used in the binary number
system.
{0,1}
• This means that only the digits in the above set can be used for
each position in every place
value in a given binary number.
9
Base 2: The Binary Number System
1
1
0
0
• Note that the highlighted place value can be filled by the digits in
the set {0,1}.
• Thus, it can be increased by 1 until it reaches 1
1
0
1
• At this point, the symbols that can be used to fill the highlighted
position has been exhausted. Increasing it further causes a shift
in place value, and resets the initial place value to zero. Thus 1
1
1
0
10
Base 2: The Binary Number System
• To avoid confusion, one should write a binary number with base
2 as its subscript whenever necessary.
• Thus, the binary number 10110 should be written as 101102
• It should be read as “one-zero-one-one-zero base two” and NOT
“ten-thousand one-hundred ten” since each phrase denotes an
entirely different number.
11
Base 2: The Binary Number System
Case Study: 101102
• We know that the decimal number 3474 can be expressed as
powers of 10 –
(3x103) + (4x102) + (7x101) + (4x100) = 347410
• In the same manner, the binary number 101102 can be expressed
as powers of 2 –
(1x24) + (0x23) + (1x22) + (1x21) + (0x20) = 2210
Note that the rightmost exponent starts from zero and increases
by 1 as the place value increases.
Hence, the binary number system is said to be in base 2.
12
Base 8: The Octal Number System
• The word “octal” comes from the Greek word oktõ, meaning eight.
• Thus, the number base of the octal number system is base 8.
• Since it is in base 8, eight symbols are used in the octal number
system.
{0,1,2,3,4,5,6,7}
• This means that only the digits in the above set can be used for
each position in every place
value in a given octal number.
13
Base 8: The Octal Number System
3
6
0
• Note that the highlighted place value can be filled by the digits in
the set {0,1,2,3,4,5,6,7}.
• Thus, it can be increased by 1 until it reaches 3
6
7
• At this point, the symbols that can be used to fill the highlighted
position has been exhausted. Increasing it further causes a shift
in place value, and resets the initial place value to zero. Thus 3
7
0
14
Base 8: The Octal Number System
• To avoid confusion, one should write an octal number with base 8
as its subscript whenever necessary.
• Thus, the octal number 72143 should be written as 721438
• It should be read as “seven-two-one-four-three base eight” and
NOT “seventy two-thousand one-hundred forty three” since each
phrase denotes an entirely different number.
15
Base 8: The Octal Number System
Case Study: 721438
• We know that the decimal number 3474 can be expressed as
powers of 10 –
(3x103) + (4x102) + (7x101) + (4x100) = 347410
• In the same manner, the octal number 721438 can be expressed
as powers of 8 –
(7x84) + (2x83) + (1x82) + (4x81) + (3x80) = 2979510
Note that the rightmost exponent starts from zero and increases
by 1 as the place value increases.
Hence, the octal number system is said to be in base 8.
16
Base 16: The Hexadecimal Number System
• The word “hexadecimal” is a combination of the Greek word hex,
meaning six and the Latin word decem, meaning ten.
• Thus, the number base of the hexadecimal number system is base
16.
• Since it is in base 16, sixteen symbols are used in the hexadecimal
number system.
{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}
• This means that only the digits in the above set can be used for
each position in every place value in a given hexadecimal number.
17
Base 16: The Hexadecimal Number System
A
3
B
0
• Note that the highlighted place value can be filled by the digits in
the set {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}.
• Thus, it can be increased by 1 until it reaches A
3
B
F
• At this point, the symbols that can be used to fill the highlighted
position has been exhausted. Increasing it further causes a shift
in place value, and resets the initial place value to zero. Thus A
3
C
0
18
Base 16: The Hexadecimal Number System
• To avoid confusion, one should write a hexadecimal number with
base 16 as its subscript whenever necessary.
• Thus, the hexadecimal number B23C should be written as B23C16
• It should be read as “b-two-three-c base sixteen”.
19
Base 16: The Hexadecimal Number System
Case Study: B23C16
• We know that the decimal number 3474 can be expressed as
powers of 10 –
(3x103) + (4x102) + (7x101) + (4x100) = 347410
• In the same manner, the hexadecimal number B23C16 can be
expressed as powers of 16 –
(11x163) + (2x162) + (3x161) + (12x160) = 4562810
Note that the rightmost exponent starts from zero and increases
by 1 as the place value increases.
Hence, the hexadecimal number system is said to be in base 16.
20
Comparative Values: Bases 10, 2, 8, 16
Base 10
Base 2
Base 8
Base 16
Decimal
Binary
Octal
Hexadecima
l
0
0000
0
0
1
0001
1
1
2
0010
2
2
3
0011
3
3
4
0100
4
4
5
0101
5
5
6
0110
6
6
7
0111
7
7
8
1000
10
8
21
Comparative Values: Bases 10, 2, 8, 16
Base 10
Base 2
Base 8
Base 16
Decimal
Binary
Octal
Hexadecima
l
9
1001
11
9
10
1010
12
A
11
1011
13
B
12
1100
14
C
13
1101
15
D
14
1110
16
E
15
1111
17
F
16
10000
20
10
17
10001
21
11
22
Conversion from Bases 2, 8, 16 to Base 10
• Technique: Expand the number using the appropriate base.
• Convert 110102 to base 10.
(1x24) + (1x23) + (0x22) + (1x21) + (0x20) = ?
(1x16) + (1x8) + (0x4) + (1x2) + (0x1)
16 + 8 + 0 + 2 + 0
=?
= 2610
• Convert 15378 to base 10.
(1x83) + (5x82) + (3x81) + (7x80) = ?
(1x512) + (5x64) + (3x8) + (7x1) = ?
(512) + (320) + (24) + (7)
= 86310
23
Conversion from Bases 2, 8, 16 to Base 10
• Technique: Expand the number using the appropriate base.
• Convert AF416 to base 10.
(Ax162) + (Fx161) + (4x160) = ?
(10x256) + (15x16) + (4x1) = ?
2560 + 240 + 4
= 280410
24
Conversion from Base 10 to Bases 2, 8, 16
• Technique: Divide the number using the appropriate base, then
repeatedly divide the resulting quotients by the same base until it
becomes zero. The answer is the combined remainders in
reverse order accumulated from the divisions. This technique is
called the remainder method.
• Convert 13310 to base 2.
133 ÷ 2 = 66
r. 1
66 ÷ 2 = 33
33 ÷ 2 = 16
16 ÷ 2 = 8
8÷2=4
4÷2=2
2÷2=1
1÷2=0
r. 0
r. 1
r. 0
r. 0
r. 0
r. 0
r. 1
Answer: 100001012
25
Conversion from Base 10 to Bases 2, 8, 16
• Technique: Divide the number using the appropriate base, then
repeatedly divide the resulting quotients by the same base until it
becomes zero. The answer is the combined remainders in
reverse order accumulated from the divisions. This technique is
called the remainder method.
• Convert 786310 to base 8.
7863 ÷ 8 = 982 r. 7
Answer: 172678
982 ÷ 8 = 122
r. 6
122 ÷ 8 = 15
r. 2
15 ÷ 8 = 1
r. 7
1÷8=0
r. 1
26
Conversion from Base 10 to Bases 2, 8, 16
• Technique: Divide the number using the appropriate base, then
repeatedly divide the resulting quotients by the same base until it
becomes zero. The answer is the combined remainders in
reverse order accumulated from the divisions. This technique is
called the remainder method.
• Convert 292610 to base 16.
2926 ÷ 16 = 182 r. 14(E)
182 ÷ 16 = 11
r. 6
11 ÷ 16 = 0
r. 11(B)
Answer: B6E16
27
Conversion from Base 8 to Base 2
• Technique: Convert each octal digit to a set of three binary
digits.
• Convert 56418 to base 2.
5
6
4
1
101 110 100 001
Answer: 1011101000012
28
Conversion from Base 2 to Base 8
• Technique: Convert each set of three binary digits to an octal digit
starting from the right going to the left, adding leading zeroes if
necessary.
• Convert 11110102 to base 8.
001 111 010
1
7
2
Answer: 1728
29
Conversion from Base 16 to Base 2
• Technique: Convert each hexadecimal digit to a set of four
binary digits.
• Convert A3CF16 to base 2.
A
3
C
F
1010
0011
1100
1111
Answer: 10100011110011112
30
Conversion from Base 2 to Base 16
• Technique: Convert each set of four binary digits to a
hexadecimal digit starting from the right going to the left, adding
leading zeroes if necessary.
• Convert 1010110102 to base 16.
0001 0101 1010
1
5
A
Answer: 15A16
31
MODULE 1.2
Number System – Arithmetic
Operation
At the end of the lesson, the student should be able to:
• Perform Addition, Subtraction, Multiplication and Division of binary, octal
and hexadecimal
Decimal Number (Base 10)
• Similar to the ordinary counting numbers from 0 to 9.
• Arithmetic operations such as: Addition, Subtraction,
Multiplication and Division are done of the same
manner/procedure with performing mathematical operations on
counting numbers.
Binary Number (Base 2)
• Binary numbers represents only two numbers , ( 0 and 1).
• There are different rules in performing arithmetic operations on
binary numbers.0
Binary Number (Base 2)
Binary Addition:
0+0=0
0+1=1
1+0=1
1 + 1 = 0 carry 1
Example:
1011101
+ 1101100
11001001
Binary Number (Base 2)
Binary
Subtraction:
0–0=0
0 – 1 = 1 borrow 1
1–0=1
1–1=0
Example:
1001101
- 1101000
1100101
Binary Number (Base 2)
Binary Multiplication:
0*0=0
0*1=0
1*0=0
1*1=0
Example:
1001101
*
110
0000000
1001101
1001101
111001110
Binary Number (Base 2)
Binary Division:
• Check the number of digits of the divisor; eg. 3, then take the
first 3 digits of the dividend.
• f the dividend is greater than the divisor, then the answer is 1,
otherwise the answer is 0.
• Proceed with the process of subtraction, bringing down the next
bit of the dividend. Remember you are subtracting binary
numbers. Then repeat the process.
Binary Number (Base 2)
Binary Division:
Example:
1001101 / 110
100 / 110 = 0 , 100 – 000 = 100
1001 / 110 = 1, 1001 – 110 = 0011, bring down 1 00111 / 110 = 1,
111 – 110 = 001, bring down 0
0010 / 110 = 0, 0010 – 000 = 10, bring down 1
101 / 110 = 0, 101 – 000 = 101
answer: 1100 r. 101
Octal Number (Base 8)
• Octal numbers represents numbers from ( 0 to 7).
• There are different rules in performing arithmetic operations on
octal numbers.
Octal Number (Base 8)
Octal Addition:
In adding octal numbers, if the result is greater than 7, it
should be subtracted by 8 until the result is less than 8. The
number of times you subtracted 8, will be the number of carry on
the next bit.
Octal Number (Base 8)
Octal Addition:
Example:
a)
2345
+ 1736
4303
b)
7632
+ 5774
15626
Octal Number (Base 8)
Octal Subtraction:
In subtracting octal numbers, if the number cannot be
subtracted then it needs to borrow bit from the next bit, every bit
borrowed will be equivalent to 8 and will be added to the bit that
needs it, then the process of subtraction will be done.
Octal Number (Base 8)
Octal Subtraction:
Example:
a)
2345
- 1736
0407
b)
7632
- 5774
1636
Octal Number (Base 8)
Octal Multiplication:
In multiplying octal numbers, it also follows the procedure in
multiplying decimal numbers, every bit in the multiplier will be
multiplied to the multiplicand, if the answer is greater than 7, then
subtract 8, until the answer is less than 8. The number of times you
subtracted 8 is the number to be carried to the next bit. Answers
are arranged just like in multiplying decimal numbers, to obtain the
final answer, proceed with the addition process, however remember
that you are adding octal numbers.
Octal Number (Base 8)
Octal Multiplication:
Example:
a)
2345
* 36
16536
+ 7257
111326
b)
7632
*
74
37150
+ 66266
722030
Octal Number (Base 8)
Octal Division:
• In dividing octal numbers, it also follows the procedure in
dividing decimal numbers, Check the number of digits of the
divisor; eg. 3, then take the first 3 digits of the dividend.
• Proceed with the process of subtraction, bringing down the next
bit of the dividend. Then repeat the process. Remember that
you are subtracting octal numbers.
Octal Number (Base 8)
Octal Division:
Example:
27 / 7 = 3, 7 * 3 in octal is 25
27 – 25 = 2, 2 cannot be divided by 7
Answer is: 3 remainder 2
Hexadecimal Number (Base 16)
• Hexadecimal numbers represents numbers from ( 0 to 15).
• However, numbers from 10 to 15 are represent by letters for A
to F respectively.
• There different rules in performing arithmetic operations on
hexadecimal numbers.
Hexadecimal Number (Base 16)
Hexadecimal Addition:
In adding hexadecimal numbers, if the result is greater than
15, it should be subtracted by 16 until the result is less than 16.
The number of times you subtracted 16, will be the number of
carry on the next bit.
Hexadecimal Number (Base 16)
Hexadecimal Addition:
Example:
a)
B34A
+ 1736
CA80
b)
F6E2
+ 5974
15056
Hexadecimal Number (Base 16)
Hexadecimal Subtraction:
In subtracting hexadecimal numbers, if the number cannot be
subtracted then it needs to borrow bit from the next bit, every bit
borrowed will be equivalent to 16 and will be added to the bit that
needs it, then the process of subtraction will be done.
Hexadecimal Number (Base 16)
Hexadecimal Subtraction:
Example:
a)
2A45
- F73B
330A
b)
E632
- 5C7A
89B8
Hexadecimal Number (Base 16)
Hexadecimal Multiplication:
In multiplying hexadecimal numbers, it also follows the
procedure in multiplying decimal numbers, every bit in the
multiplier will be multiplied to the multiplicand, if the answer is
greater than 15, then subtract 16, until the answer is less than 16.
The number of times you subtracted 16 is the number to be carried
to the next bit. Answers are arranged just like in multiplying decimal
numbers, to obtain the final answer, proceed with the addition
process, however remember that you are adding hexadecimal
numbers.
Hexadecimal Number (Base 16)
Hexadecimal Multiplication:
Example:
a)
B34A
*
36
433BC
+219DE
25D19C
b)
7632
*
74
D8C8
+33B5E
348EA8
Hexadecimal Number (Base 16)
Hexadecimal Division:
• In dividing hexadecimal numbers, it also follows the procedure
in dividing decimal numbers, Check the number of digits of the
divisor; eg. 3, then take the first 3 digits of the dividend.
• Proceed with the process of subtraction, bringing down the next
bit of the dividend. Then repeat the process. Remember that
you are subtracting hexadecimal numbers.
Hexadecimal Number (Base 16)
Hexadecimal Division:
Example:
27 / 7 = 5, 7 * 5 in hexadecimal is 23
27 – 23 = 4, 4 cannot be divided by 7
Answer is: 5 remainder 4
MODULE 1. 3
Number System – Digital Codes &
Parity
At the end of the lesson, the student should be able to :
• convert decimal numbers into digital codes (8421, 84-2-1, 2421, Excess-3,
Biquinary, and Gray codes)
• identify decimal numbers represented by the digital codes
• distinguish Even from Odd parity
The 8421 Code
• It is a type of binary coded decimal (BCD) code. Binary coded
decimal means that each decimal digit, 0 to 9, is represented
by the binary code of four bits.
•The designation 8421 indicates the binary weights of the four bits
(23, 22, 21, 20).
• To express any decimal number in BCD, simply replace each
decimal digit with the appropriate 4-bit code.
The 8421 Code
The 8421 Code
You should realize that, with four bits, sixteen numbers (0000
through 1111) can be represented but that, in the 8421 code, only
ten of these are used. The six code combinations that are not used
– 1010, 1011, 1100, 1101, 1110, and 1111 – are invalid in 8421
code.
The Excess-3 Code
This is unweighted code; its code assignment is obtained from the
corresponding value of BCD after the addition of three.
The 84-2-1 and 2421 Codes
These are weighted code. The designation 8421 and 2421
indicates the binary weights of the four bits.
The Biquinary Code
• It is an example of a seven-bit code with error-detection
properties. Each decimal digit consists of five 0’s and two 1’s
placed in the corresponding weighted columns (5043210).
• During transmission of signals from one location to another, an
error may occur. One or more bits may change value. A circuit
in the receiving side can detect the presence of more (or less)
than two 1’s and if the received combination of bits does not
agree with the allowed combination, an error is detected.
Digital Codes
The Gray Code
• It is unweighted and is not arithmetic code: that is, there are no
specific weights assigned to the bit positions.
• The important feature of the Fray Code is that it exhibits only a
single bit change from one code to the next.
Binary-to-Gray Code Conversion
1. The most significant bit (left-most) in the Gray code is the same
as the corresponding MSB in the binary number.
2. Going from left to right, add each adjacent pair of binary code
bits to get the next Gray code bit. Discard carries.
Binary-to-Gray Code Conversion
Gray Code-to-Binary Conversion
1. The most significant bit (left-most) in the Gray code is the same
as the corresponding MSB in the binary number.
2. Add each binary code bit generated to the gray code bit in the
next adjacent position. Discard carries.
Gray Code-to-Binary Conversion
Parity
•
•
It is one of the most common ways to achieve error detection.
A parity bit is an extra bit included with a message to make the
total number of 1’s transmitted either odd or even.
• Odd Parity: The parity bit is chosen so that the total number
of 1s is odd. Even Parity: The parity bit is chosen so that
the total number of 1s is even.
• It can detect odd number of errors but not even number of
errors.
Parity
Parity
Binary, Signed Integer Representations
Three systems are widely used for representing both
positive and negative numbers:
• 1. Sign and Magnitude
• 2. 1’s – complement
• 3. 2’s – complement
• For all three systems, the leftmost bit is 0 for
positive numbers and 1 is for negative numbers
Binary, Signed Integer Representations
Be reminded that:
• Positive values have identical representations in all systems.
• In the sign-and-magnitude system, negative values are represented by
changing the MSB of the positive representation to 1.
Be reminded that:
• In the 1’s-complement system, negative values are obtained by
complementing each bit of the corresponding positive
representation.
• In the 2’s-complement system, a negative number is obtained by
subtracting the positive number from 2n. Hence, the 2’scomplement representation is obtained by adding 1 to the 1’scomplement representation.
Overflow and Underflow
• Overflow (Addition)
• MSB - Carry, No Carry
• MSB – No Carry, Carry
• Underflow (Subtraction)
• MSB – Borrow, No Borrow
• MSB – No Borrow, Borrow
ASK ANY QUESTION RELATED TO OUR TOPIC
FOR TODAY.
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
COMPUTER SYSTEMS AND
PLATFORM TECHNOLOGIES
IT0047
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
MODULE 2.1
Review on Computer Concepts: How
Computers Work
At the end of the lesson, the student should be able to :
• Define Computer
• Identify elements of a computer system
• Identify the input, output and storage devices
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
Computer
A Computer is an electronic device that is capable of accepting
data/information, performs arithmetic and logical operation
and supplies the result in an acceptable form.
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
Hardware
Tangible parts of a computer system, includes:
Memory
CPU
Input devices
Output devices
Buses
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
Input Devices
Used to input instructions into the computer system.
Keyboard
Mouse
Joystick
Scanner
Touch Panel
Microphone
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
Output Devices
Used to give an output of what the computer executes.
Monitor
Printer
Projectors
Speakers
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
Software
These are programs that run the computer, designed to perform
a particular type of task.
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
How Computers Work
Operating System
It is the software that makes the computer work.
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
Peopleware
Peopleware refers to anything that has to do with the role of
people in the development of computer software and
hardware systems.
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
Computer Memory
It stores data and program instructions.
RAM – Random Access Memory
which can be read or changed by the user or computer.
ROM – Read Only Memory
which can be read by the computer but not altered in
any way.
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
ROM Memory
PROM - Programmable Read Only Memory
Information is written to a PROM chip after
it is manufactured. A PROM chip cannot be erased or rewritten.
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
ROM Memory
EPROM - Erasable Programmable Read Only Memory
Information is written to an EPROM chip after it is
manufactured. An EPROM chip can be erased with exposure
to UV light.
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
ROM Memory
EEPROM - Electrically Erasable Programmable Read Only
Memory
Information is written to an EEPROM chip after it is
manufactured. EEPROM chips are also called Flash ROMs.
An EEPROM chip can be erased and re-written without
having to remove the chip from the computer.
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
Central Processing Unit (CPU)
Information from an input device or from the computer’s memory is
communicated via the bus to the central processing unit (CPU),
which is the part of the computer that translates commands
and runs programs.
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
Functional Unit of CPU
Arithmetic and Logic Unit (ALU)
is where the execution of most operations takes place. It
contains a number of high-speed storage elements called
registers.
Control Unit (CU)
is the nerve center of a computer. It sends control signals to
other units and senses their state.
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
MODULE 2.2
Review on Computer Concepts:
Programming Language
At the end of the lesson, the student should be able to :
• Define Programming Language
• Identify the types of programming language
• Identify the advantages of using High Level and Low Level Languages
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
Programming Languages
• contain the series of commands that create software, all other
programming languages must be converted to machine code for them to be
understood because a CPU has a limited set of instructions known as
machine code that it is capable of understanding.
• Machine Language
• A program is a sequence of extremely simple instructions known as
machine code , Machine code instructions are binary
which are not easy to understand
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
High-Level Language
• This programming languages were developed because of the difficulty of
programming using assembly languages
• High-level languages are easier to use than machine and assembly
languages because their commands are closer to natural human language
• A compiler turns a high-level program into a CPU-specific machine
language.
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
Assembly Language
• A programming language that uses easy-to-remember commands or
mnemonics in place of binary patterns in order to make the task of
programming easier
• Once an assembly-language program is written, it is converted to a
machine-language program by another program called an assembler
• Both machine and assembly languages are low-level programming
languages
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
Advantages of using high-level languages over lowlevel languages:
• Easy to Learn
• Predefined Functions
• Portability
Advantages of using low-level languages over high-level
languages:
• Compact Code
• Speed
• Flexibility
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
ASK ANY QUESTION RELATED TO OUR TOPIC
FOR TODAY.
CPECOMSYS: Module 1.1: Review On Computer Concepts: How Computers Work
CPECOMSYS: Module 3.1- The BUS
COMPUTER SYSTEMS AND
PLATFORM TECHNOLOGIES
IT0047
CPECOMSYS: Module 3.1- The BUS
MODULE 4
The System Bus, Von Neuman
Architecture & CPU Registers
At the end of the lesson, the student should be able to :
• Define Bus
• Identify types of Bus
• Identify the Memory Operations
CPECOMSYS: Module 3.1- The BUS
MODULE 4.1
The Bus System
At the end of the lesson, the student should be able to :
• Define Bus
• Identify types of Bus
• Identify the Memory Operations
CPECOMSYS: Module 3.1- The BUS
Buses
• Bus - A bus is a collection of wires on which electrical signals pass between components in
the system.
• Data Bus - The 80x86 processors use the data bus to shuffle data between the various
components in a computer system. The size of this bus varies widely in the 80x86 family.
• 80x86 Processor
Data Bus Size
8088
8
•
80188
8
•
8086
16
•
80186
16
•
80286
16
•
80386sx
16
•
80386dx
32
•
80486
32
•
80586 / Pentium family
64
CPECOMSYS: Module 3.1- The BUS
Address Bus
• Address Bus - The address bus specifies the location of data in
memory. To differentiate memory locations and I/O devices, the
system designer assigns a unique memory address to each
memory element and I/O device
• The number of bits on the address bus will determine the
maximum number of addressable memory and I/O locations
(2^n) n- bit binary number. The 8088 and 8086, for example,
have 20 bit address busses. Therefore, they can access up to
1,048,576 memory locations.
CPECOMSYS: Module 3.1- The BUS
80x86 Family Address Bus Sizes
•
•
•
•
•
•
•
•
•
•
•
•
•
Processor
8088
8086
80188
80186
80286
80386sx
80386dx
80486
80586/Pentium
Pentium Pro
Pentium II
Pentium III
Address Bus Size
20
20
20
20
24
24
32
32
32
36
36
36
Max. Addressable
1,048,576
1,048,576
1,048,576
1,048,576
16,777,216
16,777,216
4,294,976,296
4,294,976,296
4,294,976,296
68,719,476,736
68,719,476,736
68,719,476,736
Memory In English
1 Megabyte
1 Megabyte
1 Megabyte
1 Megabyte
16 Megabytes
16 Megabytes
4 Gigabytes
4 Gigabytes
4 Gigabytes
64 Gigabytes
64 Gigabytes
64 Gigabytes
CPECOMSYS: Module 3.1- The BUS
Control Bus
• Control Bus - The control bus is an extensive collection of signals
that control how the processor communicates with the rest of the
system.
• The read and write control lines control the direction of data on the
data bus. When both contain a logic one, the CPU and memory-I/O
are not communicating with one another. If the read line is low
(logic zero), the CPU is reading data from memory (that is, the
system is transferring data from memory to the CPU). If the write
line is low, the system transfers data from the CPU to memory.
• The byte enable lines are another set of important control lines.
These control lines allow 16, 32, and 64 bit processors to deal with
smaller chunks of data.
CPECOMSYS: Module 3.1- The BUS
Data Bus
The data bus is used to transfer data to and from the memory or I/O devices.
It is bi-directional.
The address bus is used to select the desired memory or I/O devices by
providing a unique address that corresponds to one of the memory or I/O. It
is unidirectional.
The control bus is used to carry control signals to and from the memory or I/O
devices. It is bi-directional.
CPECOMSYS: Module 3.1- The BUS
Fetch or Read. This transfers the contents of a specific MM location to
the CPU. The word in the MM remains unchanged.
Read/Fetch Cycle:
1. CPU sends address of the desired location.
2. MM reads the data stored at that address and sends it to the CPU.
CPECOMSYS: Module 3.1- The BUS
The CPU places the address 125 on the address bus, enables the read line
(since the CPU is reading data from memory), and then reads the
resulting data from the data bus.
CPECOMSYS: Module 3.1- The BUS
Store or Write. This transfers a word of information from the CPU to a
specific MM location. This overwrites the former contents of that
location.
Write/Store Cycle:
1. CPU sends address of the desired location to the MM, together
with the data to be stored into that location.
2. Data is written at desired location.
CPECOMSYS: Module 3.1- The BUS
The CPU places the address 125 on the address bus, the value zero on
the data bus, and enables the write line (since the CPU is writing data to
memory).
CPECOMSYS: Module 3.1- The BUS
If operand or data needed by the instruction resides in MM:
1. It will have to be fetched by sending its address to the MAR and
initiating a read cycle.
2. When the operand has been read from MM
into the MDR, it
may be transferred from the MDR to the ALU.
If result is to be stored in MM:
1. The result is sent to the MDR.
2. The address of the location where the result
sent to the MAR and a write
cycle is initiated
is to be stored is
CPECOMSYS: Module 3.1- The BUS
MODULE 4.1
Basic Operational Concept
At the end of the lesson, the student should be able to :
• Familiar with the Von Neumann Architecture
• Identify the functions of the different components of the Von Neumann Architecture
• Identify the operating steps of the Von Neumann Architecture
CPECOMSYS: Module 3.1- The BUS
Address Bus
I /O
Address Bus
Data Bus
Data Bus
MPU
Control Bus
Control Bus
MPU
MU
MU
CPECOMSYS: Module 3.1- The BUS
Von Neumann Architecture means that programs (together with data)
are stored in main memory during execution.
It is also known as the Stored Program Architecture or the Fetch-DecodeExecute Architecture.
CPECOMSYS: Module 3.1- The BUS
Connections between the processor and the main memory:
CPECOMSYS: Module 3.1- The BUS
The PC (Program Counter) contains the memory address of the
instruction to be executed. During execution, the contents of the PC are
updated to point to the next instruction.
The MAR (Memory Address Register) holds the address of the location to
or from which data are to be transferred.
The MDR (Memory Data Register) contains the data to be written or
read out of the addressed location.
The IR (Instruction Register) contains the instruction that is being
executed.
CPECOMSYS: Module 3.1- The BUS
1. PC is set to point to the first instruction of the program (the operating
system loads the memory address of the first instruction).
2. The contents of the PC are transferred to the MAR (which are
automatically transmitted to the MM) and a Read signal is
sent to
the MM.
3. The addressed word is read out of MM and loaded into the MDR.
4. The contents of MDR are transferred to the IR. The instruction is ready
to be decoded and executed.
5. During execution, the contents of the PC are incremented or updated
to point to the
next instruction.
CPECOMSYS: Module 3.1- The BUS
If operand or data needed by the instruction resides in MM:
1. It will have to be fetched by sending its address to the MAR and
initiating a read cycle.
2. When the operand has been read from MM
into the MDR, it
may be transferred from the MDR to the ALU.
If result is to be stored in MM:
1. The result is sent to the MDR.
2. The address of the location where the result
sent to the MAR and a write
cycle is initiated
is to be stored is
CPECOMSYS: Module 3.1- The BUS
Address Bus
I /O
Address Bus
Data Bus
Data Bus
MPU
Control Bus
Control Bus
MPU
MU
MU
CPECOMSYS: Module 3.1- The BUS
Von Neumann Architecture means that programs (together with data)
are stored in main memory during execution.
It is also known as the Stored Program Architecture or the Fetch-DecodeExecute Architecture.
CPECOMSYS: Module 3.1- The BUS
CPECOMSYS: Module 3.1- The BUS
The PC (Program Counter) contains the memory address of the
instruction to be executed. During execution, the contents of the PC are
updated to point to the next instruction.
The MAR (Memory Address Register) holds the address of the location to
or from which data are to be transferred.
The MDR (Memory Data Register) contains the data to be written or
read out of the addressed location.
The IR (Instruction Register) contains the instruction that is being
executed.
CPECOMSYS: Module 3.1- The BUS
1. PC is set to point to the first instruction of
the program (the
operating system loads the memory address of the first instruction).
2. The contents of the PC are transferred to the MAR (which are
automatically transmitted to the MM) and a Read signal is
sent to
the MM.
3. The addressed word is read out of MM and loaded into the MDR.
4. The contents of MDR are transferred to the IR. The instruction is ready
to be decoded and executed.
5. During execution, the contents of the PC are incremented or updated
to point to the
next instruction.
CPECOMSYS: Module 3.1- The BUS
If operand or data needed by the instruction resides in MM:
1. It will have to be fetched by sending its address to the MAR and
initiating a read cycle.
2. When the operand has been read from MM
into the MDR, it
may be transferred from the MDR to the ALU.
If result is to be stored in MM:
1. The result is sent to the MDR.
2. The address of the location where the result
sent to the MAR and a write
cycle is initiated
is to be stored is
CPECOMSYS: Module 3.1- The BUS
MODULE 4.3
CPU Registers and Flags
At the end of the lesson, the student should be able to :
• Define Register
• Identify the different types of Registers
• Identify the values of the conditional flag registers
CPECOMSYS: Module 3.1- The BUS
Registers are high speed memory elements that resides inside the
Central Processing Unit or CPU.
CPECOMSYS: Module 3.1- The BUS
The AX register (Accumulator) is where
most arithmetic and logical
computations take place.
The BX register (Base) has some
special purposes as well. This is often
used to hold base addresses of data
located in the memory.
The CX register (Count), as its name
implies, counts things. It is often use it
to count off the number of iterations in
a loop or specify the number of
characters in a string.
The DX register (Data) has two special
purposes: it holds the overflow from
certain arithmetic operations, and it
holds I/O addresses when accessing
data on the 80x86 I/O bus.
CPECOMSYS: Module 3.1- The BUS
AH
BH
CH
DH
Higher Order byte registers
AL
BL
CL
DL
Lower Order byte registers
Eight 16-bit registers
CPECOMSYS: Module 3.1- The BUS
Four Special Segment Registers
 16
bits wide registers deals with selecting blocks (segments) of main
memory. A segment register points at the beginning of a segment in
memory.
•
•
•
•
CS (Code Segment)
DS (Data Segment)
ES (Extra Segment)
SS (Stack Segment)
CPECOMSYS: Module 3.1- The BUS
CPECOMSYS: Module 3.1- The BUS
 Code Segment. This contains the program or code. The address of the
next instruction executed by the 8086/8088 is generated by adding
the contents of IP (offset address) to the contents of CS x 10H.
CPECOMSYS: Module 3.1- The BUS
 Data Segment. This contains data referenced by almost all
instructions and many addressing modes. Data are almost always
moved into or out of MM via the data segment. The physical address
of the data is generated by adding the contents of one of the index or
pointer registers (BX, DI, or SI) to the contents of DS x 10H.
CPECOMSYS: Module 3.1- The BUS
 Stack Segment. This is for the LIFO stack. The physical address is a
combination of the contents stack pointer (SP) plus SS x 10H.
 Extra Segment. This is normally for string instructions. When a string
instruction is executed, the destination location is addressed by the
destination index register (DI) plus ES x 10H.
CPECOMSYS: Module 3.1- The BUS
The instruction pointer (IP)
is also the program counter, it contains the memory address of the
instruction to be executed. During execution, the contents of the IP
are updated to point to the next instruction.
The flags register
is an extensive collection of one bit values which help determine the
current state of the processor. A 16 bits wide register, it uses only nine
of those bits.
CPECOMSYS: Module 3.1- The BUS
CPECOMSYS: Module 3.1- The BUS
Conditional Flags - reflect the result of the previous operation involving
the ALU.
Control Flags - (they control the execution of special functions.
CPECOMSYS: Module 3.1- The BUS
Sign Flag (SF) - b7
This is equal to the MSB of the result of the previous
operation. 0 if positive, 1 if negative.
Zero Flag (ZF) - b6
This is set to 1 if the result of the previous operation is zero
and 0 if the result is nonzero.
Parity Flag (PF) - b2
This is set to 1 if the low-order 8 bits of the result of the
previous operation contain an even number of 1s. Otherwise it
is reset to 0.
CPECOMSYS: Module 3.1- The BUS
Carry Flag (CF) - b0
An addition causes this flag to be set to 1 if there is a carry out of the
MSB, and a subtraction causes it to be set to 1 if a borrow is needed.
Overflow Flag (OF) - b11
This is set to 1 if an overflow occurs, i.e., a result is out of range. More
specifically, for addition this flag is set to 1 when there is a carry into
the MSB and no carry out of the MSB or vice-versa. For subtraction, it
is set to 1, when the MSB needs a borrow and there is no borrow
from the MSB, or vice-versa.
CPECOMSYS: Module 3.1- The BUS
Auxiliary Carry Flag (AF) – b4
This flag is used exclusively for BCD arithmetic. It is set to 1 if there is
a carry out of bit 3 (b3) during an addition or a borrow by bit 3 during
a subtraction.
CPECOMSYS: Module 3.1- The BUS
Direction Flag (DF) - b10
This flag is used by string manipulation instructions. If clear, the string
is processed from its beginning with the first element having the
lowest address. Otherwise, the string is processed from the high
address towards the low address.
Interrupt Enable Flag (IF) - b9
If set, a certain type of interrupt (a maskable interrupt) can be
recognized by the CPU; otherwise, these interrupts are ignored.
CPECOMSYS: Module 3.1- The BUS
Trap Flag (TF) - b8
If set, the 8086/8088 will enter into a single-step mode. In this
mode, the CPU executes one instruction at a time.
CPECOMSYS: Module 3.1- The BUS
There are three additional bits present in the 80286 flags register. The I/O
Privilege Level is a two bit value (bits 12 and 13). It specifies one of four
different privilege levels necessary to perform I/O operations. These two
bits generally contain 00 when operating in real mode on the 80286 (the
8086 emulation mode). The NT (nested task) flag controls the operation
of an interrupt return (IRET) instruction. NT is normally zero for realmode programs. The protected mode on the 80286 is to access more
than one megabyte of RAM.
CPECOMSYS: Module 3.1- The BUS
80286 also has five additional registers used by an operating system to
support memory management and multiple processes: the machine
status word (msw), the global descriptor table register (gdtr), the local
descriptor table register (ldtr), the interrupt descriptor table register
(idtr) and the task register (tr).
CPECOMSYS: Module 3.1- The BUS
The 80386 calls these new 32-bit versions EAX, EBX, ECX, EDX, ESI, EDI,
EBP, ESP, EFLAGS, and EIP to differentiate them from their 16-bit
versions (which are still available on the 80386).
Besides the 32-bit registers, the 80386 also provides two new 16-bit
segment registers, FS and GS, which allow the programmer to
concurrently access six different segments in memory.
CPECOMSYS: Module 3.1- The BUS
The 80386 did not make any changes to the bits in the flags register.
Instead, it extended the flags register to 32 bits (the “EFLAGS” register)
and defined bits 16 and 17.
Bit 16 is the debug resume flag (RF) used with the set of 80386 debug
registers.
Bit 17 is the Virtual 8086 mode flag (VM) which determines whether the
processor is operating in virtual-86 mode (which simulates an 8086) or
standard protected mode.
CPECOMSYS: Module 3.1- The BUS
The 80486 adds a third bit to the EFLAGS register at bit 18 – the
alignment check flag (ACF). Along with control register zero (CR0)
on the 80486, this flag forces a trap (program abort) whenever the
processor accesses non-aligned data.
The 80386 added four control registers: CR0-CR3. These registers
extend the msw register of the 80286. On the 80386 and 80486
these registers control functions such as paged memory
management, cache enable /disable operation (80486 only),
protected mode operation, and more.
.
CPECOMSYS: Module 3.1- The BUS
ASK ANY QUESTION RELATED TO OUR TOPIC
FOR TODAY.
CPECOMSYS: Module 3.1- The BUS
Download