S
S
sddvxd2019-05-22 21:37:47
assembler
sddvxd, 2019-05-22 21:37:47

What can be improved in this feature?

Good afternoon!
There is a function to check strings on nasm. Please tell me if it can be improved somehow

strcmp: ; stdcall
  push ebp
  mov ebp, esp
  push ecx
  push edx
  
  xor ecx, ecx
  mov eax, [ebp + 8]
  mov ebx, [ebp + 12]
.loop:
  mov dh, [eax + ecx]
  mov dl, [ebx + ecx]
  cmp dh, dl
  jne .end_not_equal
  test dh, dh
  jz .end_equal
  inc ecx
  jmp .loop
  
.end:
  pop edx
  pop ecx
  mov esp, ebp
  pop ebp
  ret
  
.end_not_equal:
  mov eax, 0
  jmp .end

.end_equal:
  mov eax, 1
  jmp .end

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2019-05-22
@sddvxd

can it be improved somehow?

Depends on what you consider an improvement.
In terms of code size, it can hardly be improved significantly.
In terms of speed, it is possible if you load data from memory with aligned words and unwind the cycle.
In terms of simplicity, it can be significantly improved by rewriting it in C or even using a ready-made implementation.

F
forspamonly2, 2019-05-23
@forspamonly2

repe cmpsb?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question