Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %include "rw32-2017.inc"
- section .data
- my_string db "ahoj svete a lide!", 0
- replaced_string dd 0, 0, 0, 0, 0
- section .text
- main:
- mov ebp, esp
- mov eax, my_string
- call my_string_len
- call WriteUInt32
- push "e"
- push my_string
- push eax
- push replaced_string
- call my_char_replace
- xor eax, eax
- ret
- my_char_replace:
- push ebp ; stack frame enter
- mov ebp, esp
- push edi
- push ebx
- push edx
- push esi
- push ecx
- ; ebp+20 char to replace
- ; ebp+16 input
- ; ebp+12 len
- ; ebp+8 output
- xor ecx, ecx
- xor edx, edx
- mov edi, [ebp+16] ; input adress
- mov esi, [ebp+8] ; output adress
- mov al, [ebp+20] ; char to replace
- do_while:
- cmp [edi+ecx], al ; compare with replacement char
- je _replace_char
- mov ebx, [edi+ecx]
- mov [esi+ecx], ebx
- jmp _move_char
- _replace_char:
- mov [edi+ecx], byte "_"
- inc edx
- _move_char:
- inc ecx
- cmp ecx, [ebp+12]
- jne do_while ; loop, if we're before end
- mov eax, edx ; store replaced chars
- pop ecx
- pop esi
- pop edx
- pop ebx
- pop edi
- mov esp, ebp ; stack frame leave
- pop ebp
- ret 32
- my_string_len:
- push ebx
- xor ebx, ebx
- while: cmp [eax + ebx], byte 0
- je end
- inc ebx
- jmp while
- end: mov eax, ebx
- pop ebx
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement