You are on page 1of 15

K0020

TOPIC TITLE: ASSEMBLY LANGUAGE AND THE X86 PROCESSOR


ARCHITECTURE

SPECIFIC OBJECTIVES:

At the end of the topic session, the students should be able to:

1. discuss the basic concepts of assembly language;


2. compare assembly language with other programming languages;
3. recognize the importance of studying assembly language;
4. perform conversion of number systems;
5. explain the basic principles of computer architecture as applied
to x86 processors;
6. describe the environment used in executing instructions; and
7. discuss how x86 processors manage memory according to the
basic modes of operation.

MATERIALS/EQUIPMENT:

o Computer
o LCD/OHP projector
o File/s (03 Assembly Language and the x86 Processor
Architecture)
 03 LCD Slides 1.ppsx
 03 OHP Slides 1.pdf
 03 LCD Slide Handout 1.pdf
 03 OHP Slide Handout 1.pdf
 03 Laboratory Exercise 1.pdf
 03 Task Performance 1.pdf
o Software requirement
 MS PowerPoint
o White board marker and eraser

TOPIC PREPARATION:

o Prepare the handouts needed for the topic presentation and


have them photocopied.
o Set up the computer and the LCD/OHP projector. These will be
used to show a slide presentation in class.
o It is imperative for the instructor to study the lecture materials
and read other materials related to the topic to be able to fuse
different sorts of teaching strategies depending on the needs of
the students.
Note: Instructor’s input as an academy expert and/or an industry
professional will be the best foundation in teaching the course
effectively.

Assembly Language and the x86 Processor Architecture *Property of STI


Page 1 of 15
K0020

o Anticipate possible questions that students might raise during


the discussion.

PRESENTATION OVERVIEW:

A. Introduction 15 min
B. Instructional Input
Basic Concepts of Assembly Language 10 min
a. Discuss the basic concepts of assembly language
How Assembly Language Relates to Other Programming
Languages 20 min
a. Compare assembly language with other programming
languages
Benefits of Leaning Assembly Language 10 min
a. Recognize the importance of studying assembly language
Number Systems 50 min
a. Perform conversion of number systems
x86 Processor Architecture 20 min
a. Explain the basic principles of computer architecture as
applied to x86 processors
Basic Execution Environment 20 min
a. Describe the environment used in executing instructions
Memory Management 20 min
b. Discuss how x86 processors manage memory according to
the basic modes of operation
C. Generalization 15 min
D. Application 180 min
Total duration 360 min

Assembly Language and the x86 Processor Architecture *Property of STI


Page 2 of 15
K0020

TOPIC PRESENTATION:

A. Introduction
Step 2
Target Attribute: Critical Thinker
Facet: Practicing Thinker (Ability to understand the process of
correct thinking)
Strategy: Motivate students to improve the ability to monitor one's process of
thinking
Learning Outcome: Students should be able to:
 identify terminologies which were discussed in the previous lesson
Step 3
Target Attribute: Effective Communicator
Facet: Speaking (Ability to express ideas and information orally in a variety of
situations)
Strategy: Improve students' ability in presenting ideas and information to an
audience confidently
Learning Outcome/s: Students should be able to:
 explain the chosen words clearly

Slide 1 1. Start the session by showing Slide 1 of 03 LCD Slides 1. Inform your
students that there will be a recap of the previous lesson in a form of
a simple game.

Recap of the Previous Lesson

K0020
11/3/2015
*Property of STI 1

Slide 2 2. Ask five (5) students to unscramble the words shown in Slide 2.

3. Once all the words are unscrambled, call another five (5) students
Unscramble the words. and ask them to choose a word and give a brief explanation or
KTDOPSE
SIERTEGR
example of their chosen word.
OORLNTC
YIANMCD
TULEBOSA

K0020
11/3/2015
*Property of STI 2

Slide 3 4. Show Slide 3. Present the topics for today’s discussion.

 Basic Concepts of Assembly Language


Assembly Language and the
x86 Processor Architecture
 Basic Concepts of Assembly Language
 How Assembly Language Relates to Other Programming
 How Assembly Language Relates to Other
Programming Languages
Languages
 Benefits of Learning Assembly Language


 Number Systems
 x86 Processor Architecture Benefits of Learning Assembly Language
 Basic Execution Environment
 Memory Management
 Number Systems
K0020
11/3/2015
*Property of STI 3

 x86 Processor Architecture

Assembly Language and the x86 Processor Architecture *Property of STI


Page 3 of 15
K0020

 Basic Execution Environment

 Memory Management

B. Instructional Input

Basic Concepts of Assembly Language

Slide 4 1. Using Slides 4 and 5, discuss assembly language.

Assembly language is a low-level programming language


Assembly Language
Low level programming language that
that provides direct access to microprocessors and other
provides direct access to microprocessors programmable devices.
and other programmable devices

K0020
11/3/2015
*Property of STI 4

Slide 5 There are three (3) utility programs related to assembly


language programming. These are assembler, linker, and
Utility Programs
debugger. An assembler is a utility program that converts
Assembler – converts source programs from source programs from assembly language into machine
assembly language into machine language
Linker – combines individual files created by language. A linker combines individual files created by an
an assembler into a single executable program
Debugger – allows you to examine registers
assembler into a single executable program. A debugger
and memory while the program is running
allows you to examine registers and memory while the
program is running.
K0020
11/3/2015
*Property of STI 5

Programs fall into two (2) general classes.

 16-Bit Real-Address Mode (real mode): These


programs run in MS-DOS and in the console window
under MS-Windows.

 32-Bit Protected Mode: These programs run under


all 32-bit versions of Microsoft Windows. They are
easier to write and understand than 16-bit real-
address mode programs.

How Assembly Language Relates to Other Programming Language

Slide 6 1. Discuss the relationship of assembly language to other programming


languages using Slide 6-11.
Assembly Language and
Other Programming Languages
Machine language is a numeric language specifically
understood by a computer’s processor. All x86 processors
understand a common machine language. Assembly
language consists of statements written with short
mnemonics such as ADD, MOV, SUB, and CALL. Assembly
11/3/2015
*Property of STI K0020
6 language has a one-to-one relationship with machine
language; each assembly language instruction corresponds
to a single machine-language instruction.

Assembly Language and the x86 Processor Architecture *Property of STI


Page 4 of 15
K0020

High-level languages such as C++ and Java have a one-to-


Slide 7 many relationship with assembly language and machine
Assembly Language and
language; a single statement in a high-level language
Machine Language expands into multiple assembly language or machine
instructions.

See table below for the comparison of the adaptability of


assembly language to high-level languages in relation to
various types of applications.
K0020
11/3/2015
*Property of STI 7

Slide 8

Assembly Language and


High-Level Languages

K0020
11/3/2015
*Property of STI 8

Slide 9

Assembly Language and


High-Level Languages

K0020
11/3/2015
*Property of STI 9

Slide 10

Assembly Language and


High-Level Languages

K0020
11/3/2015
*Property of STI 10

Slide 11

Assembly Language and


High-Level Languages

K0020
11/3/2015
*Property of STI 11

Assembly Language and the x86 Processor Architecture *Property of STI


Page 5 of 15
K0020

Type of Application High-Level Languages Assembly Language


Commercial or Formal structures It has minimal
scientific make it easy to formal structure, so
application, organize and maintain one must be
written for single large sections of code. imposed by
platform, medium programmers who
to large size have varying levels
of experience. This
leads to difficulties
maintaining existing
code.
Hardware device The language may not Hardware access is
driver provide for direct straightforward and
hardware access. Even simple. Easy to
if it does, awkward maintain when
coding techniques may programs are short
be required, resulting and well-
in maintenance documented.
difficulties.
Commercial or They are usually It must be recorded
scientific portable. The source separately for each
application written code can be platform, using an
for multiple recompiled on each assembler with a
platforms (different target operating different syntax. It is
operating systems) system with minimal difficult to maintain.
changes.
Embedded systems These produce too This is ideal because
and computer much executable code the executable code
games requiring and may not run is small and runs
direct hardware efficiently. quickly.
access

Benefits of Learning Assembly Language

Slide 12 1. Using Slide 12, explain why studying assembly language is still
important despite the existence of high-level languages.
Benefits of
Learning Assembly Language
It is an ideal tool for writing embedded
Here are the benefits of learning assembly language:
programs because of its economical use of


memory.
It permits you to precisely specify a program’s It is an ideal tool for writing embedded programs
executable code.
It permits direct access to computer hardware
because of its economical use of memory.
and code can be hand optimized for speed.
It allows you to apply and test theoretical
information.
K0020
 It permits you to precisely specify a program’s
11/3/2015
*Property of STI 12

executable code.

 It permits direct access to computer hardware and


code can be hand optimized for speed.

 It allows you to apply and test theoretical


information.

Assembly Language and the x86 Processor Architecture *Property of STI


Page 6 of 15
K0020

Number Systems

Slide 13 1. Discuss number systems using Slide 13.

Number Systems
A number system (or numeral system) is a system that uses
a system that uses distinct symbols to
distinct symbols to represent a number inside the
represent a number inside the computer’s memory. For example, the two numbers 528 and
computer’s memory
Base or Radix - The number of different 2A16 both refer to the same quantity, 4210, but their
symbols (digits) required to represent
any given number
representations are different.

11/3/2015
*Property of STI K0020
13
The number of different symbols (digits) required to
represent any given number is known as the base or radix of
a number system.

For example, with a given base, or radix that is equal to three


(3) indicates that there are three (3) symbols, (0, 1, and 2)
used in the system. A number system using four (3) symbols
would be base 4 and so forth. The base of a number system
is indicated by a subscript following the value of the number.

Note: The larger the base, the more numerals are required.
The highest value symbol used in a number system is always
one less than the base of the system.

Slide 14 2. Compare the different types of number systems using Slide 14.
Provide examples of each.
Types of Number Systems

Binary – base of 2
Below are the different types of number systems.
Decimal – base of 10
Octal – base of 8  Binary Number System – This is the number system
Hexadecimal – base of 16
that is the basic foundation of any computer
machine. In this system, the base (n) = 2 and includes
11/3/2015
*Property of STI K0020
14
two symbols from 0 through 1.

 Decimal Number System – This is the number


system that we are all familiar with. In this system,
the base (n) = 10 and includes ten symbols from 0 to
9.

 Octal Number System – This is the number system


that uses base (n) = 8 and includes eight (8) symbols
from 0 to 7.

 Hexadecimal Number System – This is the number


system that uses base (n) = 16 and includes sixteen
symbols from 0 to 9 and the letters A = 10, B = 11, C
= 12, D = 13, E = 14 and F = 15.

Assembly Language and the x86 Processor Architecture *Property of STI


Page 7 of 15
K0020

3. Using Slide 15, explain the three (3) methods of converting a decimal
Slide 15 number base system to other number base systems. Provide
examples of each.
Decimal to Other Base Systems
Subtracting the Powers of Base 2 Method There are three (3) ways to convert a decimal number into its
Successive/Repeated Division by Powers representation in a different number base. These methods
of Base (n) Method
Successive/Repeated Division by Base are:
Method

 Subtracting the Powers of Base 2 Method – This


11/3/2015
*Property of STI K0020
15 method is only applicable when converting a decimal
number to a binary number (base 2). This is done by
subtracting off the largest power of base 2 that is less
than or equal to the decimal number. Then we
subtract off the largest power of base 2 that is less
than or equal to the difference, and so on, until we
obtain 0.

 Successive/Repeated Division by Powers of Base (n)


Method – This method converts the decimal number
to a desired base (n) by repeatedly dividing the
decimal number by the largest power of base (n) that
is less than or equal to the decimal number. Then we
divide the largest power of base (n) that is less than
or equal to the remainder, and so on, until we obtain
0.

 Successive/Repeated Division by Base (n) Method –


This method converts the decimal number to a
desired base (n) by dividing continuously the decimal
number by the base (n) were converting to until the
quotient equals zero (0). The first remainder (after
the first division by base (n) becomes the least
significant bit (LSB) of the integer portion of the
number, while the last remainder becomes the most
significant bit (MSB), the leftmost bit, of the integer
portion.

Slide 16 4. Discuss the two (2) methods of converting other base systems to
decimal number system as shown in Slide 16. Provide examples of
Other Base Systems to Decimal each.
Multiply and Add Method
Positional Value Method There are two (2) ways to convert numbers in other bases
into a decimal number. These are:

 Multiply and Add Method – This method converts


11/3/2015
*Property of STI K0020
16
other base systems to decimal number system by
multiplying the leftmost digit by the base (n) then
adding the next digit to the product. Then multiply

Assembly Language and the x86 Processor Architecture *Property of STI


Page 8 of 15
K0020

the sum by the base (n) and then add again the next
digit to the product.

Note: If the rightmost digit is already added, the


operation will automatically stop and the resulting
sum is the actual decimal equivalent.

 Positional Value Method - This method converts


other base systems to decimal number system by
multiplying each digit (starting from the rightmost
digit) with powers of base (n) raised to a power of
zero. Then get the sum of all the products. The total
is the decimal equivalent of the base (n) number.

x86 Processor Architecture

Slide 17 1. Using Slide 17, describe the basic design of a microcomputer.

The central processor unit (CPU), where calculations and


Basic Design of Microcomputer
logic operations take place, contains a limited number of
storage locations called registers, a high-frequency clock, a
control unit (CU), and an arithmetic logic unit (ALU).

 Clock – synchronizes the internal operations of the


11/3/2015
*Property of STI K0020
17
CPU with other system components

 Control Unit (CU) – coordinates the sequencing of


steps involved in executing machine instructions

 Arithmetic Logic Unit (ALU) – performs arithmetic


operations such as addition and subtraction and
logical operations such as AND, OR, and NOT

A bus is a group of parallel wires that transfer data from one


part of the computer to another. A computer system usually
consists of four (4) buys types: data, I/O, control, and
address.

 Data bus – transfers instructions and data between


the CPU and memory

 I/O bus – transfers data between the CPU and the


system input/output devices

 Control bus – uses binary signals to synchronize


actions of all devices attached to the system bus

 Address bus – holds the addresses of instructions


and data when the currently executing instruction
transfers data between the CPU and memory

Assembly Language and the x86 Processor Architecture *Property of STI


Page 9 of 15
K0020

The CPU is attached to the rest of the computer via pins


attached to the CPU socket in the computer’s motherboard.
Most pins connect to the data bus, the control bus, and the
address bus. The memory storage unit holds instructions and
data while a computer program is running. The storage unit
receives requests for data from the CPU, transfers data from
Random Access Memory (RAM) to the CPU, and transfers
data from the CPU into memory. Programs residing in
memory must be copied into the CPU before they can
execute since all processing of data takes place within the
CPU. Individual program instructions can be copied into the
CPU one at a time; groups of instructions can be copied
together.

Modes of Operation

Slide 18 1. Compare the different modes of operation using Slide 18.

x86 processors have three (3) primary modes of operation.


Modes of Operation
Protected Mode
These are protected mode, real-address mode, and system
o Virtual-8086 Mode management mode. A sub-mode, named virtual-8086, is a
Real-Address Mode
System Management Mode
special case of protected mode.

 Protected Mode – native state of the processor that


11/3/2015
*Property of STI K0020
18
contains all instructions and features. Programs are
given separate memory areas named segments.
Processor prevents programs from referencing
memory outside their assigned segments.

o Virtual-8086 Mode – While in protected


mode, the processor can directly execute
real-address software in a safe multitasking
environment.

 Real-Address Mode – implements the


programming environment of the Intel 8086
processor with extra features such as the ability to
switch into other modes

 System Management Mode – provides an


operating system with a mechanism for
implementing functions such as system security and
power management. These functions are usually
implemented by computer manufacturers since
they customize the processor for a particular
system setup.

Basic Execution Environment

Assembly Language and the x86 Processor Architecture *Property of STI


Page 10 of 15
K0020

1. Using Slide 19, describe the basic execution environment of the


Slide 19 x86 processor architecture.

Basic Program Execution Registers Registers are high-speed storage locations directly inside the
CPU, designed to be accessed at much higher speed than
conventional memory. When a processing loop is optimized
for speed, loop counters are held in registers rather than
variables. Out of the 18 basic program execution registers,
there are eight (8) general-purpose registers, six (6) segment
11/3/2015
*Property of STI K0020
19
registers, a processor status flags register (EFLAGS), and an
instruction pointer (EIP).

 General-Purpose Registers – primarily used for


arithmetic and data movement. The eight (8)
general-purpose registers are EAX, EBX, ECX, EDX,
ESI, EDI, EBP, and ESP.

They are provided for holding the following items:

o Operands for logical and arithmetic


operations

o Operands for address calculations

o Memory pointers

The following table summarizes the special uses of


these registers.

General-Purpose Register Use


EAX (Extended Accumulator for operands and
Accumulator) results data
EBX (Extended Base) Pointer to data in the data
segment (DS)
ECX (Extended Count) Counter for string and loop
operations
EDX (Extended Data) I/O pointer
ESI (Extended Source Pointer to data in the segment
Index) pointed to by the data
segment (DS) register; source
pointer for string operations
EDI (Extended Destination Pointer to data (or destination
Index) in the segment pointed to by
the extra segment (ES)
register; destination pointer
for string operations
EBP (Extended Base Pointer to data on the stack in
Pointer) the stack segment (SS)
ESP (Extended Stack Stack pointer in the stack
Pointer) segment (SS)

Assembly Language and the x86 Processor Architecture *Property of STI


Page 11 of 15
K0020

 Segment Registers – indicate base addresses of pre-


assigned memory areas named segments. The six (6)
segment registers are CS, DS, ES, FS, GS, and SS.

The table below summarizes the special uses of


these registers.

Segment Register Use


CS (Code Segment) Determines the segment where the
executable code of a program is
located
DS (Data Segment) Default segment for most memory
accesses
ES (Extra Segment) Can be used instead of DS when data
from two (2) segments need to be
accessed at once
SS (Stack Segment) Holds information about the memory
segment that your program uses
FS Additional extra segment register
GS Additional extra segment register

 Instruction Pointer (EIP) Register – contains the


address of the next instruction to be executed

 EFLAGS Register (Flag Register) – consists of


individual binary bits that control the operation of
the CPU or reflect the outcome of some CPU
operation. The status flags reflect the outcomes of
arithmetic and logical operations performed by the
CPU. These are CF, OF, SF, ZF, AF, and PF.

The following table summarizes the functions of


these status flags.

Status Flag Function


CF (Carry Flag) Set when the result of an unsigned
arithmetic operation is too large to fit
into the destination
OF (Overflow Set when the result of a signed
Flag) arithmetic operation is too large to fit
into the destination
SF (Sign Flag) Set when the result of arithmetic or
logical operation generates a negative
result
ZF (Zero Flag) Set when the result of an arithmetic or
logical operation generates a result of
zero
AF (Adjust Flag) Set when an arithmetic operation causes
or AC (Auxiliary a carry from bit 3 to bit 4 in an 8-bit
Carry Flag) operand

Assembly Language and the x86 Processor Architecture *Property of STI


Page 12 of 15
K0020

PF (Parity Flag) Set if the least significant byte in the


result contains an even number of 1 bit;
otherwise, PF is clear.

Memory Management

Slide 20 1. Discuss how x86 processors manage memory according to the basic
modes of operation. Use Slide 20.
Memory Management Models
The memory that the processor addresses on its bus is called
physical memory. Physical memory is organized as a
sequence of 8-bit bytes. Each byte is assigned a unique
address, called a physical address. The physical address space
ranges from zero to a maximum of 232 – 1 (four [4]
11/3/2015
*Property of STI K0020
20 gigabytes).

When employing the processor’s memory management


facilities, programs do not directly address physical memory
Instead, they access memory using any of three (3) memory
models: flat, segmented, or real-address mode.

 Flat Model – memory appears as a single, continuous


address space called a linear address space

 Segmented Model – memory appears to a program


as a group of independent address spaces called
segments

 Real-Address Model – uses the memory model for


the Intel 8086 processor, the first Intel architecture
processor

C. Generalization
Step 1
Target Attribute: Lifelong Learner
Facet: Self-directed (Ability to identify, define and transfer
worthwhile learning)
Strategy: Guide students to evaluate their learning process
Learning Outcome: Students should be able to:
 identify concepts learned through answering the crossword puzzle

Slide 21 1. Display Slide 21 for about a minute to catch the attention of the class.
Have a recap of the topics discussed during the session in a form of a
game. Show Slide 22, ask 10 students to answer the crossword puzzle
projected in the whiteboard using a whiteboard marker.
Let’s play a game!

K0020
11/3/2015
*Property of STI 21

Assembly Language and the x86 Processor Architecture *Property of STI


Page 13 of 15
K0020

Slide 22
Across
D. Application
Steps 1 and 2
2. Number system that uses
base 16
6. High-speed storage actions
7. Independent address space
8. Memory appears as a single
address space in this model.
9. Synchronizes internal
Target Attribute: Lifelong Learner
operations of the CPU with
other components
10. Combines individual files
created by an assembler into a
Facet: Self-directed (Ability to identify, define and transfer
single executable program

Down
worthwhile learning)
1. Permits you to examine
registers
execution
during program

3. Uses binary signals to


Strategy: Guide students to evaluate their learning process
synchronize actions of all
devices attached to the
system bus
4. The number of digits or
Learning Outcome: Students should be able to:
 create and execute an assembly program
symbols required to represent
any given number
K0020
11/3/2015
*Property of STI 22

1. Ask the students to independently perform the hands-on activity


instructed in 03 Laboratory Exercise 1. Give them 1.5 hours to finish.
Entertain their questions. Roam around to check their progress and
do not forget to acknowledge their work.

2. Ask the students to independently perform the hands-on activity


instructed in 03 Task Performance 1. Give them 1.5 hours to finish.
Entertain their questions. Roam around to check their progress and
do not forget to acknowledge their work.

GRADUATE ATTRIBUTES CHECKLIST

Creative Conscientious Emotionally Mature


Fluency Orderly Self-awareness
Flexibility Dutiful Self-management
Originality Self-disciplined Social Awareness
Elaboration Relationship Management

Effective Communicator Team Player Critical Thinker


Speaking Networking Challenged Thinker
Listening Coordinating Beginning Thinker
Body Language Cooperating Practicing Thinker
Reading Collaborating
Writing

Proactive Lifelong Learner


Anticipatory Self-motivated
Plan-oriented Self-regulated
Action-directed Self-directed

Assembly Language and the x86 Processor Architecture *Property of STI


Page 14 of 15
K0020

REFERENCES:

Hamacher, C., Vranesic, Z., Zaky, S. and Manjikian, N. (2012). Computer


Organization and Embedded Systems (6th Ed.). McGraw Hill

Stallings, W. (2009). Computer Organization and Architecture: Designing


for Performance (8th Ed.). Prentice-Hall

Tanenbaum, A. (2007). Structured Computer Organization. Prentice-Hall


International

Irvine, K. (2011). Assembly Language for x86 Processors (6th Ed.). Pearson

Assembly Language and the x86 Processor Architecture *Property of STI


Page 15 of 15

You might also like