Claro que el tamaño de la cadena esta limitado a lo que reservemos en la macro buff_size que en éste caso sera un maximo de 1024 bytes.
NOTA: Si se pasa esta longitud no se producen desbordamientos de pila.
[bits 32]
global _rev_string
section .bss
%define buff_size 1024
buff_src : resb buff_size ; reservar 1024 bytes
buff_dst : resb buff_size
section .text
_rev_string:
push ebp
mov ebp, esp
mov edi, [ebp+8]
xor eax, eax
xor esi, esi
.get_len:
movzx esi, byte[edi]
mov [buff_src+eax], esi
inc edi ; mover el proximo digito
inc eax
cmp esi, ''
jnz .get_len
sub eax, 1 ; contiene la longitud y alinea @EAX
xor edx, edx
.reverse_loop:
movzx esi, byte [eax-0x1+buff_src] ; nos vamos a la posicion final del string - 1
dec eax
mov [buff_dst+edx], esi
inc edx
cmp esi, ''
jnz .reverse_loop
lea eax, [buff_dst]
pop ebp
ret
Importación a C/C++
extern rev_string(char *C);
int main()
{
printf("%s", rev_string("abcdefghijklmnopqrstuvxyz"));
return 0;
}
OUTPUT:
zyxvutsrqponmlkjihgfedcba
Saludos.