Hello,

I'm trying to code a SWAP_STRING procedure for an array of BYTEs

does this seem correct?

assuming below - i wanna swap the positions (parallel) of each array

how do i return the swapped values?

for example, if 1 and 2 gets swapped in Var1
then 1 and 2 from var2 gets swapped as well.


.data

var1 BYTE 1,2,3
var2 BYTE 1,2,3


.code

Swap_String PROC

push ebp
mov ebp, esp
mov al,
mov bl,
mov , al
mov , bl
pop
ret

Swap_String PROC
Posted on 2010-08-06 16:18:16 by l flipboi l
I can't really help you as far as MASM syntax goes, but you need to use pointers and you need to create a loop.

Swap_String:
  enter 0, 0
  push esi
  push edi

    mov edi,
    mov esi,
    mov ecx,
f01:
    mov al,
    mov ah,
    mov , ah
    mov , al
    inc edi
    inc esi
    dec ecx
    jnz f01

  pop edi
  pop esi
  leave
  ret


This takes the OFFSET of each var and the length of how many bytes to swap as arguments.
Posted on 2010-08-07 00:22:36 by Synfire
Thanks!
Posted on 2010-08-08 17:11:24 by l flipboi l