SlideShare a Scribd company logo
1 of 24
Download to read offline
STRING HANDLING INSTRUCTIONS
●
8086 has special instructions to handle strings
●
By string we mean an array of bytes/words
●
Need pointers to point to each byte/each word in the array
●
SI is the default pointer to the source string
●
DI is the default pointer to the destination string
●
The processor assumes that source string is in DS
●
The processor assumes that destination string is in ES
STRING INSTRUCTIONS
●
The processor needs to increment or decrement the pointer to operate the
consecutive bytes/words in a string
●
String instructions automatically update (increment/decrement) the pointers
●
DF (Direction Flag) decides whether the pointers are incremented or
decremented by a string instruction
●
The programmer should set/clear the DF using instructions:
●
CLD – Clear Direction Flag (DF =0), the string instruction will automatically
increment the pointer(s)
●
STD – Set Direction Flag (DF =1), the string instruction will automatically
decrement the pointer(s)
MOVSB/MOVSW
●
MOVSB/MOVSW (move string byte/move string word)
●
Transfers a byte/word from a memory location pointed DS:SI pair to the
memory location pointed by ES:DI pair.
●
MOVSB/MOVSW also automatically updates SI and DI to point to the next
element in the source and destination string.
REP Prefix
●
The instruction to which the REP prefix is attached, is executed repeatedly.
●
REP assumes that CX holds the the number of times the instruction should be
repeated
●
Each time an instruction with REP prefix is executed, the basic string
operation is performed, pointers are updated, and then , CX is decremented
by 1, if CX is not zero then the operation is repeated.
●
The repeat count must be loaded into CX prior to executing a string
instruction with REP prefix
●
REP prefix is used with MOVSB/MOVSW to repeat the data transfer in order
to completely transfer the string from one location to another
Using MOVSB instruction to move a string
Alternative:
LODSB/LODSW
●
Load string byte /load string word
●
LODSB loads the content of memory location pointed by the DS:SI in to
AL, and updates SI (depending on DF). If DF = 0, SI is incremented by 1. If
DF = 1, SI is decremented by 1
●
LODSW loads the content of memory locations pointed by the DS:SI and
DS:(SI+1) in to AX, and updates SI (depending on DF). If DF = 0, SI is
incremented by 2. If DF = 1, SI is decremented by 2
●
LODSB/LODSW is never used with REP prefix
STOSB/STOSW
●
Store string byte /store string word
●
STOSB stores the byte in AL into the memory location pointed by ES: DI
and updates DI (depending on DF ). If DF = 0, DI is incremented by 1. If DF
= 1, DI is decremented by 1
●
STOSW stores the word in AX to the memory locations pointed by ES: DI
and ES:(DI+1) and updates DI (depending on DF ). If DF = 0, DI is
incremented by 2. If DF = 1, DI is decremented by 2
●
REP prefix can be used with STOSB/STOSW
.DATA
MEM_BLOCK DB 100 DUP(?)
Msg DB 'bad memory', '$'
.CODE
; - - -
MOV AX, @DATA
MOV DS, AX
MOV ES, AX
CLD
MOV CX, 50
MOV DI, OFFSET MEM_BLOCK
MOV AX, 0AAAAH
REP STOSW
MOV SI, OFFSET MEM_BLOCK
MOV CX, 100
AGAIN: LODSB
XOR AL, AH
JNZ OVER
LOOP AGAIN
JMP EXIT
OVER: MOV AH,09H
MOV DX, OFFSET Msg
INT 21H
EXIT: MOV AH,4CH
INT 21H
; - - -
Store byte AAH into 100 memory locations, test the content of each location to see if AAH is there.
If test fails display the msg “bad memory”
CMPSB/CMPSW
●
Compare string byte / compare string word
●
CMPS allows comparison of two arrays pointed by SI and DI
●
CMPS subtracts the source byte/word from dest. byte/word
●
Affects the flags, but does not alter either operand
●
Automatically updates SI and DI (depending on DF)
●
We can test for the equality/ inequality of the string by the use of REPE or
REPNE prefixes
REPE and REPNE Prefixes
●
Used with CMPS and SCAS instructions
●
REPE will repeat the string operation as long as the source
and destination operands are equal (ZF = 1) or until CX
becomes zero
●
REPNE will repeat the string operation as long as the
source and destination operands are not equal (ZF = 0 ) or
until CX becomes zero
Compare strings
Compare strings and display messages depending on the result
SCASB/SCASW
●
Scan String byte/Scan String Word
●
SCASB/SCASW allows us to scan a string for a particular byte/word
●
SCASB/SCASW instruction compares each byte/word of an array
pointed by ES:DI with the content of AL/AX and also updates DI
●
SCASB does (AL - ES:DI ), update the flags, update DI
●
SCASW does (AX- [ES:DI+1,ES:DI]), update the flags, update DI
●
SCASB/SCASW can be prefixed with REPE/REPNE
Scan a string for a specific letter
Scan a string for a specific letter and replace it with another letter
Signed Number representation in computers
D7 = 0, operand is positive
D7 = 1, operand is negative
The range of positive numbers that can
be represented by the above format is 0
to +127
Signed byte operands
For negative numbers, D7 =1, and the magnitude is represented in 2's
complement form
Example: representaion of
-5 = FBH
-34H = CCH
-128 = 80H (This is not negative zero)
Signed byte operands
The range of byte-sized negative numbers is -1 to -128
Word-sized signed numbers
The range of word-sized signed
numbers is -32768 to +32767
Overflow problem in signed number operations
Overflow problem in signed number operations
In 8-bit signed number operations, OF is set to 1 if either of the following
conditions occurs:
1) there is a carry from D6 to D7 but no carry out of D7 (CF = 0)
2) there is a carry from D7 out (CF =1) but no carry from D6 to D7
This means if there is a carry both from D6 to D7 and from D7 out, OF = 0
Overflow problem in signed number operations
Overflow problem in signed number operations
Overflow problem in signed number operations
In 16-bit signed number operations, OF is set to 1 if either of the following
conditions occurs:
1) there is a carry from D14 to D15 but no carry out of D15 (CF = 0)
2) there is a carry from D15 out (CF =1) but no carry from D14 to D15
This means if there is a carry both from D14 to D15 and from D15 out, OF = 0

More Related Content

Similar to String_manipulations.pdf

Microprocessor.pptx
Microprocessor.pptxMicroprocessor.pptx
Microprocessor.pptxNishatNishu5
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086Akhila Rahul
 
N_Asm Assembly strings (sol)
N_Asm Assembly strings (sol)N_Asm Assembly strings (sol)
N_Asm Assembly strings (sol)Selomon birhane
 
15CS44 MP &MC Module 3
15CS44 MP &MC Module 315CS44 MP &MC Module 3
15CS44 MP &MC Module 3RLJIT
 
unit1.pdf
unit1.pdfunit1.pdf
unit1.pdfSaruM1
 
Byte and string manipulation 8086
Byte and string manipulation 8086Byte and string manipulation 8086
Byte and string manipulation 8086mpsrekha83
 
Instructionsetof8086 by Alwani
Instructionsetof8086 by AlwaniInstructionsetof8086 by Alwani
Instructionsetof8086 by AlwaniHimanshu Alwani
 
Chap 3_2.ppt
Chap 3_2.pptChap 3_2.ppt
Chap 3_2.pptinian2
 
Arm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.pptArm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.pptManju Badiger
 
Topic 6 - Programming in Assembly Language_230517_115118.pdf
Topic 6 - Programming in Assembly Language_230517_115118.pdfTopic 6 - Programming in Assembly Language_230517_115118.pdf
Topic 6 - Programming in Assembly Language_230517_115118.pdfezaldeen2013
 
Assembly Language Lecture 4
Assembly Language Lecture 4Assembly Language Lecture 4
Assembly Language Lecture 4Motaz Saad
 
Instruction set-of-8086
Instruction set-of-8086Instruction set-of-8086
Instruction set-of-8086mudulin
 

Similar to String_manipulations.pdf (20)

Chapt 06
Chapt 06Chapt 06
Chapt 06
 
Chapt 06
Chapt 06Chapt 06
Chapt 06
 
8086 String Instructions.pdf
8086 String Instructions.pdf8086 String Instructions.pdf
8086 String Instructions.pdf
 
Microprocessor.pptx
Microprocessor.pptxMicroprocessor.pptx
Microprocessor.pptx
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
N_Asm Assembly strings (sol)
N_Asm Assembly strings (sol)N_Asm Assembly strings (sol)
N_Asm Assembly strings (sol)
 
15CS44 MP &MC Module 3
15CS44 MP &MC Module 315CS44 MP &MC Module 3
15CS44 MP &MC Module 3
 
unit1.pdf
unit1.pdfunit1.pdf
unit1.pdf
 
Byte and string manipulation 8086
Byte and string manipulation 8086Byte and string manipulation 8086
Byte and string manipulation 8086
 
Chap03[1]
Chap03[1]Chap03[1]
Chap03[1]
 
Instructionsetof8086 by Alwani
Instructionsetof8086 by AlwaniInstructionsetof8086 by Alwani
Instructionsetof8086 by Alwani
 
Chap 3_2.ppt
Chap 3_2.pptChap 3_2.ppt
Chap 3_2.ppt
 
Lecture5
Lecture5Lecture5
Lecture5
 
Lecture5(1)
Lecture5(1)Lecture5(1)
Lecture5(1)
 
Arm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.pptArm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.ppt
 
Topic 6 - Programming in Assembly Language_230517_115118.pdf
Topic 6 - Programming in Assembly Language_230517_115118.pdfTopic 6 - Programming in Assembly Language_230517_115118.pdf
Topic 6 - Programming in Assembly Language_230517_115118.pdf
 
X86 operation types
X86 operation typesX86 operation types
X86 operation types
 
Assembly Language Lecture 4
Assembly Language Lecture 4Assembly Language Lecture 4
Assembly Language Lecture 4
 
Instruction set-of-8086
Instruction set-of-8086Instruction set-of-8086
Instruction set-of-8086
 
Al2ed chapter4
Al2ed chapter4Al2ed chapter4
Al2ed chapter4
 

Recently uploaded

Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniquesugginaramesh
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxPurva Nikam
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
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
 
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
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
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
 
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
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
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
 
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
 

Recently uploaded (20)

Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniques
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptx
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
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
 
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
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
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
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
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
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
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)
 
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
 

String_manipulations.pdf

  • 1. STRING HANDLING INSTRUCTIONS ● 8086 has special instructions to handle strings ● By string we mean an array of bytes/words ● Need pointers to point to each byte/each word in the array ● SI is the default pointer to the source string ● DI is the default pointer to the destination string ● The processor assumes that source string is in DS ● The processor assumes that destination string is in ES
  • 2. STRING INSTRUCTIONS ● The processor needs to increment or decrement the pointer to operate the consecutive bytes/words in a string ● String instructions automatically update (increment/decrement) the pointers ● DF (Direction Flag) decides whether the pointers are incremented or decremented by a string instruction ● The programmer should set/clear the DF using instructions: ● CLD – Clear Direction Flag (DF =0), the string instruction will automatically increment the pointer(s) ● STD – Set Direction Flag (DF =1), the string instruction will automatically decrement the pointer(s)
  • 3. MOVSB/MOVSW ● MOVSB/MOVSW (move string byte/move string word) ● Transfers a byte/word from a memory location pointed DS:SI pair to the memory location pointed by ES:DI pair. ● MOVSB/MOVSW also automatically updates SI and DI to point to the next element in the source and destination string.
  • 4. REP Prefix ● The instruction to which the REP prefix is attached, is executed repeatedly. ● REP assumes that CX holds the the number of times the instruction should be repeated ● Each time an instruction with REP prefix is executed, the basic string operation is performed, pointers are updated, and then , CX is decremented by 1, if CX is not zero then the operation is repeated. ● The repeat count must be loaded into CX prior to executing a string instruction with REP prefix ● REP prefix is used with MOVSB/MOVSW to repeat the data transfer in order to completely transfer the string from one location to another
  • 5. Using MOVSB instruction to move a string Alternative:
  • 6. LODSB/LODSW ● Load string byte /load string word ● LODSB loads the content of memory location pointed by the DS:SI in to AL, and updates SI (depending on DF). If DF = 0, SI is incremented by 1. If DF = 1, SI is decremented by 1 ● LODSW loads the content of memory locations pointed by the DS:SI and DS:(SI+1) in to AX, and updates SI (depending on DF). If DF = 0, SI is incremented by 2. If DF = 1, SI is decremented by 2 ● LODSB/LODSW is never used with REP prefix
  • 7. STOSB/STOSW ● Store string byte /store string word ● STOSB stores the byte in AL into the memory location pointed by ES: DI and updates DI (depending on DF ). If DF = 0, DI is incremented by 1. If DF = 1, DI is decremented by 1 ● STOSW stores the word in AX to the memory locations pointed by ES: DI and ES:(DI+1) and updates DI (depending on DF ). If DF = 0, DI is incremented by 2. If DF = 1, DI is decremented by 2 ● REP prefix can be used with STOSB/STOSW
  • 8. .DATA MEM_BLOCK DB 100 DUP(?) Msg DB 'bad memory', '$' .CODE ; - - - MOV AX, @DATA MOV DS, AX MOV ES, AX CLD MOV CX, 50 MOV DI, OFFSET MEM_BLOCK MOV AX, 0AAAAH REP STOSW MOV SI, OFFSET MEM_BLOCK MOV CX, 100 AGAIN: LODSB XOR AL, AH JNZ OVER LOOP AGAIN JMP EXIT OVER: MOV AH,09H MOV DX, OFFSET Msg INT 21H EXIT: MOV AH,4CH INT 21H ; - - - Store byte AAH into 100 memory locations, test the content of each location to see if AAH is there. If test fails display the msg “bad memory”
  • 9. CMPSB/CMPSW ● Compare string byte / compare string word ● CMPS allows comparison of two arrays pointed by SI and DI ● CMPS subtracts the source byte/word from dest. byte/word ● Affects the flags, but does not alter either operand ● Automatically updates SI and DI (depending on DF) ● We can test for the equality/ inequality of the string by the use of REPE or REPNE prefixes
  • 10. REPE and REPNE Prefixes ● Used with CMPS and SCAS instructions ● REPE will repeat the string operation as long as the source and destination operands are equal (ZF = 1) or until CX becomes zero ● REPNE will repeat the string operation as long as the source and destination operands are not equal (ZF = 0 ) or until CX becomes zero
  • 12. Compare strings and display messages depending on the result
  • 13. SCASB/SCASW ● Scan String byte/Scan String Word ● SCASB/SCASW allows us to scan a string for a particular byte/word ● SCASB/SCASW instruction compares each byte/word of an array pointed by ES:DI with the content of AL/AX and also updates DI ● SCASB does (AL - ES:DI ), update the flags, update DI ● SCASW does (AX- [ES:DI+1,ES:DI]), update the flags, update DI ● SCASB/SCASW can be prefixed with REPE/REPNE
  • 14. Scan a string for a specific letter
  • 15. Scan a string for a specific letter and replace it with another letter
  • 16. Signed Number representation in computers D7 = 0, operand is positive D7 = 1, operand is negative The range of positive numbers that can be represented by the above format is 0 to +127
  • 17. Signed byte operands For negative numbers, D7 =1, and the magnitude is represented in 2's complement form Example: representaion of -5 = FBH -34H = CCH -128 = 80H (This is not negative zero)
  • 18. Signed byte operands The range of byte-sized negative numbers is -1 to -128
  • 19. Word-sized signed numbers The range of word-sized signed numbers is -32768 to +32767
  • 20. Overflow problem in signed number operations
  • 21. Overflow problem in signed number operations In 8-bit signed number operations, OF is set to 1 if either of the following conditions occurs: 1) there is a carry from D6 to D7 but no carry out of D7 (CF = 0) 2) there is a carry from D7 out (CF =1) but no carry from D6 to D7 This means if there is a carry both from D6 to D7 and from D7 out, OF = 0
  • 22. Overflow problem in signed number operations
  • 23. Overflow problem in signed number operations
  • 24. Overflow problem in signed number operations In 16-bit signed number operations, OF is set to 1 if either of the following conditions occurs: 1) there is a carry from D14 to D15 but no carry out of D15 (CF = 0) 2) there is a carry from D15 out (CF =1) but no carry from D14 to D15 This means if there is a carry both from D14 to D15 and from D15 out, OF = 0