Assembly Language 6
Assembly Language 6
Language Programming:
The String Instruction
Reference: Yu . Marut
Chapter 11
CLD
MOV AL, ‘A’
STOSB
STOSB
String1 DB ‘HELLO$’
MOV AX, @DATA
MOV DS, AX
LEA SI, String1
CLD Before LODSB
After LODSB
SI
LODSB String1
SI SI
String1 ‘H’
‘H’ ‘E’
‘E’ ‘L’
‘L’ ‘L’
‘L’ ‘O’
‘O’ AL=‘H’
AL=‘E’
LODSB
Md. Shafiqul Islam
EEE 315: MICROPROCESSOR & INTERFACING
10/9/2024 Lecturer, Dept of EEE, BUET
Scan String
Syntax: SCASB; scan string byte
Can be used to examine a string for a target
byte. The target byte is contained in AL.
SCASB subtracts the string byte pointed to by
ES:DI from the contents of AL and uses the result
to set the flags. DI is incremented if DF=0 or
decremented if DF=1.
Syntax: SCASW; scan string word
The target word is in AX.
All the flags are affected by SCASB and SCASW
String1 DB ‘HELLO$’
MOV AX, @DATA
MOV ES, AX
LEA DI, String1
CLD
MOV AL, ‘E’ Before SCASB
After SCASB
SCASB DI DI DI ZF=0
SCASB String1
String1 ‘H’
‘H’ ‘E’
‘E’ ‘L’
‘L’ ‘L’
‘L’ ‘O’
‘O’ ZF=1