hello,all ;======== mov edx, 41 mov eax,41 mov ebx,16 div ebx ; Integer overflow exception. ;===== what's wrong? regards
hey,AsmGuru62 Thanks you for help. ;========== ;41/16=? mov edx, 41 xor eax,eax mov ebx,16 div ebx ;========== is it right? regards
hey,yureckor Thanks you for help. ;========== ;Local buffer1[128]:byte ;Local buffer2[128]:byte mov esi, offset buffer1 mov edi, offset buffer2 invoke lstrlen, esi shr eax,2 mov ecx,eax .while ecx lodsd stosd dec ecx add esi,4 add edi,4 .endw ;========== is it right? regards
Код (Text): ;Local buffer1[128]:byte ;Local buffer2[128]:byte invoke lstrlen, addr buffer1 lea esi, buffer1 lea edi, buffer2 mov edx, eax mov ecx, eax shr ecx,2 rep movsd mov ecx, edx and ecx, 3 rep movsb Or use lstrcpy Код (Text): ;Local buffer1[128]:byte ;Local buffer2[128]:byte invoke lstrcpy, addr buffer2, addr buffer1
dcskm4200 Your code is correct, but he slow, since 1) call Windows API, 2) The line can be copied during calculation of its length. Код (Text): ;return eax=lenght copy_str proc src:DWORD, dst:DWORD push esi push edi mov esi, [src] mov edi, [dst] xor eax, eax @@1: mov al, [esi] mov [edi], al inc esi inc edi test eax, eax jnz @@1 mov eax, esi sub eax, [src] pop edi pop esi ret copy_str endp Faster: Код (Text): ;return eax=lenght copy_str_fast proc src:DWORD, dst:DWORD push esi push edi mov esi, [src] mov edi, [dst] @@1: mov eax, [esi] mov [edi], eax test eax, 0000000FFh jz @@a1 test eax, 00000FF00h jz @@a2 test eax, 000FF0000h jz @@a3 test eax, 0FF000000h jz @@a4 add esi, 4 add edi, 4 jmp @@1 @@a4: inc esi @@a3: inc esi @@a2: inc esi @@a1: mov eax, esi sub eax, [src] pop edi pop esi ret copy_str_fast endp You also can change function strlen.asm from MASM32\m32lib, but she works only with 7 bit letters that does not approach for Russian.
hey,yureckor Thanks you for gave me more information. we often need to encrypt or decrypt a buffer with a byte or word or dword. since you guided me, now I can manipulate it with a byte and dword. but i can't do it with a word. regards