• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 441
  • Last Modified:

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 =)
0
basura
Asked:
basura
  • 3
1 Solution
 
Jase-CoderCommented:
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
0
 
Jase-CoderCommented:
I forgot to mention if you have to get the strings from the stack you can do

push bp
mov bp, sp

mov si, Offset [SS:bp+08]   ; get the right most param
mov di offset  [ss:bp+04]    ;get the left argument
0
 
basuraAuthor Commented:
Haven't tried the code
But forgot to mention that it  should be for NASM for windows/dos
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now