0

Can you tell that this code is a loop?, even without declaring a loop below?

pool:
mov ah, 9
lea dx, shw_smthng
int 21h
jmp pool
stevenjake
  • 23
  • 6
  • Well there's clearly a jump instruction back to `pool`, so yes, it's a loop. Not sure what you mean by "declaring" a loop. – Banex Aug 28 '17 at 16:11
  • Loops are never "declared" anyway – harold Aug 28 '17 at 16:17
  • what I mean of declare is this *loop pool*, xD – stevenjake Aug 28 '17 at 16:49
  • by the way, thanks! – stevenjake Aug 28 '17 at 16:50
  • That's not a "declaration", it's a special instruction (http://felixcloutier.com/x86/LOOP:LOOPcc.html) that's like `dec cx / jnz pool`. Don't fall into the trap of thinking that the `loop` instruction is always the best (or only) way to write loops. It's slow, so you normally shouldn't use it (unless optimizing for code-size instead of speed). https://stackoverflow.com/questions/35742570/why-is-the-loop-instruction-slow-couldnt-intel-have-implemented-it-efficiently – Peter Cordes Aug 28 '17 at 21:01
  • @PeterCordes ah, now I get it, thanks! – stevenjake Aug 29 '17 at 01:38

0 Answers0