memcpy

left trim

Mar 29th, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .globl asm_str_ltrim
  2. asm_str_ltrim:
  3.     testq   %rsi, %rsi
  4.     je  sl_out
  5. sl_loop:
  6.     movq    %rsi, %rbx
  7. sl_len:
  8.     incq    %rsi
  9.     cmpb    $0xa, (%rsi)
  10.     je  sl_calc
  11.     cmpb    $0x0, (%rsi)
  12.     je  sl_calc
  13.     jmp sl_len
  14. sl_calc:
  15.     addq    %rdx, %rbx
  16.     cmpq    %rbx, %rsi
  17.     jle sl_inc
  18. sl_copy:
  19.     movb    (%rbx), %al
  20.     movb    %al, (%rdi)
  21.     incq    %rbx
  22.     incq    %rdi
  23.     cmpq    %rbx, %rsi
  24.     jg  sl_copy
  25.     movq    $0xa, (%rdi)
  26.     incq    %rdi
  27. sl_inc:
  28.     incq    %rsi
  29.     cmpb    $0x0, (%rsi)
  30.     jne sl_loop
  31. sl_out:
  32.     movb    $0x0, (%rdi)
  33.     ret
Advertisement
Add Comment
Please, Sign In to add comment