Advertisement
Guest User

Untitled

a guest
Mar 16th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. // YOUR CODE STARTS HERE
  2. push ebp
  3. mov ebp, esp
  4.  
  5. push ebx
  6. push ecx
  7.  
  8. mov esi, image //ESI = base address of image
  9. mov ebx, 0 //EBX = row index counter
  10. mov ecx, 0 //ECX = column index counter
  11.  
  12.  
  13. OuterLoop: //loop through all row indexes
  14. cmp ebx, dim
  15. jae EndOuterLoop
  16. jmp InnerLoop
  17.  
  18. InnerLoop: //loop through all column indexes
  19. cmp ecx, dim
  20. jae EndInnerLoop
  21.  
  22. //calculate offset
  23. mov eax, dim
  24. mul ebx
  25. add eax, ecx
  26.  
  27. mov dl, byte ptr[esi + eax]
  28.  
  29. cmp dl, threshold
  30. jae OverThreshold
  31.  
  32. mov byte ptr[esi + eax], 0x00
  33. xor eax, eax
  34. inc ecx
  35. jmp InnerLoop
  36.  
  37. OverThreshold:
  38. mov byte ptr[esi + eax], 0xFF
  39. xor eax, eax
  40. inc ecx
  41. jmp InnerLoop
  42.  
  43. EndInnerLoop:
  44. xor ecx, ecx
  45. inc ebx
  46. jmp OuterLoop
  47.  
  48. EndOuterLoop:
  49. pop ecx
  50. pop ebx
  51.  
  52.  
  53. mov esp, ebp
  54. pop ebp
  55. ret
  56. // YOUR CODE ENDS HERE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement