SlideShare a Scribd company logo
1 of 22
Download to read offline
Assembly Language Programming
Prepared by pdfshare
What is Assembly Language?
 Each personal computer has a microprocessor that manages the
computer's arithmetical, logical and control activities.
 Each family of processors has its own set of instructions for handling
various operations like getting input from keyboard, displaying
information on screen and performing various other jobs.
 These set of instructions are called machine language instruction'.
 Processor understands only machine language instructions which are
strings of 1s and 0s. However machine language is too obscure and
complex for using in software development. So the low level assembly
language is designed for a specific family of processors that represents
various instructions in symbolic code and a more understandable form.
Prepared by pdfshare
Advantages of Assembly Language
 An understanding of assembly language provides knowledge of:
 Interface of programs with OS, processor and BIOS;
 Representation of data in memory and other external devices;
 How processor accesses and executes instruction;
 How instructions accesses and process data;
 How a program access external devices.
Other advantages of using assembly language are:
 It requires less memory and execution time;
 It allows hardware-specific complex jobs in an easier way;
 It is suitable for time-critical jobs;
Prepared by pdfshare
Assemblers
Assemblers need to
 translate assembly instructions and pseudo-instructions into
machine instructions.
Convert decimal numbers, etc. specified by programmer into
binary
Typically, assemblers make two passes over the assembly file
 First pass: reads each line and records labels in a symbol table
 Second pass: use info in symbol table to produce actual
machine code for each line
Prepared by pdfshare
Linker
• Tool that merges the object files produced by separate compilation or
assembly and creates an executable file.
• Three tasks
Searches the program to find library routines used by program , e.g.
printf(), math routines,…
Determines the memory locations that code from each module will
occupy and relocates its instructions by adjusting absolute references.
Resolves references among files
Prepared by pdfshare
Debuggers
 A program needed when writing any type of code
 Displays the contents of memory
 Lets you view registers and variables and see how they change
 Allows tracing (stepping through a program one line at a time) .
 A debugger supplied with both DOS and Windows
 Debug.exe
 Found in Windowscommand
 Command line driven
 A precursor of Microsoft Codeview, Borland Turbo Debugger, Visual Studio
Debuggers, Periscope, Atron, SYMDEB, Codesmith-86, Advanced-Trace-86
Prepared by pdfshare
Assembly Level Debugger
 Debug is an assembly level debugger
Displays only assembly mnemonics and machine instructions.
C> debug sample.exe
Debug.exe
Sample.exe
DOS
0000Prepared by pdfshare
Debugging Functions
 Assemble short programs
 View a program’s source code along with its machine language
 View the CPU registers and flags
 Trace or execute a program, watching variables for changes
 Enter new values into memory
 Search for binary or ASCII values in memory
 Move a block of memory from one location to another
 Fill a block of memory
 Load and write disk files and sectors
Prepared by pdfshare
Procedure
 Definition of procedure
 A procedure is a collection of instructions to which we can direct the
flow of our program, and once the execution of these instructions is
over control is given back to the next line to process of the code
which called on the procedure.
 Procedures help us to create legible and easy to modify programs.
 At the time of invoking a procedure the address of the next
instruction of the program is kept on the stack so that, once the flow
of the program has been transferred and the procedure is done, one
can return to the next line
of the original program, the one which called the procedure.
Prepared by pdfshare
Procedure
 A procedure begins with the PROC directive and ends with the ENDP directive.
 each directive appears with the procedure name
 PROC is followed by the type of procedure:
 NEAR or FAR
 In MASM version 6.x, the NEAR or FAR type can be followed by the USES
statement.
 USES allows any number of registers to be automatically pushed to the stack
and popped from the stack within the procedure
Prepared by pdfshare
CALL
 Transfers the flow of the program to the procedure.
 CALL instruction differs from the jump instruction because a CALL
saves a return address on the stack.
 The return address returns control to the instruction that
immediately follows the
CALL in a program when a RET instruction executes.
Prepared by pdfshare
NEAR CALL
 3 bytes long.
 the first byte contains the opcode; the second
and third bytes contain the displacement
 When the near CALL executes, it first pushes the offset address of the next
instruction onto the stack.
 offset address of the next instruction appears in the instruction pointer (IP or
EIP)
 It then adds displacement from bytes 2 & 3
to the IP to transfer control to the procedure.
 Why save the IP or EIP on the stack?
 the instruction pointer always points to the
next instruction in the program
 For the CALL instruction, the contents of IP/EIP are pushed onto the stack.
 program control passes to the instruction following the CALL after a procedure
endsPrepared by pdfshare
FAR CALL
 5-byte instruction contains an opcode followed by the next value for the IP and CS
registers.
 bytes 2 and 3 contain new contents of the IP
 bytes 4 and 5 contain the new contents for CS
 Far CALL places the contents of both IP and CS on the stack before jumping to the address
indicated by bytes 2 through 5.
 This allows far CALL to call a procedure located anywhere in the memory and return from
that procedure.
 The program branches to the procedure.
 A variant of far call exists as CALLF, but should be avoided in favor of defining the
type of call instruction with the PROC statement
 In 64-bit mode a far call is to any memory location and information placed onto the stack is
an 8-byte number.
 the far return instruction retrieves an 8-byte return address from the stack and places it
into RIPPrepared by pdfshare
Memory Initialization/Reservation
These directives will initialize or reserve memory space in the
form of a byte, a word, or a double word in the code space.
The directives for memory initialization and reservation are DB,
DW and DD
These directives will initialize and reserve memory storage in the
form of a byte, a word or a double word in code space
The directive to reserve memory without initialization is DS
This directive will reserve specified number of bytes in the
current segment
Prepared by pdfshare
DB (Define Byte)
 The DB directive initializes code memory with a byte value
 The directive has the following format:
<label>: DB <expression>, <expression>, …
label
is the starting address where the byte values are stored
expression
is the byte value, it can be a character string, a symbol, or an 8-bit
constant
Prepared by pdfshare
DB (Define Byte)
 Example:
CSEG AT 200H
MSG: DB ‘Please enter your password’, 0
ARRAY: DB 10H,20H,30H,40H,50H
 The above string of characters will be stored as ASCII bytes starting from location
200H, which means location [200H]=50H, [201H]=6CH and so on
 Notice that the DB directive can only be declared in a code segment
 If it is defined in a different segment, the assembler will generate an error
Prepared by pdfshare
DW (Define Word)
 The DW directive initializes the code memory with a double byte or a 16-bit word
 The directive has the following format:
<label>: DW <expression>, <expression>, …
 Example:
;2 words allocated
CNTVAL: DW 1025H, 2340H
;10 values of 1234H starting from location XLOC
XLOC: DW 10 DUP (1234H)
 The DUP operator can be used to duplicate a sequence of memory contents
 The DW directive can only be used in the code segment
 If it is defined in other segments, the assembler will give an
error message
Prepared by pdfshare
DD (Define Double Word)
 The DD directive initializes the code memory with double word or 32-bit data
value
 The directive has the following format:
<label>:DD <expression>, <expression>, …
 Example:
ADDR: DD 820056EFH, 10203040H
EMPT: DD 3 DUP ( 0 )
 Same as the DB and DW directives, DD can only be specified in the code segment
 If it is declared in other segment it risks having error message generated by
the assemblerPrepared by pdfshare
DS (Define Storage)
 The DS directive reserves a specified number of bytes in the current segment
 It can only be used in the currently active segment like CSEG, ISEG, DSEG or
XSEG
 The DS directive has the following format:
<label>: DS <expression>
 The expression can not contain forward references, relocatable symbols or
external symbols
Prepared by pdfshare
DS (Define Storage)
 Example:
XSEG AT 1000H ;select memory block from
;external memory, starting ;address from 1000H
Input: DS 16 ; reserve 16 bytes
Wavetyp: DS 1 ; reserve 1 byte
 The location counter of the segment is incremented by one byte every
time the DS statement is encountered in the program
 The programmer should be aware that no more than 16 byte values
should be entered starting from the address ‘Input’ as shown in the
above example
 Notice that the bytes are not initialized, just reservedPrepared by pdfshare
Macro
 Definition of the macro
 A macro is a group of repetitive instructions in a program which are
codified only once and can be used as many times as necessary.
 The main difference between a macro and a procedure is that in the macro
the passage of parameters is possible and in the procedure it is not, this
is only applicable for the TASM - there are other programming languages
which do allow it. At the moment the macro is executed each parameter is
substituted by the name or value specified at the time of the call.
 We can say then that a procedure is an extension of a determined program,
while the macro is a module with specific functions which can be used by
different programs.
 Another difference between a macro and a procedure is the way of calling
each one, to call a procedure the use of a directive is required, on the
other hand the call of macros is done as if it were an assembler
instruction.
Prepared by pdfshare
Prepared By PDFSHARE
Prepared by pdfshare

More Related Content

What's hot

Computer architecture instruction formats
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formatsMazin Alwaaly
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language BasicsEducation Front
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and ArchitectureVinit Raut
 
Introduction to loaders
Introduction to loadersIntroduction to loaders
Introduction to loadersTech_MX
 
Microprogram Control
Microprogram Control Microprogram Control
Microprogram Control Anuj Modi
 
Instruction format
Instruction formatInstruction format
Instruction formatchauhankapil
 
Assembly language programming
Assembly language programmingAssembly language programming
Assembly language programminghimhk
 
Assembly Language and microprocessor
Assembly Language and microprocessorAssembly Language and microprocessor
Assembly Language and microprocessorKhaled Sany
 
Lecture 16 17 code-generation
Lecture 16 17 code-generationLecture 16 17 code-generation
Lecture 16 17 code-generationIffat Anjum
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086aviban
 
Part I:Introduction to assembly language
Part I:Introduction to assembly languagePart I:Introduction to assembly language
Part I:Introduction to assembly languageAhmed M. Abed
 
Computer instructions
Computer instructionsComputer instructions
Computer instructionsAnuj Modi
 
Computer registers
Computer registersComputer registers
Computer registersDeepikaT13
 
Assembly language
Assembly languageAssembly language
Assembly languagegaurav jain
 
Loader and Its types
Loader and Its typesLoader and Its types
Loader and Its typesParth Dodiya
 

What's hot (20)

Computer architecture instruction formats
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formats
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language Basics
 
Assembler
AssemblerAssembler
Assembler
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and Architecture
 
Introduction to loaders
Introduction to loadersIntroduction to loaders
Introduction to loaders
 
Microprogram Control
Microprogram Control Microprogram Control
Microprogram Control
 
Assembly Language
Assembly LanguageAssembly Language
Assembly Language
 
Assembler
AssemblerAssembler
Assembler
 
Instruction format
Instruction formatInstruction format
Instruction format
 
Assembly language programming
Assembly language programmingAssembly language programming
Assembly language programming
 
Two pass Assembler
Two pass AssemblerTwo pass Assembler
Two pass Assembler
 
Assembly Language and microprocessor
Assembly Language and microprocessorAssembly Language and microprocessor
Assembly Language and microprocessor
 
Lecture 16 17 code-generation
Lecture 16 17 code-generationLecture 16 17 code-generation
Lecture 16 17 code-generation
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Part I:Introduction to assembly language
Part I:Introduction to assembly languagePart I:Introduction to assembly language
Part I:Introduction to assembly language
 
Computer instructions
Computer instructionsComputer instructions
Computer instructions
 
Computer registers
Computer registersComputer registers
Computer registers
 
Assembly language
Assembly languageAssembly language
Assembly language
 
Loader and Its types
Loader and Its typesLoader and Its types
Loader and Its types
 

Viewers also liked

Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1Motaz Saad
 
Coal 14 input output devices in Assembly Programming
Coal 14 input output devices in Assembly ProgrammingCoal 14 input output devices in Assembly Programming
Coal 14 input output devices in Assembly ProgrammingMuhammad Taqi Hassan Bukhari
 
Unit 2 assembly language programming
Unit 2   assembly language programmingUnit 2   assembly language programming
Unit 2 assembly language programmingKartik Sharma
 
8086 assembly language
8086 assembly language8086 assembly language
8086 assembly languageMir Majid
 
System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit IIManoj Patil
 
assembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUassembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUEducation
 
Input output accessing
Input output accessingInput output accessing
Input output accessingankitraosingh
 
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGChapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGFrankie Jones
 
Operating system.ppt (1)
Operating system.ppt (1)Operating system.ppt (1)
Operating system.ppt (1)Vaibhav Bajaj
 
Assembly Language Programming Of 8085
Assembly Language Programming Of 8085Assembly Language Programming Of 8085
Assembly Language Programming Of 8085techbed
 

Viewers also liked (12)

Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1
 
Coal7 segmentation in Assembly Programming
Coal7 segmentation in Assembly ProgrammingCoal7 segmentation in Assembly Programming
Coal7 segmentation in Assembly Programming
 
Coal 14 input output devices in Assembly Programming
Coal 14 input output devices in Assembly ProgrammingCoal 14 input output devices in Assembly Programming
Coal 14 input output devices in Assembly Programming
 
8086
80868086
8086
 
Unit 2 assembly language programming
Unit 2   assembly language programmingUnit 2   assembly language programming
Unit 2 assembly language programming
 
8086 assembly language
8086 assembly language8086 assembly language
8086 assembly language
 
System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit II
 
assembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUassembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YU
 
Input output accessing
Input output accessingInput output accessing
Input output accessing
 
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGChapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
 
Operating system.ppt (1)
Operating system.ppt (1)Operating system.ppt (1)
Operating system.ppt (1)
 
Assembly Language Programming Of 8085
Assembly Language Programming Of 8085Assembly Language Programming Of 8085
Assembly Language Programming Of 8085
 

Similar to Assembly level language

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
 
Lec 04 intro assembly
Lec 04 intro assemblyLec 04 intro assembly
Lec 04 intro assemblyAbdul Khan
 
Code generation errors and recovery
Code generation errors and recoveryCode generation errors and recovery
Code generation errors and recoveryMomina Idrees
 
Chapter 2 programming concepts - I
Chapter 2  programming concepts - IChapter 2  programming concepts - I
Chapter 2 programming concepts - ISHREEHARI WADAWADAGI
 
intro to assembly language.pptx
intro to assembly language.pptxintro to assembly language.pptx
intro to assembly language.pptxEdFeranil
 
Embedded System Programming on ARM Cortex M3 and M4 Course
Embedded System Programming on ARM Cortex M3 and M4 CourseEmbedded System Programming on ARM Cortex M3 and M4 Course
Embedded System Programming on ARM Cortex M3 and M4 CourseFastBit Embedded Brain Academy
 
Dive into exploit development
Dive into exploit developmentDive into exploit development
Dive into exploit developmentPayampardaz
 
1 Describe different types of Assemblers.Assembly language.docx
 1 Describe different types of Assemblers.Assembly language.docx 1 Describe different types of Assemblers.Assembly language.docx
1 Describe different types of Assemblers.Assembly language.docxaryan532920
 
N_Asm Assembly basic syntax (sol)
N_Asm Assembly basic syntax (sol)N_Asm Assembly basic syntax (sol)
N_Asm Assembly basic syntax (sol)Selomon birhane
 
Introduction to Assembly Language
Introduction to Assembly Language Introduction to Assembly Language
Introduction to Assembly Language ApekshaShinde6
 

Similar to Assembly level language (20)

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
 
Mp lab manual
Mp lab manualMp lab manual
Mp lab manual
 
Assembly
AssemblyAssembly
Assembly
 
Lec 04 intro assembly
Lec 04 intro assemblyLec 04 intro assembly
Lec 04 intro assembly
 
Code generation errors and recovery
Code generation errors and recoveryCode generation errors and recovery
Code generation errors and recovery
 
Chapter 2 programming concepts - I
Chapter 2  programming concepts - IChapter 2  programming concepts - I
Chapter 2 programming concepts - I
 
intro to assembly language.pptx
intro to assembly language.pptxintro to assembly language.pptx
intro to assembly language.pptx
 
First session quiz
First session quizFirst session quiz
First session quiz
 
First session quiz
First session quizFirst session quiz
First session quiz
 
Chapter 6 notes
Chapter 6 notesChapter 6 notes
Chapter 6 notes
 
Embedded System Programming on ARM Cortex M3 and M4 Course
Embedded System Programming on ARM Cortex M3 and M4 CourseEmbedded System Programming on ARM Cortex M3 and M4 Course
Embedded System Programming on ARM Cortex M3 and M4 Course
 
Dive into exploit development
Dive into exploit developmentDive into exploit development
Dive into exploit development
 
1 Describe different types of Assemblers.Assembly language.docx
 1 Describe different types of Assemblers.Assembly language.docx 1 Describe different types of Assemblers.Assembly language.docx
1 Describe different types of Assemblers.Assembly language.docx
 
EC8691-MPMC-PPT.pptx
EC8691-MPMC-PPT.pptxEC8691-MPMC-PPT.pptx
EC8691-MPMC-PPT.pptx
 
Chapter 5 notes
Chapter 5 notesChapter 5 notes
Chapter 5 notes
 
Chapter 5 notes new
Chapter 5 notes newChapter 5 notes new
Chapter 5 notes new
 
20 -miscellaneous
20  -miscellaneous20  -miscellaneous
20 -miscellaneous
 
N_Asm Assembly basic syntax (sol)
N_Asm Assembly basic syntax (sol)N_Asm Assembly basic syntax (sol)
N_Asm Assembly basic syntax (sol)
 
Introduction to Assembly Language
Introduction to Assembly Language Introduction to Assembly Language
Introduction to Assembly Language
 
Unit-2.pptx
Unit-2.pptxUnit-2.pptx
Unit-2.pptx
 

Recently uploaded

Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 

Recently uploaded (20)

Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 

Assembly level language

  • 2. What is Assembly Language?  Each personal computer has a microprocessor that manages the computer's arithmetical, logical and control activities.  Each family of processors has its own set of instructions for handling various operations like getting input from keyboard, displaying information on screen and performing various other jobs.  These set of instructions are called machine language instruction'.  Processor understands only machine language instructions which are strings of 1s and 0s. However machine language is too obscure and complex for using in software development. So the low level assembly language is designed for a specific family of processors that represents various instructions in symbolic code and a more understandable form. Prepared by pdfshare
  • 3. Advantages of Assembly Language  An understanding of assembly language provides knowledge of:  Interface of programs with OS, processor and BIOS;  Representation of data in memory and other external devices;  How processor accesses and executes instruction;  How instructions accesses and process data;  How a program access external devices. Other advantages of using assembly language are:  It requires less memory and execution time;  It allows hardware-specific complex jobs in an easier way;  It is suitable for time-critical jobs; Prepared by pdfshare
  • 4. Assemblers Assemblers need to  translate assembly instructions and pseudo-instructions into machine instructions. Convert decimal numbers, etc. specified by programmer into binary Typically, assemblers make two passes over the assembly file  First pass: reads each line and records labels in a symbol table  Second pass: use info in symbol table to produce actual machine code for each line Prepared by pdfshare
  • 5. Linker • Tool that merges the object files produced by separate compilation or assembly and creates an executable file. • Three tasks Searches the program to find library routines used by program , e.g. printf(), math routines,… Determines the memory locations that code from each module will occupy and relocates its instructions by adjusting absolute references. Resolves references among files Prepared by pdfshare
  • 6. Debuggers  A program needed when writing any type of code  Displays the contents of memory  Lets you view registers and variables and see how they change  Allows tracing (stepping through a program one line at a time) .  A debugger supplied with both DOS and Windows  Debug.exe  Found in Windowscommand  Command line driven  A precursor of Microsoft Codeview, Borland Turbo Debugger, Visual Studio Debuggers, Periscope, Atron, SYMDEB, Codesmith-86, Advanced-Trace-86 Prepared by pdfshare
  • 7. Assembly Level Debugger  Debug is an assembly level debugger Displays only assembly mnemonics and machine instructions. C> debug sample.exe Debug.exe Sample.exe DOS 0000Prepared by pdfshare
  • 8. Debugging Functions  Assemble short programs  View a program’s source code along with its machine language  View the CPU registers and flags  Trace or execute a program, watching variables for changes  Enter new values into memory  Search for binary or ASCII values in memory  Move a block of memory from one location to another  Fill a block of memory  Load and write disk files and sectors Prepared by pdfshare
  • 9. Procedure  Definition of procedure  A procedure is a collection of instructions to which we can direct the flow of our program, and once the execution of these instructions is over control is given back to the next line to process of the code which called on the procedure.  Procedures help us to create legible and easy to modify programs.  At the time of invoking a procedure the address of the next instruction of the program is kept on the stack so that, once the flow of the program has been transferred and the procedure is done, one can return to the next line of the original program, the one which called the procedure. Prepared by pdfshare
  • 10. Procedure  A procedure begins with the PROC directive and ends with the ENDP directive.  each directive appears with the procedure name  PROC is followed by the type of procedure:  NEAR or FAR  In MASM version 6.x, the NEAR or FAR type can be followed by the USES statement.  USES allows any number of registers to be automatically pushed to the stack and popped from the stack within the procedure Prepared by pdfshare
  • 11. CALL  Transfers the flow of the program to the procedure.  CALL instruction differs from the jump instruction because a CALL saves a return address on the stack.  The return address returns control to the instruction that immediately follows the CALL in a program when a RET instruction executes. Prepared by pdfshare
  • 12. NEAR CALL  3 bytes long.  the first byte contains the opcode; the second and third bytes contain the displacement  When the near CALL executes, it first pushes the offset address of the next instruction onto the stack.  offset address of the next instruction appears in the instruction pointer (IP or EIP)  It then adds displacement from bytes 2 & 3 to the IP to transfer control to the procedure.  Why save the IP or EIP on the stack?  the instruction pointer always points to the next instruction in the program  For the CALL instruction, the contents of IP/EIP are pushed onto the stack.  program control passes to the instruction following the CALL after a procedure endsPrepared by pdfshare
  • 13. FAR CALL  5-byte instruction contains an opcode followed by the next value for the IP and CS registers.  bytes 2 and 3 contain new contents of the IP  bytes 4 and 5 contain the new contents for CS  Far CALL places the contents of both IP and CS on the stack before jumping to the address indicated by bytes 2 through 5.  This allows far CALL to call a procedure located anywhere in the memory and return from that procedure.  The program branches to the procedure.  A variant of far call exists as CALLF, but should be avoided in favor of defining the type of call instruction with the PROC statement  In 64-bit mode a far call is to any memory location and information placed onto the stack is an 8-byte number.  the far return instruction retrieves an 8-byte return address from the stack and places it into RIPPrepared by pdfshare
  • 14. Memory Initialization/Reservation These directives will initialize or reserve memory space in the form of a byte, a word, or a double word in the code space. The directives for memory initialization and reservation are DB, DW and DD These directives will initialize and reserve memory storage in the form of a byte, a word or a double word in code space The directive to reserve memory without initialization is DS This directive will reserve specified number of bytes in the current segment Prepared by pdfshare
  • 15. DB (Define Byte)  The DB directive initializes code memory with a byte value  The directive has the following format: <label>: DB <expression>, <expression>, … label is the starting address where the byte values are stored expression is the byte value, it can be a character string, a symbol, or an 8-bit constant Prepared by pdfshare
  • 16. DB (Define Byte)  Example: CSEG AT 200H MSG: DB ‘Please enter your password’, 0 ARRAY: DB 10H,20H,30H,40H,50H  The above string of characters will be stored as ASCII bytes starting from location 200H, which means location [200H]=50H, [201H]=6CH and so on  Notice that the DB directive can only be declared in a code segment  If it is defined in a different segment, the assembler will generate an error Prepared by pdfshare
  • 17. DW (Define Word)  The DW directive initializes the code memory with a double byte or a 16-bit word  The directive has the following format: <label>: DW <expression>, <expression>, …  Example: ;2 words allocated CNTVAL: DW 1025H, 2340H ;10 values of 1234H starting from location XLOC XLOC: DW 10 DUP (1234H)  The DUP operator can be used to duplicate a sequence of memory contents  The DW directive can only be used in the code segment  If it is defined in other segments, the assembler will give an error message Prepared by pdfshare
  • 18. DD (Define Double Word)  The DD directive initializes the code memory with double word or 32-bit data value  The directive has the following format: <label>:DD <expression>, <expression>, …  Example: ADDR: DD 820056EFH, 10203040H EMPT: DD 3 DUP ( 0 )  Same as the DB and DW directives, DD can only be specified in the code segment  If it is declared in other segment it risks having error message generated by the assemblerPrepared by pdfshare
  • 19. DS (Define Storage)  The DS directive reserves a specified number of bytes in the current segment  It can only be used in the currently active segment like CSEG, ISEG, DSEG or XSEG  The DS directive has the following format: <label>: DS <expression>  The expression can not contain forward references, relocatable symbols or external symbols Prepared by pdfshare
  • 20. DS (Define Storage)  Example: XSEG AT 1000H ;select memory block from ;external memory, starting ;address from 1000H Input: DS 16 ; reserve 16 bytes Wavetyp: DS 1 ; reserve 1 byte  The location counter of the segment is incremented by one byte every time the DS statement is encountered in the program  The programmer should be aware that no more than 16 byte values should be entered starting from the address ‘Input’ as shown in the above example  Notice that the bytes are not initialized, just reservedPrepared by pdfshare
  • 21. Macro  Definition of the macro  A macro is a group of repetitive instructions in a program which are codified only once and can be used as many times as necessary.  The main difference between a macro and a procedure is that in the macro the passage of parameters is possible and in the procedure it is not, this is only applicable for the TASM - there are other programming languages which do allow it. At the moment the macro is executed each parameter is substituted by the name or value specified at the time of the call.  We can say then that a procedure is an extension of a determined program, while the macro is a module with specific functions which can be used by different programs.  Another difference between a macro and a procedure is the way of calling each one, to call a procedure the use of a directive is required, on the other hand the call of macros is done as if it were an assembler instruction. Prepared by pdfshare