Código (ASM) [Seleccionar]
include 'win32ax.inc'
.data
dString db "i'm a string",0
.code
start:
stdcall fRight,dString,9
invoke MessageBox,0,eax,0,0
invoke ExitProcess,0'
;Funcion que emula la funcion Right de Visual Basic 6
proc fRight,pString,pLen
push esi ebx edi ecx
mov eax,[pLen]
inc eax
invoke GlobalAlloc,GPTR, eax
mov esi,eax
mov ebx,eax
stdcall Len,[pString]
sub eax,[pLen]
mov edi,[pString]
add edi,eax
.bucle_:
cmp [pLen] ,0
je .exit
mov cl,byte[edi]
mov byte[ebx],cl
inc ebx
inc edi
dec [pLen]
jmp .bucle_
.exit:
mov eax,esi
pop ecx edi ebx esi
ret
endp
proc Len,cCadena ;Funcion que mide la cadena
push ecx edi
mov ecx,-1
mov edi,[cCadena]
mov al,0
repnz scasb
mov eax,ecx
not eax
dec eax
pop edi ecx
ret
endp
.end start