Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .intel_syntax noprefix
  2.  
  3. .text
  4.  
  5. .global amemmove
  6.  
  7. amemmove:
  8.     push    ebp
  9.     mov ebp,esp
  10.     mov edi, BYTE PTR [ebp+8]       # edi = *dest
  11.     mov esi, BYTE PTR [ebp+12]      # esi = *src
  12.     mov ecx, WORD [ebp+16]      # ecx = nbytes
  13.     mov eax, esi
  14.     sub eax, ecx            # eax = src - nbytes
  15.     cmp edi, eax
  16.     jl  rightcpy
  17.     mov edx, [esi] + ecx            # edx = src + btytes
  18.     cmp eax, edx
  19.     jg  rightcpy
  20.     jmp leftcpy
  21.  
  22. leftcpy:
  23.     std
  24.  
  25. rightcpy:
  26. rep movsb
  27.     cld
  28.     mov esp, ebp
  29.     pop ebp
  30.     ret
  31.  
  32. .end
  33.  
  34.  
  35. Gcc Errors:
  36.  
  37. ex1.s: Assembler messages:
  38. ex1.s:8: Error: ambiguous operand size or operands invalid for `push'
  39. ex1.s:10: Error: `edi' not allowed with `movb'
  40. ex1.s:11: Error: `esi' not allowed with `movb'
  41. ex1.s:17: Error: invalid use of register
  42. ex1.s:29: Error: ambiguous operand size or operands invalid for `pop'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement