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