|
421
|
Programación / ASM / Re: Pequeño codigo para comparar strings...
|
en: 15 Junio 2009, 01:37 am
|
bueno, hay tienen el code, al que no le guste algo de el code , que lo cambie. Lo de usar unos registros en puesto de otros es cuestión de gustos, yo si tengo registros sin usar no usare la pila, y siempre suelo dejar para los últimos edi y esi. lo de ah y al da lo mismo porque un caracter nunca superara el tamaño de 1 byte al menos con ascii. Saludos No te pongas sensible . No es por usar los registro seguramente que lo dijo seguro se refiere a usar cmpsb.
|
|
|
422
|
Programación / ASM / Re: Pequeño codigo para comparar strings...
|
en: 15 Junio 2009, 00:46 am
|
si usara esi y edi tendría que añadir 2 push y 2 pop para conservar los registros. De todas maneras, si quieres puedes quitar un test si le pones ax.
Saludos
PD:Con or 0x20 lo pasarías a minúsculas
Con Pushad no talves unos pop mas pero ahorrarias unops push tambien
|
|
|
426
|
Programación / ASM / Re: Recopilación de mis codigos.
|
en: 13 Junio 2009, 04:26 am
|
include 'win32ax.inc' .data buffer rb 41 var0 db "12345",0 .code start: invoke lstrlen,var0 stdcall SHA1Hash ,var0 ,eax,buffer invoke MessageBox,0,buffer,buffer,0 leave ret ;Descripción: Saca el hash sha1 de un dato ; by YST proc SHA1Hash ,pbData,dwDataLen,cBuffer locals hProv dd ? PROV_RSA_FULL = 1 CALG_SHA = 0x00008004 hHash dd ? cBuf rb 40 dwSigLen dd ? endl pushad invoke CryptAcquireContext,addr hProv,0,0,PROV_RSA_FULL,0 .if [hProv] = 0 invoke CryptAcquireContext,addr hProv,0,0,PROV_RSA_FULL,8h .endif invoke CryptCreateHash,[hProv],CALG_SHA, 0, 0, addr hHash invoke CryptHashData,[hHash], [pbData],[dwDataLen] , 0 invoke CryptGetHashParam,[hHash], 2, 0,addr dwSigLen, 0 .if [dwSigLen] <> 0 invoke CryptGetHashParam,[hHash], 2, addr cBuf,addr dwSigLen, 0 .endif invoke CryptDestroyHash,[hHash] invoke CryptReleaseContext,[hProv], 0 stdcall StringToHex,addr cBuf,20,[cBuffer] popad ret endp ;Descripción: Convierte un dato a hexadecimal ; by YST proc StringToHex,cPuntero,cCantidad,cBuffer pushad mov esi,[cPuntero] mov edi,[cBuffer] .bucle: cmp [cCantidad],0 je .salir xor edx,edx movzx eax,byte[esi] mov ebx,16 div ebx mov bl, byte[numeros+eax] mov byte[edi],bl mov bl, byte[numeros+edx] mov byte[edi+1],bl add edi,2 inc esi dec [cCantidad] jmp .bucle .salir: popad ret numeros db '0123456789ABCDEF',0 endp .end start
|
|
|
427
|
Programación / ASM / Re: Pequeño codigo para comparar strings...
|
en: 13 Junio 2009, 02:22 am
|
otra opción: proc comparar ,SRC,DST ;Funcion que compara push edi ecx esi mov ecx,-1 mov edi,[SRC] mov al,0 repnz scasb mov eax,ecx not eax mov ecx,eax mov esi,[SRC] mov edi,[DST] repz cmpsb mov eax,1 jnz Next dec eax Next: pop esi ecx edi ret endp
|
|
|
429
|
Programación / ASM / Re: Recopilación de mis codigos.
|
en: 12 Junio 2009, 23:58 pm
|
proc HexToString,cPuntero,cCantidad,cBuffer pushad mov edi,[cPuntero] mov esi,[cBuffer] .bucle: cmp [cCantidad] ,0 je .salir movzx eax,byte[edi] xor edx,edx mov ebx,16 div ebx mov ecx,edx .if byte[edi] >= 'A' add ecx,9 .endif xor edx,edx mov eax,16 mul ecx mov ecx,eax movzx eax,byte[edi+1] xor edx,edx mov ebx,16 div ebx .if byte[edi+1] >= 'A' add edx,9 .endif add ecx,edx mov byte[esi],cl inc esi add edi,2 dec [cCantidad] jmp .bucle .salir : popad ret endp
|
|
|
430
|
Programación / ASM / Re: Recopilación de mis codigos.
|
en: 12 Junio 2009, 22:08 pm
|
;Descripción: Convierte un dato a hexadecimal ; by YST proc StringToHex,cPuntero,cCantidad,cBuffer pushad mov esi,[cPuntero] mov edi,[cBuffer] .bucle: cmp [cCantidad],0 je .salir xor edx,edx movzx eax,byte[esi] mov ebx,16 div ebx mov bl, byte[numeros+eax] mov byte[edi],bl mov bl, byte[numeros+edx] mov byte[edi+1],bl add edi,2 inc esi dec [cCantidad] jmp .bucle .salir: popad ret numeros db '0123456789ABCDEF',0 endp
|
|
|
|
|
|
|