Link to home
Start Free TrialLog in
Avatar of basura
basura

asked on

Assembly Comparing Strings

I need some help comparing strings, i need to do some functions with this strings

the first one is union of two strings

for example {1,2,3,4} union {5,6,4} = {1,2,3,4,5,6}

so i was looking for a way to compare each number to see if its located in the other string
and therefore be able to create the last string.

the strings are stored in a stack and the first two are the ones that need to be compared in other to do the union function

thanks for your help =)
Avatar of Jase-Coder
Jase-Coder

use cmpsb

since the operands are ds:si and es:di, make sure the data seg and the extra segment point to the same thing for example

mov ax, @data
mov ds, ax
mov es, ax


mov si, OFFSET string1      ;ds:si
mov di, OFFSET string2     ;es:di

mov cx, strlen

repe  cmpsb

jb Less
ja Greater
je Equal


Less:
   ;do something
   jmp END

Greate:
   ;....
   jmp ENd
ASKER CERTIFIED SOLUTION
Avatar of Jase-Coder
Jase-Coder

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of basura

ASKER

Haven't tried the code
But forgot to mention that it  should be for NASM for windows/dos