Another version :
.386
.model flat,stdcall
option casemap:none
ExitProcess PROTO :DWORD
includelib \PellesC\lib\Win\kernel32.lib
.data
str1 dw 'This is a test.',0
.code
start:
push OFFSET str1
call UniStrLen
invoke ExitProcess,0
align 16
UniStrLen:
mov eax,DWORD PTR [esp+4]
mov ecx,4
sub eax,ecx
@@:
add eax,ecx
mov edx,DWORD PTR [eax]
test dx,dx
je @f
test edx,0FFFF0000h
jnz @b
add eax,2
@@:
sub eax,DWORD PTR [esp+4]
shr eax,1
ret 4
END start