Monday, March 8, 2021

Loops

  • Unconditional jump
  • Can only be performed within -128 to +127 of current location
  • Execute instruction decrement ECX by 1 check ECX (if 0, stop loop else continue loop)
  • ECX must be initialized to any positive value first
  • If ECX was initialized to 0, it will loop 4,294,967,295 times (initial value is 0 then 1 will be subtracted which will result to FFFFFFFF)
  • Example:

; This adds 1 to eax 5 times 
mov eax,0
mov ecx,5
L1:
  add eax,1
  loop L1

; eax = 5

No comments:

Post a Comment