SlideShare a Scribd company logo
1 of 43
Intro to Assembly
Language
MUHAMMAD TASNIM MOHIUDDIN
LECTURER, CSE, UIU
1
Levels of Programming Languages
1) Machine Language
2) Assembly Language (Low Level Language)
3) High Level Languages
2
Machine Language
 Set of fundamental instructions
 Native to a processor: executed directly by hardware
 Expressed as a pattern of 1’s and 0’s
Here’s what a program-fragment looks like:
10100001 10111100 10010011 00000100
00001000 00000011 00000101 11000000
10010011 00000100 00001000 10100011
11000000 10010100 00000100 00001000
It means: z = x + y;
3
Assembly Language
 One step up from machine language
 Designed for a specific family of processors (different processor groups/family
has different Assembly Language)
 Consists of symbolic instructions directly related to machine language
instructions one-for-one and are assembled into machine language.
 Alphanumeric equivalent of machine language
 Mnemonics more human-oriented than 1’s and 0’s
 Example: for A = A + 4
MOV AX, A
ADD AX, 4
MOV A, AX
4
High Level Languages
 Similar to Natural language.
 Designed to eliminate the technicalities of a particular computer.
 Statements compiled in a high level language typically generate many low-
level instructions.
 Example: C, Java, Python etc
5
Advantages of High-Level Languages
 Program development is faster
 High-level statements: fewer instructions to code
 Program maintenance is easier
 For the same above reasons
 Programs are portable
6
Why Assembly Language?
 Accessibility to system hardware
 Assembly Language is useful for implementing system software
 Also useful for small embedded system applications
 Faster and shorter programs.
 Compilers do not always generate optimum code.
 Resident programs (that reside in memory while other program execute)
and interrupt service routines (that handle input and output) are almost
always develop in Assembly Language.
 Instruction set knowledge is important for machine designers.
 Compiler writers must be familiar with details of machine language.
7
Advantages of Assembly Language
 Shows how program interfaces with the processor, operating system, and
BIOS.
 Shows how data is represented and stored in memory and on external
devices.
 Clarifies how processor accesses and executes instructions and how
instructions access and process data.
8
Assembler
 An assembler is a program that converts source-code programs written in
assembly language into object files in machine language
 Popular assemblers have emerged over the years for the Intel family of
processors. These include …
 TASM (Turbo Assembler from Borland)
 NASM (Netwide Assembler for both Windows and Linux), and
 GNU assembler distributed by the free software foundation
9
Compiler and Assembler 10
Computer Architecture
CPU
I/O Devices
Memory
11
Computer Architecture
Control Bus
CPU Memory I/O
Address Bus
Data Bus
12
Organization of 8086 Processor
 16 bit Processor
 16 bit data bus
 16 bit registers
 20 bit Address bus
13
Organization of 8086 Processor
CPU Memory
Address Bus
Data Bus
20
16
CPU-Memory Interface
16-bit
Control Bus
14
Bytes and Words
 Information processed by computer is stored in its memory
 A memory element can store one bit of data
 Group of 8 bits forms one byte
 Group of 16 bits or 2 bytes forms one word
15
RAM and ROM
 Random-Access Memory (RAM)
 Can be performed read and write operation
 Program instruction and data are loaded into RAM
 Contents are lost when the machine is turned off
 ROM (Read-Only-Memory)
 Once initialized can’t be changed, can only be read
 Retain values event the machine is turned off
 Hence used to store system programs
16
Address Space of 8086 17
Number System
18
Number System
• Consists of TWO Things:
– A BASE or RADIX Value
– A SET of DIGITS
• Digits are symbols representing all values
less than the radix value.
• Example is the Common Decimal System:
– RADIX (BASE) = 10
– Digit Set = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
19
Decimal Number Systems
 Consider: 5032.21
210123
10
)10(1)10(2)10(2)10(3)10(0)10(5
01.02.023005000)21.5032(


5032.21
20
Commonly Occurring Bases
• Binary
– Radix = (2)10
– Digit Set = {0,1}
• Octal
– Radix = (8)10
– Digit Set = {0,1,2,3,4,5,6,7}
• Hexadecimal
– Radix = (16)10
– Digit Set = {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}
21
Any Base to Decimal
 A number with radix r is represented by a string of
digits:
An - 1An - 2 … A1A0 . A- 1 A- 2 … A- m  1 A- m
The string of digits represents the power series:
(Number)r
=
 
j = - 1
j
j
i
i = 0
i rArA
(Integer Portion) + (Fractional Portion)
i = n - 1 j = - m
22
Hexadecimal
 16-base number system
 16 symbols (0—9, A, B, C, D, E, F)
 Again radix is power of 2
 4 bits to represent a hexadecimal number
23
Hexadecimal to Binary
Restate the hexadecimal as four binary digits starting
at the radix point and going both ways.
24
Binary to Hexadecimal
Group the binary digits into four bits groups starting at
the radix point and going both ways, padding with
zeros as needed in the fractional part.
Convert each group of three bits to an hexadecimal
digit.
25
Binary to Hexadecimal 26
Binary Negative Numbers
• In decimal we are quite familiar with placing a
“-” sign in front of a number to denote that it is negative
• But for binary numbers a computer won’t understand
that
• What happens in memory then?
27
Binary Negative Numbers
There are several representations
- Signed magnitude
- One’s complement
- Two’s complement
28
Signed Magnitude
 Left bit (MSB) used as the sign bit
29
One’s Complement
 Invert the ones and zeros
30
Subtraction with One's Complement
 Steps for subtracting x from y with an n-bit 1's
complement representation:
 Negate x using 1's complement.
 Add -x and y.
 If the sum exceeds n bits, add the extra bit to the result.
 If the sum does not exceed n bits, leave the result as it is.
The result will be in 1's complement form
31
Example: subtracting 1 from 7 using 1's
complement
First, we need to convert 0001 to its negative equivalent in 1's complement.
Next we perform addition of 7 and our computed 1's complement of -1.
Notice that our addition caused an overflow bit. Whenever we have an overflow
bit in 1's complement, we add this bit to our sum to get the correct answer. If
there is no overflow bit, then we leave the sum as it is.
32
Another Example 33
Two’s Complement
Take 1’s complement then add 1
OR
Toggle all bits to the left of the first ‘1’ from the right
Example:
0 1 0 1 0 0 0 0
1 0 1 1 0 0 0 0
0 1 0 0 1 1 1 1
+ 1
1 0 1 1 0 0 0 0
00001010
34
Two’s Complement 35
Subtraction with Two’s Complement
Steps for subtracting x from y with an n-bit 2's
complement representation:
Negate x using 2's complement.
 Reverse all the bits in x.
 Add 1 to form -x.
Add -x and y.
Discard any bits greater than n.
The result will be in 2's complement form
36
Example: subtracting 1 from 7 using 2's
complement
First, we need to convert 00012 to its negative equivalent in 2's complement.
Next we perform addition of 7 and our computed 2's complement of -1.
Notice that our addition caused an overflow bit. Whenever we have an overflow
bit in 2's complement, we discard the extra bit. This gives us a final answer of
01102 (or 610)
37
Another Example
 1 -7 = 1 + (-7)
0001
+1001
1010
2’s complement of -7
1010 is the 2’s complement of -6
38
Registers of 8086
Intel 8086 contains following registers:
General Purpose Registers
Pointer and Index Registers
Segment Registers
Instruction Pointer
Status Flags
39
General Purpose Registers
There are four 16-bit general purpose registers:
Accumulator Register (AX)
Base Register (BX)
Count Register (CX)
Data Register (DX)
40
Following four 16-bit registers are under this
category:
Stack Pointer (SP)
Base Pointer (BP)
Source Index (SI)
 Destination Index (DI).
Pointer & Index Register 41
Segment Register
There are four 16-bit segment registers in Intel
8086:
 Code Segment Register (CS),
 Data Segment Register (DS),
 Stack Segment Register (SS),
 Extra Segment Register (ES).
42
Rest 2 Registers
Instruction Pointer
Status Flag Register
43

More Related Content

What's hot

Assembly language programming
Assembly language programmingAssembly language programming
Assembly language programming
himhk
 
Cache memory
Cache memoryCache memory
Cache memory
Anuj Modi
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
9840596838
 

What's hot (20)

Lecture ascii and ebcdic codes
Lecture ascii and ebcdic codesLecture ascii and ebcdic codes
Lecture ascii and ebcdic codes
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
Assembly language progarmming
Assembly language progarmmingAssembly language progarmming
Assembly language progarmming
 
Basic Computer Organization and Design
Basic  Computer  Organization  and  DesignBasic  Computer  Organization  and  Design
Basic Computer Organization and Design
 
Assembly level language
Assembly level languageAssembly level language
Assembly level language
 
Assembly language programming
Assembly language programmingAssembly language programming
Assembly language programming
 
8086 microprocessor lab manual
8086 microprocessor lab manual8086 microprocessor lab manual
8086 microprocessor lab manual
 
Microprogrammed Control Unit
Microprogrammed Control UnitMicroprogrammed Control Unit
Microprogrammed Control Unit
 
Computer Organization and Assembly Language
Computer Organization and Assembly LanguageComputer Organization and Assembly Language
Computer Organization and Assembly Language
 
Cache memory
Cache memoryCache memory
Cache memory
 
8086 assembly
8086 assembly8086 assembly
8086 assembly
 
Addressing Modes
Addressing ModesAddressing Modes
Addressing Modes
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Chapter 5The proessor status and the FLAGS registers
Chapter 5The proessor status and the FLAGS registersChapter 5The proessor status and the FLAGS registers
Chapter 5The proessor status and the FLAGS registers
 
Computer registers
Computer registersComputer registers
Computer registers
 
Instruction format
Instruction formatInstruction format
Instruction format
 
memory reference instruction
memory reference instructionmemory reference instruction
memory reference instruction
 
design of accumlator
design of accumlatordesign of accumlator
design of accumlator
 
Chapter 6 Flow control Instructions
Chapter 6 Flow control InstructionsChapter 6 Flow control Instructions
Chapter 6 Flow control Instructions
 
Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1
 

Viewers also liked

Chp6 assembly language programming for pic copy
Chp6 assembly language programming for pic   copyChp6 assembly language programming for pic   copy
Chp6 assembly language programming for pic copy
mkazree
 

Viewers also liked (20)

Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly Language
 
Assembly Language -I
Assembly Language -IAssembly Language -I
Assembly Language -I
 
Assembly Language Lecture 5
Assembly Language Lecture 5Assembly Language Lecture 5
Assembly Language Lecture 5
 
Assembly
AssemblyAssembly
Assembly
 
.NET Framework Projet with C#
.NET Framework Projet with C#.NET Framework Projet with C#
.NET Framework Projet with C#
 
Assembly fundamentals
Assembly fundamentalsAssembly fundamentals
Assembly fundamentals
 
Assembly Language Tanka - SAKAI Hiroaki
Assembly Language Tanka - SAKAI HiroakiAssembly Language Tanka - SAKAI Hiroaki
Assembly Language Tanka - SAKAI Hiroaki
 
Assembly language part I
Assembly language part IAssembly language part I
Assembly language part I
 
Chapt 01 basic concepts
Chapt 01   basic conceptsChapt 01   basic concepts
Chapt 01 basic concepts
 
Processor Basics
Processor BasicsProcessor Basics
Processor Basics
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Lec 01 basic concepts
Lec 01 basic conceptsLec 01 basic concepts
Lec 01 basic concepts
 
[ASM] Lab1
[ASM] Lab1[ASM] Lab1
[ASM] Lab1
 
Assembly Language Lecture 4
Assembly Language Lecture 4Assembly Language Lecture 4
Assembly Language Lecture 4
 
Assembly Language Lecture 2
Assembly Language Lecture 2Assembly Language Lecture 2
Assembly Language Lecture 2
 
Math Puzzle Game By Assembly Language
Math Puzzle Game By Assembly LanguageMath Puzzle Game By Assembly Language
Math Puzzle Game By Assembly Language
 
Chp6 assembly language programming for pic copy
Chp6 assembly language programming for pic   copyChp6 assembly language programming for pic   copy
Chp6 assembly language programming for pic copy
 
08. Numeral Systems
08. Numeral Systems08. Numeral Systems
08. Numeral Systems
 
Chapt 01 Assembly Language
Chapt 01 Assembly LanguageChapt 01 Assembly Language
Chapt 01 Assembly Language
 

Similar to Intro to assembly language

6_2018_11_23!09_24_56_PM (1).pptx
6_2018_11_23!09_24_56_PM (1).pptx6_2018_11_23!09_24_56_PM (1).pptx
6_2018_11_23!09_24_56_PM (1).pptx
HebaEng
 
6_2020_12_23!08_00_40_AM.pdf
6_2020_12_23!08_00_40_AM.pdf6_2020_12_23!08_00_40_AM.pdf
6_2020_12_23!08_00_40_AM.pdf
HebaEng
 
Computers numbering systems
Computers   numbering systemsComputers   numbering systems
Computers numbering systems
sld1950
 

Similar to Intro to assembly language (20)

Gsp 215 Future Our Mission/newtonhelp.com
Gsp 215 Future Our Mission/newtonhelp.comGsp 215 Future Our Mission/newtonhelp.com
Gsp 215 Future Our Mission/newtonhelp.com
 
GSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.comGSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.com
 
GSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.comGSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.com
 
GSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.comGSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.com
 
6_2018_11_23!09_24_56_PM (1).pptx
6_2018_11_23!09_24_56_PM (1).pptx6_2018_11_23!09_24_56_PM (1).pptx
6_2018_11_23!09_24_56_PM (1).pptx
 
Process.org
Process.orgProcess.org
Process.org
 
data representation
 data representation data representation
data representation
 
C programming part2
C programming part2C programming part2
C programming part2
 
C programming part2
C programming part2C programming part2
C programming part2
 
C programming part2
C programming part2C programming part2
C programming part2
 
Datarepresentation2
Datarepresentation2Datarepresentation2
Datarepresentation2
 
Data representation moris mano ch 03
Data representation   moris mano ch  03Data representation   moris mano ch  03
Data representation moris mano ch 03
 
6_2020_12_23!08_00_40_AM.pdf
6_2020_12_23!08_00_40_AM.pdf6_2020_12_23!08_00_40_AM.pdf
6_2020_12_23!08_00_40_AM.pdf
 
Computers numbering systems
Computers   numbering systemsComputers   numbering systems
Computers numbering systems
 
Introduction to computers
Introduction to computersIntroduction to computers
Introduction to computers
 
Ch3
Ch3Ch3
Ch3
 
GSP 215 Enhance teaching/tutorialrank.com
 GSP 215 Enhance teaching/tutorialrank.com GSP 215 Enhance teaching/tutorialrank.com
GSP 215 Enhance teaching/tutorialrank.com
 
GSP 215 Inspiring Innovation/tutorialrank.com
GSP 215 Inspiring Innovation/tutorialrank.comGSP 215 Inspiring Innovation/tutorialrank.com
GSP 215 Inspiring Innovation/tutorialrank.com
 
DATA REPRESENTATION
DATA  REPRESENTATIONDATA  REPRESENTATION
DATA REPRESENTATION
 
Introduction to digital computers and Number systems.pptx
Introduction to digital computers and Number systems.pptxIntroduction to digital computers and Number systems.pptx
Introduction to digital computers and Number systems.pptx
 

Recently uploaded

Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
AldoGarca30
 

Recently uploaded (20)

Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 

Intro to assembly language

  • 1. Intro to Assembly Language MUHAMMAD TASNIM MOHIUDDIN LECTURER, CSE, UIU 1
  • 2. Levels of Programming Languages 1) Machine Language 2) Assembly Language (Low Level Language) 3) High Level Languages 2
  • 3. Machine Language  Set of fundamental instructions  Native to a processor: executed directly by hardware  Expressed as a pattern of 1’s and 0’s Here’s what a program-fragment looks like: 10100001 10111100 10010011 00000100 00001000 00000011 00000101 11000000 10010011 00000100 00001000 10100011 11000000 10010100 00000100 00001000 It means: z = x + y; 3
  • 4. Assembly Language  One step up from machine language  Designed for a specific family of processors (different processor groups/family has different Assembly Language)  Consists of symbolic instructions directly related to machine language instructions one-for-one and are assembled into machine language.  Alphanumeric equivalent of machine language  Mnemonics more human-oriented than 1’s and 0’s  Example: for A = A + 4 MOV AX, A ADD AX, 4 MOV A, AX 4
  • 5. High Level Languages  Similar to Natural language.  Designed to eliminate the technicalities of a particular computer.  Statements compiled in a high level language typically generate many low- level instructions.  Example: C, Java, Python etc 5
  • 6. Advantages of High-Level Languages  Program development is faster  High-level statements: fewer instructions to code  Program maintenance is easier  For the same above reasons  Programs are portable 6
  • 7. Why Assembly Language?  Accessibility to system hardware  Assembly Language is useful for implementing system software  Also useful for small embedded system applications  Faster and shorter programs.  Compilers do not always generate optimum code.  Resident programs (that reside in memory while other program execute) and interrupt service routines (that handle input and output) are almost always develop in Assembly Language.  Instruction set knowledge is important for machine designers.  Compiler writers must be familiar with details of machine language. 7
  • 8. Advantages of Assembly Language  Shows how program interfaces with the processor, operating system, and BIOS.  Shows how data is represented and stored in memory and on external devices.  Clarifies how processor accesses and executes instructions and how instructions access and process data. 8
  • 9. Assembler  An assembler is a program that converts source-code programs written in assembly language into object files in machine language  Popular assemblers have emerged over the years for the Intel family of processors. These include …  TASM (Turbo Assembler from Borland)  NASM (Netwide Assembler for both Windows and Linux), and  GNU assembler distributed by the free software foundation 9
  • 12. Computer Architecture Control Bus CPU Memory I/O Address Bus Data Bus 12
  • 13. Organization of 8086 Processor  16 bit Processor  16 bit data bus  16 bit registers  20 bit Address bus 13
  • 14. Organization of 8086 Processor CPU Memory Address Bus Data Bus 20 16 CPU-Memory Interface 16-bit Control Bus 14
  • 15. Bytes and Words  Information processed by computer is stored in its memory  A memory element can store one bit of data  Group of 8 bits forms one byte  Group of 16 bits or 2 bytes forms one word 15
  • 16. RAM and ROM  Random-Access Memory (RAM)  Can be performed read and write operation  Program instruction and data are loaded into RAM  Contents are lost when the machine is turned off  ROM (Read-Only-Memory)  Once initialized can’t be changed, can only be read  Retain values event the machine is turned off  Hence used to store system programs 16
  • 17. Address Space of 8086 17
  • 19. Number System • Consists of TWO Things: – A BASE or RADIX Value – A SET of DIGITS • Digits are symbols representing all values less than the radix value. • Example is the Common Decimal System: – RADIX (BASE) = 10 – Digit Set = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} 19
  • 20. Decimal Number Systems  Consider: 5032.21 210123 10 )10(1)10(2)10(2)10(3)10(0)10(5 01.02.023005000)21.5032(   5032.21 20
  • 21. Commonly Occurring Bases • Binary – Radix = (2)10 – Digit Set = {0,1} • Octal – Radix = (8)10 – Digit Set = {0,1,2,3,4,5,6,7} • Hexadecimal – Radix = (16)10 – Digit Set = {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F} 21
  • 22. Any Base to Decimal  A number with radix r is represented by a string of digits: An - 1An - 2 … A1A0 . A- 1 A- 2 … A- m  1 A- m The string of digits represents the power series: (Number)r =   j = - 1 j j i i = 0 i rArA (Integer Portion) + (Fractional Portion) i = n - 1 j = - m 22
  • 23. Hexadecimal  16-base number system  16 symbols (0—9, A, B, C, D, E, F)  Again radix is power of 2  4 bits to represent a hexadecimal number 23
  • 24. Hexadecimal to Binary Restate the hexadecimal as four binary digits starting at the radix point and going both ways. 24
  • 25. Binary to Hexadecimal Group the binary digits into four bits groups starting at the radix point and going both ways, padding with zeros as needed in the fractional part. Convert each group of three bits to an hexadecimal digit. 25
  • 27. Binary Negative Numbers • In decimal we are quite familiar with placing a “-” sign in front of a number to denote that it is negative • But for binary numbers a computer won’t understand that • What happens in memory then? 27
  • 28. Binary Negative Numbers There are several representations - Signed magnitude - One’s complement - Two’s complement 28
  • 29. Signed Magnitude  Left bit (MSB) used as the sign bit 29
  • 30. One’s Complement  Invert the ones and zeros 30
  • 31. Subtraction with One's Complement  Steps for subtracting x from y with an n-bit 1's complement representation:  Negate x using 1's complement.  Add -x and y.  If the sum exceeds n bits, add the extra bit to the result.  If the sum does not exceed n bits, leave the result as it is. The result will be in 1's complement form 31
  • 32. Example: subtracting 1 from 7 using 1's complement First, we need to convert 0001 to its negative equivalent in 1's complement. Next we perform addition of 7 and our computed 1's complement of -1. Notice that our addition caused an overflow bit. Whenever we have an overflow bit in 1's complement, we add this bit to our sum to get the correct answer. If there is no overflow bit, then we leave the sum as it is. 32
  • 34. Two’s Complement Take 1’s complement then add 1 OR Toggle all bits to the left of the first ‘1’ from the right Example: 0 1 0 1 0 0 0 0 1 0 1 1 0 0 0 0 0 1 0 0 1 1 1 1 + 1 1 0 1 1 0 0 0 0 00001010 34
  • 36. Subtraction with Two’s Complement Steps for subtracting x from y with an n-bit 2's complement representation: Negate x using 2's complement.  Reverse all the bits in x.  Add 1 to form -x. Add -x and y. Discard any bits greater than n. The result will be in 2's complement form 36
  • 37. Example: subtracting 1 from 7 using 2's complement First, we need to convert 00012 to its negative equivalent in 2's complement. Next we perform addition of 7 and our computed 2's complement of -1. Notice that our addition caused an overflow bit. Whenever we have an overflow bit in 2's complement, we discard the extra bit. This gives us a final answer of 01102 (or 610) 37
  • 38. Another Example  1 -7 = 1 + (-7) 0001 +1001 1010 2’s complement of -7 1010 is the 2’s complement of -6 38
  • 39. Registers of 8086 Intel 8086 contains following registers: General Purpose Registers Pointer and Index Registers Segment Registers Instruction Pointer Status Flags 39
  • 40. General Purpose Registers There are four 16-bit general purpose registers: Accumulator Register (AX) Base Register (BX) Count Register (CX) Data Register (DX) 40
  • 41. Following four 16-bit registers are under this category: Stack Pointer (SP) Base Pointer (BP) Source Index (SI)  Destination Index (DI). Pointer & Index Register 41
  • 42. Segment Register There are four 16-bit segment registers in Intel 8086:  Code Segment Register (CS),  Data Segment Register (DS),  Stack Segment Register (SS),  Extra Segment Register (ES). 42
  • 43. Rest 2 Registers Instruction Pointer Status Flag Register 43