SlideShare a Scribd company logo
1 of 10
1
Strings
2
String Primitive Instructions, Implied Operands.
Instruction Description ImpliedOperands
MOVS
MoveStringData: Copyamemory
byte, word, ordoublewordfromone
memorylocationtoanother.
MOVS [DI],[SI]
CMPS
CompareString: Compareamemory
byte, word, ordoublewordto
memory.
CMPS [SI],[DI]
SCAS
ScanString: CompareAL, AX, or
EAXtothecontentsofmemory,
affectingtheFlagsregister.
SCAS [DI],AL
SCAS [DI],AX
SCAS [DI],EAX
STOS StoreStringData: StoreAL, AX, or
EAXintomemory.
STOS [DI],AL
STOS [DI],AX
STOS [DI],EAX
LODS
LoadAccumulatorfromString:
Loadabyte, word, ordoubleword
intoAL, AX, orEAXfrommemory.
LODS AL,[SI]
LODS AX,[SI]
LODS EAX,[SI]
3
Overview of String Primitive Instructions.
General Specific Size Description
Increment Value
for SI and DI
MOVS MOVSB Move (copy) byte 1
MOVSW Move (copy) word 2
MOVSD Move (copy) doubleword* 4
CMPS CMPSB Compare bytes 1
CMPSW Compare words 2
CMPSD Compare doublewords* 4
SCAS SCASB Scan byte 1
SCASW Scan word 2
SCASD Scan doubleword* 4
STOS STOSB Store byte 1
STOSW Store word 2
STOSD Store doubleword* 4
LODS LODSB Load byte 1
LODSW Load word 2
LODSD Load doubleword* 4
4
ValueoftheDirectionFlagEffectonSIandDIAddressSequence
0 Incremented Low-high
1 Decremented High-low
Direction Flags.
5
MOVS (Move String Data).
Instruction
Valuetobeautomatically
added/subtractedfromSIandDI
MOVSB 1
MOVSW 2
MOVSD 4
6
Unsigned and Signed Jumps.
Condition Unsigned Signed
source< dest JB JL
source<=dest JBE JLE
source≠dest JNE(JNZ) JNE(JNZ)
source= dest JE(JZ) JE(JZ)
source>=dest JAE JGE
source> dest JA JG
7
Scan for a Matching Character.
.data
alpha db ‘ABCDEFGH’,0
.code
mov di,seg alpha
mov es,di
mov di,offset alpha ; ES:DI points to the string
mov al,’F’ ; search for the letter ‘F’
mov cx,8 ; set the search count
cld ; direction = up
repne scasb ; repeat while not equal
jnz exit ; quit if letter is not found
dec di ; found: back up DI one
character
8
String-Handling Procedures.
Procedure Description
Str_compare
Compare two strings according to their
collating sequence. CF = 1 if the first
string is lesser, ZF = 1 if both strings
are equal, and (CF = 0, ZF = 0) if the
first string is greater.
Str_copy Copy a source string to a destination
string.
Str_length Find the length of a string.
Str_getline Read a null-terminated string froma file
or device.
Str_read Read a string froma file or device.
Str_ucase Convert a string to uppercase.
Str_write Write a string to a file or device.
9
Flag Usage by the Str_compare Procedure.
RelationBetween
Strings
CarryFlag ZeroFlag
RelatedJump
Instruction
first<second 1 0 JB
first=second 0 1 JE
first>second 0 0 JA
9
Flag Usage by the Str_compare Procedure.
RelationBetween
Strings
CarryFlag ZeroFlag
RelatedJump
Instruction
first<second 1 0 JB
first=second 0 1 JE
first>second 0 0 JA

More Related Content

What's hot (20)

Modeling- Object, Dynamic and Functional
Modeling- Object, Dynamic and FunctionalModeling- Object, Dynamic and Functional
Modeling- Object, Dynamic and Functional
 
Introduction to Relational Databases
Introduction to Relational DatabasesIntroduction to Relational Databases
Introduction to Relational Databases
 
Database system concepts and architecture
Database system concepts and architectureDatabase system concepts and architecture
Database system concepts and architecture
 
Computer Network
Computer NetworkComputer Network
Computer Network
 
Application Layer
Application Layer Application Layer
Application Layer
 
The CAP Theorem
The CAP Theorem The CAP Theorem
The CAP Theorem
 
Entity relationship modelling
Entity relationship modellingEntity relationship modelling
Entity relationship modelling
 
Simple Mail Transfer Protocol
Simple Mail Transfer ProtocolSimple Mail Transfer Protocol
Simple Mail Transfer Protocol
 
Osi model 7 Layers
Osi model 7 LayersOsi model 7 Layers
Osi model 7 Layers
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
 
Webmail and Mail Clients
Webmail and Mail ClientsWebmail and Mail Clients
Webmail and Mail Clients
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 
Computer Network - Network Layer
Computer Network - Network LayerComputer Network - Network Layer
Computer Network - Network Layer
 
Introduction of DBMS
Introduction of DBMSIntroduction of DBMS
Introduction of DBMS
 
Xml
XmlXml
Xml
 
Database and Database Management (DBM): Health Informatics
Database and Database Management (DBM): Health InformaticsDatabase and Database Management (DBM): Health Informatics
Database and Database Management (DBM): Health Informatics
 
Asynchronous data transfer
Asynchronous data transferAsynchronous data transfer
Asynchronous data transfer
 
Ch1
Ch1Ch1
Ch1
 
Data warehouse design
Data warehouse designData warehouse design
Data warehouse design
 
Ch 4 linker loader
Ch 4 linker loaderCh 4 linker loader
Ch 4 linker loader
 

Viewers also liked

A method for detecting obfuscated calls in malicious binaries
A method for detecting obfuscated calls in malicious binariesA method for detecting obfuscated calls in malicious binaries
A method for detecting obfuscated calls in malicious binariesUltraUploader
 
Subroutine & string in 8086 Microprocessor
Subroutine & string in 8086 MicroprocessorSubroutine & string in 8086 Microprocessor
Subroutine & string in 8086 MicroprocessorMustafa AL-Timemmie
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1deval patel
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 80869840596838
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-pptjemimajerome
 
8086 instructions
8086 instructions8086 instructions
8086 instructionsRavi Anand
 
Assembly language programming(unit 4)
Assembly language programming(unit 4)Assembly language programming(unit 4)
Assembly language programming(unit 4)Ashim Saha
 

Viewers also liked (11)

[ASM]Lab8
[ASM]Lab8[ASM]Lab8
[ASM]Lab8
 
A method for detecting obfuscated calls in malicious binaries
A method for detecting obfuscated calls in malicious binariesA method for detecting obfuscated calls in malicious binaries
A method for detecting obfuscated calls in malicious binaries
 
Subroutine & string in 8086 Microprocessor
Subroutine & string in 8086 MicroprocessorSubroutine & string in 8086 Microprocessor
Subroutine & string in 8086 Microprocessor
 
Mips
MipsMips
Mips
 
Instruction formats-in-8086
Instruction formats-in-8086Instruction formats-in-8086
Instruction formats-in-8086
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1
 
Pipelining In computer
Pipelining In computer Pipelining In computer
Pipelining In computer
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
 
Assembly language programming(unit 4)
Assembly language programming(unit 4)Assembly language programming(unit 4)
Assembly language programming(unit 4)
 

Similar to Assembly Language String Chapter

N_Asm Assembly strings (sol)
N_Asm Assembly strings (sol)N_Asm Assembly strings (sol)
N_Asm Assembly strings (sol)Selomon birhane
 
13 Strings and Text Processing
13 Strings and Text Processing13 Strings and Text Processing
13 Strings and Text ProcessingIntro C# Book
 
Reversing & malware analysis training part 4 assembly programming basics
Reversing & malware analysis training part 4   assembly programming basics Reversing & malware analysis training part 4   assembly programming basics
Reversing & malware analysis training part 4 assembly programming basics Abdulrahman Bassam
 
Strings in c
Strings in cStrings in c
Strings in cvampugani
 
Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsEelco Visser
 
THE IO LIBRARY in C++
THE IO LIBRARY in C++THE IO LIBRARY in C++
THE IO LIBRARY in C++Prof Ansari
 
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
 
Maxbox starter20
Maxbox starter20Maxbox starter20
Maxbox starter20Max Kleiner
 
Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
Space Efficient Suffix Array Construction using Induced Sorting LMS SubstringsSpace Efficient Suffix Array Construction using Induced Sorting LMS Substrings
Space Efficient Suffix Array Construction using Induced Sorting LMS Substringsijistjournal
 
Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
 Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings  Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings ijistjournal
 

Similar to Assembly Language String Chapter (20)

N_Asm Assembly strings (sol)
N_Asm Assembly strings (sol)N_Asm Assembly strings (sol)
N_Asm Assembly strings (sol)
 
Al2ed chapter10
Al2ed chapter10Al2ed chapter10
Al2ed chapter10
 
Matlab strings
Matlab stringsMatlab strings
Matlab strings
 
8086 String Instructions.pdf
8086 String Instructions.pdf8086 String Instructions.pdf
8086 String Instructions.pdf
 
RegexCat
RegexCatRegexCat
RegexCat
 
13 Strings and Text Processing
13 Strings and Text Processing13 Strings and Text Processing
13 Strings and Text Processing
 
Reversing & malware analysis training part 4 assembly programming basics
Reversing & malware analysis training part 4   assembly programming basics Reversing & malware analysis training part 4   assembly programming basics
Reversing & malware analysis training part 4 assembly programming basics
 
Strings in c
Strings in cStrings in c
Strings in c
 
Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type Constraints
 
arrays.pptx
arrays.pptxarrays.pptx
arrays.pptx
 
Strings
StringsStrings
Strings
 
Instruction set
Instruction setInstruction set
Instruction set
 
THE IO LIBRARY in C++
THE IO LIBRARY in C++THE IO LIBRARY in C++
THE IO LIBRARY in C++
 
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
 
vb.net.pdf
vb.net.pdfvb.net.pdf
vb.net.pdf
 
Maxbox starter20
Maxbox starter20Maxbox starter20
Maxbox starter20
 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
 
C語言基本資料型別與變數
C語言基本資料型別與變數C語言基本資料型別與變數
C語言基本資料型別與變數
 
Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
Space Efficient Suffix Array Construction using Induced Sorting LMS SubstringsSpace Efficient Suffix Array Construction using Induced Sorting LMS Substrings
Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
 
Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
 Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings  Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
 

Recently uploaded

(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
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
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 

Recently uploaded (20)

(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
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
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
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
 

Assembly Language String Chapter

  • 2. 2 String Primitive Instructions, Implied Operands. Instruction Description ImpliedOperands MOVS MoveStringData: Copyamemory byte, word, ordoublewordfromone memorylocationtoanother. MOVS [DI],[SI] CMPS CompareString: Compareamemory byte, word, ordoublewordto memory. CMPS [SI],[DI] SCAS ScanString: CompareAL, AX, or EAXtothecontentsofmemory, affectingtheFlagsregister. SCAS [DI],AL SCAS [DI],AX SCAS [DI],EAX STOS StoreStringData: StoreAL, AX, or EAXintomemory. STOS [DI],AL STOS [DI],AX STOS [DI],EAX LODS LoadAccumulatorfromString: Loadabyte, word, ordoubleword intoAL, AX, orEAXfrommemory. LODS AL,[SI] LODS AX,[SI] LODS EAX,[SI]
  • 3. 3 Overview of String Primitive Instructions. General Specific Size Description Increment Value for SI and DI MOVS MOVSB Move (copy) byte 1 MOVSW Move (copy) word 2 MOVSD Move (copy) doubleword* 4 CMPS CMPSB Compare bytes 1 CMPSW Compare words 2 CMPSD Compare doublewords* 4 SCAS SCASB Scan byte 1 SCASW Scan word 2 SCASD Scan doubleword* 4 STOS STOSB Store byte 1 STOSW Store word 2 STOSD Store doubleword* 4 LODS LODSB Load byte 1 LODSW Load word 2 LODSD Load doubleword* 4
  • 5. 5 MOVS (Move String Data). Instruction Valuetobeautomatically added/subtractedfromSIandDI MOVSB 1 MOVSW 2 MOVSD 4
  • 6. 6 Unsigned and Signed Jumps. Condition Unsigned Signed source< dest JB JL source<=dest JBE JLE source≠dest JNE(JNZ) JNE(JNZ) source= dest JE(JZ) JE(JZ) source>=dest JAE JGE source> dest JA JG
  • 7. 7 Scan for a Matching Character. .data alpha db ‘ABCDEFGH’,0 .code mov di,seg alpha mov es,di mov di,offset alpha ; ES:DI points to the string mov al,’F’ ; search for the letter ‘F’ mov cx,8 ; set the search count cld ; direction = up repne scasb ; repeat while not equal jnz exit ; quit if letter is not found dec di ; found: back up DI one character
  • 8. 8 String-Handling Procedures. Procedure Description Str_compare Compare two strings according to their collating sequence. CF = 1 if the first string is lesser, ZF = 1 if both strings are equal, and (CF = 0, ZF = 0) if the first string is greater. Str_copy Copy a source string to a destination string. Str_length Find the length of a string. Str_getline Read a null-terminated string froma file or device. Str_read Read a string froma file or device. Str_ucase Convert a string to uppercase. Str_write Write a string to a file or device.
  • 9. 9 Flag Usage by the Str_compare Procedure. RelationBetween Strings CarryFlag ZeroFlag RelatedJump Instruction first<second 1 0 JB first=second 0 1 JE first>second 0 0 JA
  • 10. 9 Flag Usage by the Str_compare Procedure. RelationBetween Strings CarryFlag ZeroFlag RelatedJump Instruction first<second 1 0 JB first=second 0 1 JE first>second 0 0 JA