SlideShare a Scribd company logo
1 of 27
Introduction to Assembly Language
Programming
By – Apeksha Shinde
From- Mucchala Polytechnic
Email – shndapeksha23@gmail.com
Introduction
 Each personal computer has a microprocessor that manages the computer’s
arithmetical, logical, and control activities .
 Each family of processor has its own set of instructions for handling various
operations.
 getting input from keyboard- displaying information on screen – performing
various other jobs.
 These sets of instructions are called “ Machine Language Instruction”
 Processor understands only machine language instructions which are strings of
1s and 0s .
 The low-level assembly language is designed for a specific family of processors
that represents various instructions in symbolic code and more understandable
form.
What is Assembly Language
 An assembly language is low-level programming language for a computer, or other
programmable device.
 It requires less memory and execution time.
 It allows hardware-specific complex jobs in an easier way.
 An understanding of assembly lang provides knowledge of :
i. Interface of programs with OS, processor and BIOS.
ii. Representation of data in memory and other external devices.
iii. How processor accesses and executes instruction.
iv. How instruction accesses and process data.
Assembly Language Development Tools
Editor:
 It is a program which is used to construct the assembly language program in
correct format so that the Assembler will translate it correctly to machine
language.
 An Editor is a program which allows us to create a file containing the assembly
language statement for the program.
 If any typing mistake is done editor will alert us to correct it.
 If we leave out a program statement an editor will let you move everything down
and insert a line.
 After typing all the program we have to save the program for a hard disk.
 This we call it as source file.
 The next step is to process the source file with an assembler.
 While using TASM or MASM we should give a file name and extension .ASM.
 Ex: Sample. Asm
Editors are EDIT,Word Star,Norton Edit
Assembler:
 An Assembler is used to translate the assembly language mnemonics into machine
language( i.e binary codes).
 When you run the assembler it reads the source file of your program from where
you have saved it.
 The assembler generates two files . The first file is the Object file with the
extension .OBJ.
 The object file consists of the binary codes for the instructions and information
about the addresses of the instructions.
 After further processing, the contents of the file will be loaded in to memory and
run. The second file is the assembler list file with the extension .LST.
 Assemblers are TASM(Borland’s Turbo Assembler) MASM(Microsoft Macro Assembler)
Linker :
 A linker is a program used to connect several object files into one large object
file.
 While writing large programs it is better to divide the large program into smaller
modules.
 Each module can be individually written, tested and debugged.
 Then all the object modules are linked together to form one, functioning
program.
 These object modules can also be kept in library file and linked into other
programs as needed. A linker produces a link file which contains the binary codes
for all the combined modules.
 The linker also produces a link map file which contains the address information
about the linked files.
 The linkers which come with TASM or MASM assemblers produce link files with the
.EXE extension.
 Linkers are TLINK(Borland’s Turbo Linker) LINK (Microsoft’s Linker)
Debugger:
 A debugger is a program which allows to load your object code program into
system memory, execute the program, and troubleshoot or debug it.
 Debuggers allows to stop the program after each instruction so that you can check
or alter memory and register contents. This is called single step debug.
 The debugger allows to look into the contents of registers and memory locations
after the program runs. We can also change the contents of registers and memory
locations and rerun the program.
 A debugger also allows to set a breakpoint at any point in the program.
 If we insert a break point, the debugger will run the program up to the instruction
where the breakpoint is put and then stop the execution.
 Debuggers are Borland’s Turbo Debugger TD, Microsoft Debugger Code View(CV).
8086 Microprocessor and its feature
a. 8086 has 16-bit ALU
b. It has 16-bit data bus , so it can read data or write data to memory or I/O ports
either 16 bits or 8 bits at a time .
c. It has 20 address lines , so it can address up to 1048576 = 1Mbytes of memory
d. 8086 includes few features , which enhance multiprocessing capability.
e. Operates on +5v supply and single phase (single line) clock frequency .(Clock is
generated by separate peripheral chip 8284)
f. 8086 comes with different versions. 8086 runs at 5 MHz, 8086-2 runs at 8 MHz, 8086-
1 runs at 10 MHz.
g. It comes in 40-pin configuration with HMOS technology having around 20,000
transistors in its circuitry.
Addressing modes of 8086
Every instruction of a program has to operate on a date. The different ways in
which a source operand is denoted in any instruction are known as addressing
modes.
There are different types of addressing modes
1. Immediate Addressing eg: MOV DL, 08H
2. Register Addressing eg: MOV (CL), (DH)
3. Direct Addressing eg: MOV BX, [1354H]
4. Register Indirect Addressing eg: MOV AX, [BX + 08H]
5. Register relative addressing eg: MOV AX, [BX + 44]
6. Based Indexed addressing eg: MOV CX , [SI + BX]
7. Relative Based Index Addressing eg: MOV DX, [BX + SI + 0AH]
8. Implied / Implicit Addressing eg: CLC
Instruction Sets
8086 supports 8 types of instruction types of instructions
1. Data Transfer Instructions :
Instructions that are used to transfer data/ address in to registers, memory
locations and I/O ports.
Generally involve two operands: Source operand and Destination operand of the
same size.
Mnemonics: MOV, XCHG, PUSH, POP, IN, OUT
2. Arithmetic Instructions :
• ADD , ADC , INC , AAA , DAA , SBB , SUB , DEC , NEG , CMP , AAS , DAS , MUL
IMUL , AAM , DIV, IDIV , AAD , CBW , CDW
3. Bit Manipulation Instruction :
i. AND - Used for adding each bit in a byte/word with the corresponding bit in
another byte/word.
ii. OR - Used to multiply each bit in a byte/word with the corresponding bit in another
byte/word.
iii. NOT - Used to invert each bit of a byte or word.
iv. XOR - Used to perform Exclusive-OR operation over each bit in a byte/word with
the corresponding bit in another byte/ word.
v. TEST - Used to add operands to update flags, without affecting operands.
vi. SHR - Used to shift bits of a byte/word towards the right and put zero(S) in MSBs.
vii. SHL/SAL - Used to shift bits of a byte/word towards left and put zero(S) in LSBs.
viii. ROR - Used to rotate bits of byte/word towards the right, i.e. LSB to MSB and to
Carry Flag [CF].
ix. ROL - Used to rotate bits of byte/word towards the left, i.e. MSB to LSB and to
Carry Flag [CF].
x. RCR - Used to rotate bits of byte/word towards the right, i.e. LSB to CF and CF to
MSB.
xi. RCL - Used to rotate bits of byte/word towards the left, i.e. MSB to CF and CF to
LSB.
4. String Instructions :
String is a group of bytes/words and their memory is always allocated in a sequential
order.
Following is the list of instructions under this group –
•REP − Used to repeat the given instruction till CX ≠ 0.
•REPE/REPZ − Used to repeat the given instruction until CX = 0 or zero flag ZF = 1.
•REPNE/REPNZ − Used to repeat the given instruction until CX = 0 or zero flag ZF = 1.
•MOVS/MOVSB/MOVSW − Used to move the byte/word from one string to another.
•COMS/COMPSB/COMPSW − Used to compare two string bytes/words.
•INS/INSB/INSW − Used as an input string/byte/word from the I/O port to the provided
memory location.
•OUTS/OUTSB/OUTSW − Used as an output string/byte/word from the provided memory
location to the I/O port.
•SCAS/SCASB/SCASW − Used to scan a string and compare its byte with a byte in AL or
string word with a word in AX.
•LODS/LODSB/LODSW − Used to store the string byte into AL or string word into AX.
5. Program Execution Transfer Instructions (Branch and Loop Instructions)
These instructions are used to transfer/branch the instructions during an
execution. It includes the following instructions −
•CALL − Used to call a procedure and save their return address to the stack.
•RET − Used to return from the procedure to the main program.
•JMP − Used to jump to the provvided address to proceed to the next instruction.
•JA/JNBE − Used to jump if above/not below/equal instruction satisfies.
•JAE/JNB − Used to jump if above/not below instruction satisfies.
•JBE/JNA − Used to jump if below/equal/ not above instruction satisfies.
•JC − Used to jump if carry flag CF = 1
•JE/JZ − Used to jump if equal/zero flag ZF = 1
•JG/JNLE − Used to jump if greater/not less than/equal instruction satisfies.
•JGE/JNL − Used to jump if greater than/equal/not less than instruction satisfies.
•JL/JNGE − Used to jump if less than/not greater than/equal instruction satisfies.
•JLE/JNG − Used to jump if less than/equal/if not greater than instruction satisfies.
•JNC − Used to jump if no carry flag (CF = 0)
•JNE/JNZ − Used to jump if not equal/zero flag ZF = 0
•JNO − Used to jump if no overflow flag OF = 0
6. Processor Control Instruction
These instructions are used to control the processor action by
setting/resetting the flag values.
Following are the instructions under this group −
•STC − Used to set carry flag CF to 1
•CLC − Used to clear/reset carry flag CF to 0
•CMC − Used to put complement at the state of carry flag CF.
•STD − Used to set the direction flag DF to 1
•CLD − Used to clear/reset the direction flag DF = 0
•STI − Used to set the interrupt enable flag to 1, i.e., enable INTR input.
•CLI − Used to clear the interrupt enable flag to 0, i.e., disable INTR input.
WAIT - Wait for TEST pin active
7. Iteration Control Instruction
These instructions are used to execute the given instructions for number of times.
Following is the list of instructions under this group −
•LOOP − Used to loop a group of instructions until the condition satisfies, i.e., CX = 0
•LOOPE/LOOPZ − Used to loop a group of instructions till it satisfies ZF = 1 & CX =
0
•LOOPNE/LOOPNZ − Used to loop a group of instructions till it satisfies ZF = 0 & CX
= 0
•JCXZ − Used to jump to the provided address if CX = 0
Interrupt Instructions
8. Interrupt Instructions :
These instructions are used to call the interrupt during program execution.
•INT − Used to interrupt the program during execution and calling service
specified.
•INTO − Used to interrupt the program during execution if OF = 1
•IRET − Used to return from interrupt service to the main program
Assembler Directive
Assembler Directives are the statement that give hint or direction to the Assembler to
perform the task. The Assembler Directives are also known as ‘Pseudo instructions’
because they are not translated into machine codes.
• Used to : › specify the start and end of a program › attach value to variables ›
allocate storage locations to input/ output data › define start and end of segments,
procedures, macros, etc.
The Art of Assembly Language
Programming
Program Development Steps
1. Defining the program
2. Algorithm
3. Initialization checklist
4. Choosing instruction
5. Converting algorithm to assembly language program
Defining the problem: The first step in program developing is the careful analysis of
problem. The objective of the program should be clear to the user.
Algorithm: It is the step by step procedure designed to perform or sovle the task.
Initialization of checklist: Initialize variables, constants etc also initialize various
segments.
Choosing Instruction: It is important to select the proper instruction that will perform
the desired task.
Converting algorithm to assembly language program: In this step instructions are
arranged in the proper sequence according to algorithm and then converting into
machine language.
Here’s a example of an assembly language program
 8 bit numbers subtraction
data segment
a db 09h
b db 05h
c dw ?
data ends
code segment
assume cs:code, ds:data
start:
mov ax, data
mov ds, ax
mov al, a
mov bl, b
sub al, bl
mov c, ax
int 3
code ends
end start o/p = al = 09 , bl = 02
al = 07
Thank you

More Related Content

What's hot

Assembler design options
Assembler design optionsAssembler design options
Assembler design optionsMohd Arif
 
Chapter 2 programming concepts - I
Chapter 2  programming concepts - IChapter 2  programming concepts - I
Chapter 2 programming concepts - ISHREEHARI WADAWADAGI
 
12109 microprocessor & programming
12109 microprocessor & programming12109 microprocessor & programming
12109 microprocessor & programmingGaurang Thakar
 
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 ...Bilal Amjad
 
Introduction to Assembly Language Programming
Introduction to Assembly Language ProgrammingIntroduction to Assembly Language Programming
Introduction to Assembly Language ProgrammingRahul P
 
Lec 04 intro assembly
Lec 04 intro assemblyLec 04 intro assembly
Lec 04 intro assemblyAbdul Khan
 
Examinable Question and answer system programming
Examinable Question and answer system programmingExaminable Question and answer system programming
Examinable Question and answer system programmingMakerere university
 
Systemsoftwarenotes 100929171256-phpapp02 2
Systemsoftwarenotes 100929171256-phpapp02 2Systemsoftwarenotes 100929171256-phpapp02 2
Systemsoftwarenotes 100929171256-phpapp02 2Khaja Dileef
 
Assembler directives and basic steps ALP of 8086
Assembler directives and basic steps ALP of 8086Assembler directives and basic steps ALP of 8086
Assembler directives and basic steps ALP of 8086Urvashi Singh
 
8086 assembly language
8086 assembly language8086 assembly language
8086 assembly languageMir Majid
 

What's hot (20)

Loader
LoaderLoader
Loader
 
ANSI C Macros
ANSI C MacrosANSI C Macros
ANSI C Macros
 
Assembler design options
Assembler design optionsAssembler design options
Assembler design options
 
Chapter 2 programming concepts - I
Chapter 2  programming concepts - IChapter 2  programming concepts - I
Chapter 2 programming concepts - I
 
Assembler
AssemblerAssembler
Assembler
 
12109 microprocessor & programming
12109 microprocessor & programming12109 microprocessor & programming
12109 microprocessor & programming
 
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 ...
 
Introduction to Assembly Language Programming
Introduction to Assembly Language ProgrammingIntroduction to Assembly Language Programming
Introduction to Assembly Language Programming
 
Al2ed chapter7
Al2ed chapter7Al2ed chapter7
Al2ed chapter7
 
Sp2 4
Sp2 4Sp2 4
Sp2 4
 
15ss
15ss15ss
15ss
 
Lec 04 intro assembly
Lec 04 intro assemblyLec 04 intro assembly
Lec 04 intro assembly
 
Examinable Question and answer system programming
Examinable Question and answer system programmingExaminable Question and answer system programming
Examinable Question and answer system programming
 
Two pass Assembler
Two pass AssemblerTwo pass Assembler
Two pass Assembler
 
Macro-processor
Macro-processorMacro-processor
Macro-processor
 
Loader
LoaderLoader
Loader
 
Systemsoftwarenotes 100929171256-phpapp02 2
Systemsoftwarenotes 100929171256-phpapp02 2Systemsoftwarenotes 100929171256-phpapp02 2
Systemsoftwarenotes 100929171256-phpapp02 2
 
Assembler directives and basic steps ALP of 8086
Assembler directives and basic steps ALP of 8086Assembler directives and basic steps ALP of 8086
Assembler directives and basic steps ALP of 8086
 
Assembly language part I
Assembly language part IAssembly language part I
Assembly language part I
 
8086 assembly language
8086 assembly language8086 assembly language
8086 assembly language
 

Similar to Introduction to Assembly Language

Reversing & Malware Analysis Training Part 4 - Assembly Programming Basics
Reversing & Malware Analysis Training Part 4 - Assembly Programming BasicsReversing & Malware Analysis Training Part 4 - Assembly Programming Basics
Reversing & Malware Analysis Training Part 4 - Assembly Programming Basicssecurityxploded
 
Workshop Assembler
Workshop AssemblerWorkshop Assembler
Workshop AssemblerTuhin_Das
 
Assembly language
Assembly languageAssembly language
Assembly languagegaurav jain
 
Reversing malware analysis training part4 assembly programming basics
Reversing malware analysis training part4 assembly programming basicsReversing malware analysis training part4 assembly programming basics
Reversing malware analysis training part4 assembly programming basicsCysinfo Cyber Security Community
 
ASSEMBLY LANGUAGE.pptx
ASSEMBLY LANGUAGE.pptxASSEMBLY LANGUAGE.pptx
ASSEMBLY LANGUAGE.pptxEdFeranil
 
Introduction to debugging linux applications
Introduction to debugging linux applicationsIntroduction to debugging linux applications
Introduction to debugging linux applicationscommiebstrd
 
Assembly level language
Assembly level languageAssembly level language
Assembly level languagePDFSHARE
 
Malware Analysis - x86 Disassembly
Malware Analysis - x86 DisassemblyMalware Analysis - x86 Disassembly
Malware Analysis - x86 DisassemblyNatraj G
 
SP Solutions -Adi.pdf
SP Solutions -Adi.pdfSP Solutions -Adi.pdf
SP Solutions -Adi.pdfAdiseshaK
 
SP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdfSP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdfAdiseshaK
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
Virtualization summary b.docx
Virtualization summary b.docxVirtualization summary b.docx
Virtualization summary b.docxshruti533256
 

Similar to Introduction to Assembly Language (20)

Microprocessor
MicroprocessorMicroprocessor
Microprocessor
 
Assembly language
Assembly languageAssembly language
Assembly language
 
Reversing & Malware Analysis Training Part 4 - Assembly Programming Basics
Reversing & Malware Analysis Training Part 4 - Assembly Programming BasicsReversing & Malware Analysis Training Part 4 - Assembly Programming Basics
Reversing & Malware Analysis Training Part 4 - Assembly Programming Basics
 
Design
DesignDesign
Design
 
microprocessor
 microprocessor microprocessor
microprocessor
 
Mp lab manual
Mp lab manualMp lab manual
Mp lab manual
 
Workshop Assembler
Workshop AssemblerWorkshop Assembler
Workshop Assembler
 
Assembly language
Assembly languageAssembly language
Assembly language
 
Reversing malware analysis training part4 assembly programming basics
Reversing malware analysis training part4 assembly programming basicsReversing malware analysis training part4 assembly programming basics
Reversing malware analysis training part4 assembly programming basics
 
ASSEMBLY LANGUAGE.pptx
ASSEMBLY LANGUAGE.pptxASSEMBLY LANGUAGE.pptx
ASSEMBLY LANGUAGE.pptx
 
Introduction to debugging linux applications
Introduction to debugging linux applicationsIntroduction to debugging linux applications
Introduction to debugging linux applications
 
Assembly level language
Assembly level languageAssembly level language
Assembly level language
 
Malware Analysis - x86 Disassembly
Malware Analysis - x86 DisassemblyMalware Analysis - x86 Disassembly
Malware Analysis - x86 Disassembly
 
SP Solutions -Adi.pdf
SP Solutions -Adi.pdfSP Solutions -Adi.pdf
SP Solutions -Adi.pdf
 
SP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdfSP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdf
 
SP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdfSP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdf
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
7986-lect 7.pdf
7986-lect 7.pdf7986-lect 7.pdf
7986-lect 7.pdf
 
EC8691-MPMC-PPT.pptx
EC8691-MPMC-PPT.pptxEC8691-MPMC-PPT.pptx
EC8691-MPMC-PPT.pptx
 
Virtualization summary b.docx
Virtualization summary b.docxVirtualization summary b.docx
Virtualization summary b.docx
 

Recently uploaded

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Recently uploaded (20)

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Introduction to Assembly Language

  • 1. Introduction to Assembly Language Programming By – Apeksha Shinde From- Mucchala Polytechnic Email – shndapeksha23@gmail.com
  • 2. Introduction  Each personal computer has a microprocessor that manages the computer’s arithmetical, logical, and control activities .  Each family of processor has its own set of instructions for handling various operations.  getting input from keyboard- displaying information on screen – performing various other jobs.  These sets of instructions are called “ Machine Language Instruction”  Processor understands only machine language instructions which are strings of 1s and 0s .  The low-level assembly language is designed for a specific family of processors that represents various instructions in symbolic code and more understandable form.
  • 3. What is Assembly Language  An assembly language is low-level programming language for a computer, or other programmable device.  It requires less memory and execution time.  It allows hardware-specific complex jobs in an easier way.  An understanding of assembly lang provides knowledge of : i. Interface of programs with OS, processor and BIOS. ii. Representation of data in memory and other external devices. iii. How processor accesses and executes instruction. iv. How instruction accesses and process data.
  • 4. Assembly Language Development Tools Editor:  It is a program which is used to construct the assembly language program in correct format so that the Assembler will translate it correctly to machine language.  An Editor is a program which allows us to create a file containing the assembly language statement for the program.  If any typing mistake is done editor will alert us to correct it.  If we leave out a program statement an editor will let you move everything down and insert a line.  After typing all the program we have to save the program for a hard disk.  This we call it as source file.  The next step is to process the source file with an assembler.  While using TASM or MASM we should give a file name and extension .ASM.  Ex: Sample. Asm Editors are EDIT,Word Star,Norton Edit
  • 5. Assembler:  An Assembler is used to translate the assembly language mnemonics into machine language( i.e binary codes).  When you run the assembler it reads the source file of your program from where you have saved it.  The assembler generates two files . The first file is the Object file with the extension .OBJ.  The object file consists of the binary codes for the instructions and information about the addresses of the instructions.  After further processing, the contents of the file will be loaded in to memory and run. The second file is the assembler list file with the extension .LST.  Assemblers are TASM(Borland’s Turbo Assembler) MASM(Microsoft Macro Assembler)
  • 6. Linker :  A linker is a program used to connect several object files into one large object file.  While writing large programs it is better to divide the large program into smaller modules.  Each module can be individually written, tested and debugged.  Then all the object modules are linked together to form one, functioning program.  These object modules can also be kept in library file and linked into other programs as needed. A linker produces a link file which contains the binary codes for all the combined modules.  The linker also produces a link map file which contains the address information about the linked files.  The linkers which come with TASM or MASM assemblers produce link files with the .EXE extension.  Linkers are TLINK(Borland’s Turbo Linker) LINK (Microsoft’s Linker)
  • 7. Debugger:  A debugger is a program which allows to load your object code program into system memory, execute the program, and troubleshoot or debug it.  Debuggers allows to stop the program after each instruction so that you can check or alter memory and register contents. This is called single step debug.  The debugger allows to look into the contents of registers and memory locations after the program runs. We can also change the contents of registers and memory locations and rerun the program.  A debugger also allows to set a breakpoint at any point in the program.  If we insert a break point, the debugger will run the program up to the instruction where the breakpoint is put and then stop the execution.  Debuggers are Borland’s Turbo Debugger TD, Microsoft Debugger Code View(CV).
  • 8. 8086 Microprocessor and its feature a. 8086 has 16-bit ALU b. It has 16-bit data bus , so it can read data or write data to memory or I/O ports either 16 bits or 8 bits at a time . c. It has 20 address lines , so it can address up to 1048576 = 1Mbytes of memory d. 8086 includes few features , which enhance multiprocessing capability. e. Operates on +5v supply and single phase (single line) clock frequency .(Clock is generated by separate peripheral chip 8284) f. 8086 comes with different versions. 8086 runs at 5 MHz, 8086-2 runs at 8 MHz, 8086- 1 runs at 10 MHz. g. It comes in 40-pin configuration with HMOS technology having around 20,000 transistors in its circuitry.
  • 9.
  • 10. Addressing modes of 8086 Every instruction of a program has to operate on a date. The different ways in which a source operand is denoted in any instruction are known as addressing modes. There are different types of addressing modes 1. Immediate Addressing eg: MOV DL, 08H 2. Register Addressing eg: MOV (CL), (DH) 3. Direct Addressing eg: MOV BX, [1354H] 4. Register Indirect Addressing eg: MOV AX, [BX + 08H] 5. Register relative addressing eg: MOV AX, [BX + 44] 6. Based Indexed addressing eg: MOV CX , [SI + BX] 7. Relative Based Index Addressing eg: MOV DX, [BX + SI + 0AH] 8. Implied / Implicit Addressing eg: CLC
  • 11. Instruction Sets 8086 supports 8 types of instruction types of instructions 1. Data Transfer Instructions : Instructions that are used to transfer data/ address in to registers, memory locations and I/O ports. Generally involve two operands: Source operand and Destination operand of the same size. Mnemonics: MOV, XCHG, PUSH, POP, IN, OUT 2. Arithmetic Instructions : • ADD , ADC , INC , AAA , DAA , SBB , SUB , DEC , NEG , CMP , AAS , DAS , MUL IMUL , AAM , DIV, IDIV , AAD , CBW , CDW
  • 12. 3. Bit Manipulation Instruction : i. AND - Used for adding each bit in a byte/word with the corresponding bit in another byte/word. ii. OR - Used to multiply each bit in a byte/word with the corresponding bit in another byte/word. iii. NOT - Used to invert each bit of a byte or word. iv. XOR - Used to perform Exclusive-OR operation over each bit in a byte/word with the corresponding bit in another byte/ word. v. TEST - Used to add operands to update flags, without affecting operands. vi. SHR - Used to shift bits of a byte/word towards the right and put zero(S) in MSBs. vii. SHL/SAL - Used to shift bits of a byte/word towards left and put zero(S) in LSBs. viii. ROR - Used to rotate bits of byte/word towards the right, i.e. LSB to MSB and to Carry Flag [CF]. ix. ROL - Used to rotate bits of byte/word towards the left, i.e. MSB to LSB and to Carry Flag [CF]. x. RCR - Used to rotate bits of byte/word towards the right, i.e. LSB to CF and CF to MSB. xi. RCL - Used to rotate bits of byte/word towards the left, i.e. MSB to CF and CF to LSB.
  • 13. 4. String Instructions : String is a group of bytes/words and their memory is always allocated in a sequential order. Following is the list of instructions under this group – •REP − Used to repeat the given instruction till CX ≠ 0. •REPE/REPZ − Used to repeat the given instruction until CX = 0 or zero flag ZF = 1. •REPNE/REPNZ − Used to repeat the given instruction until CX = 0 or zero flag ZF = 1. •MOVS/MOVSB/MOVSW − Used to move the byte/word from one string to another. •COMS/COMPSB/COMPSW − Used to compare two string bytes/words. •INS/INSB/INSW − Used as an input string/byte/word from the I/O port to the provided memory location. •OUTS/OUTSB/OUTSW − Used as an output string/byte/word from the provided memory location to the I/O port. •SCAS/SCASB/SCASW − Used to scan a string and compare its byte with a byte in AL or string word with a word in AX. •LODS/LODSB/LODSW − Used to store the string byte into AL or string word into AX.
  • 14. 5. Program Execution Transfer Instructions (Branch and Loop Instructions) These instructions are used to transfer/branch the instructions during an execution. It includes the following instructions − •CALL − Used to call a procedure and save their return address to the stack. •RET − Used to return from the procedure to the main program. •JMP − Used to jump to the provvided address to proceed to the next instruction. •JA/JNBE − Used to jump if above/not below/equal instruction satisfies. •JAE/JNB − Used to jump if above/not below instruction satisfies. •JBE/JNA − Used to jump if below/equal/ not above instruction satisfies. •JC − Used to jump if carry flag CF = 1 •JE/JZ − Used to jump if equal/zero flag ZF = 1 •JG/JNLE − Used to jump if greater/not less than/equal instruction satisfies. •JGE/JNL − Used to jump if greater than/equal/not less than instruction satisfies. •JL/JNGE − Used to jump if less than/not greater than/equal instruction satisfies. •JLE/JNG − Used to jump if less than/equal/if not greater than instruction satisfies. •JNC − Used to jump if no carry flag (CF = 0) •JNE/JNZ − Used to jump if not equal/zero flag ZF = 0 •JNO − Used to jump if no overflow flag OF = 0
  • 15. 6. Processor Control Instruction These instructions are used to control the processor action by setting/resetting the flag values. Following are the instructions under this group − •STC − Used to set carry flag CF to 1 •CLC − Used to clear/reset carry flag CF to 0 •CMC − Used to put complement at the state of carry flag CF. •STD − Used to set the direction flag DF to 1 •CLD − Used to clear/reset the direction flag DF = 0 •STI − Used to set the interrupt enable flag to 1, i.e., enable INTR input. •CLI − Used to clear the interrupt enable flag to 0, i.e., disable INTR input. WAIT - Wait for TEST pin active
  • 16. 7. Iteration Control Instruction These instructions are used to execute the given instructions for number of times. Following is the list of instructions under this group − •LOOP − Used to loop a group of instructions until the condition satisfies, i.e., CX = 0 •LOOPE/LOOPZ − Used to loop a group of instructions till it satisfies ZF = 1 & CX = 0 •LOOPNE/LOOPNZ − Used to loop a group of instructions till it satisfies ZF = 0 & CX = 0 •JCXZ − Used to jump to the provided address if CX = 0 Interrupt Instructions
  • 17. 8. Interrupt Instructions : These instructions are used to call the interrupt during program execution. •INT − Used to interrupt the program during execution and calling service specified. •INTO − Used to interrupt the program during execution if OF = 1 •IRET − Used to return from interrupt service to the main program
  • 18. Assembler Directive Assembler Directives are the statement that give hint or direction to the Assembler to perform the task. The Assembler Directives are also known as ‘Pseudo instructions’ because they are not translated into machine codes. • Used to : › specify the start and end of a program › attach value to variables › allocate storage locations to input/ output data › define start and end of segments, procedures, macros, etc.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24. The Art of Assembly Language Programming Program Development Steps 1. Defining the program 2. Algorithm 3. Initialization checklist 4. Choosing instruction 5. Converting algorithm to assembly language program
  • 25. Defining the problem: The first step in program developing is the careful analysis of problem. The objective of the program should be clear to the user. Algorithm: It is the step by step procedure designed to perform or sovle the task. Initialization of checklist: Initialize variables, constants etc also initialize various segments. Choosing Instruction: It is important to select the proper instruction that will perform the desired task. Converting algorithm to assembly language program: In this step instructions are arranged in the proper sequence according to algorithm and then converting into machine language.
  • 26. Here’s a example of an assembly language program  8 bit numbers subtraction data segment a db 09h b db 05h c dw ? data ends code segment assume cs:code, ds:data start: mov ax, data mov ds, ax mov al, a mov bl, b sub al, bl mov c, ax int 3 code ends end start o/p = al = 09 , bl = 02 al = 07