Advertisement
Guest User

Untitled

a guest
Jul 12th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MPASM 1.35 KB | None | 0 0
  1. String_Add proc stri:STRING, chars:LPSTR
  2.     push ebx
  3.     push ecx
  4.     push edx
  5.     mov ecx, stri
  6.     invoke GetCharLength, chars
  7.     ASSUME ecx:PTR STRINGS
  8.         mov edx, [ecx].len
  9.         add edx, eax
  10.         mov ebx, [ecx].max
  11.         push edx
  12.         cmp ebx, edx
  13.         jg String_Add_Update
  14.         String_Add_continue:
  15.             xor edx, edx
  16.             mov eax, ebx
  17.             mul ebx
  18.             mov ebx, eax
  19.             mov edx, [ecx].chars
  20.             ASSUME ecx:NOTHING
  21.             push ecx
  22.             invoke GetProcessHeap
  23.             invoke HeapReAlloc, eax, HEAP_ZERO_MEMORY, edx, ebx
  24.             pop ecx
  25.             invoke PrintNumber, eax
  26.             ASSUME ecx:PTR STRINGS
  27.             cmp eax, NULL
  28.             je String_Add_fail
  29.             invoke PrintChars, eax
  30.             mov [ecx].chars, eax
  31.             mov [ecx].max, ebx
  32.             pop edx
  33.             cmp ebx, edx
  34.             push edx
  35.             jle String_Add_continue
  36.         String_Add_Update:
  37.             pop edx
  38.             mov [ecx].len, edx
  39.             mov edx, [ecx].chars
  40.     ASSUME ecx:NOTHING
  41.     invoke PrintChars, edx
  42.     xor ebx, ebx
  43.     mov ecx, chars
  44.     cmp [edx], bl
  45.     je String_Add_Loop_Begin
  46.     String_Add_MovePtr:
  47.         inc edx
  48.         cmp [edx], bl
  49.         jne String_Add_MovePtr
  50.     String_Add_Loop_Begin:
  51.         cmp [ecx], bl
  52.         je String_Add_Sucess
  53.     String_Add_Loop:
  54.         mov al, [ecx]
  55.         mov [edx], al
  56.         inc ecx
  57.         inc edx
  58.         cmp [ecx], bl
  59.         jne String_Add_Loop
  60.     String_Add_Sucess:
  61.         mov eax, ecx
  62.         sub eax, chars
  63.         jmp String_Add_done
  64.     String_Add_fail:
  65.         xor eax, eax
  66.     String_Add_done:
  67.     pop edx
  68.     pop ecx
  69.     pop ebx
  70.     ret
  71. String_Add endp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement