This looks like self-modifying code.
It loops 7 times and when ecx reaches zero, it replaces the jmp L statement with a different JMP instruction which jumps to the statement after the second JMP.
Foos:
mov ecx,7
mov edx,5
L:
inc edx
sub ecx,1
setZ al ; set al to 1 if zero flag, otherwise al=0
shl al,1 ; multiply by 2, so al=2 when ecx reaches zero
mov byte[L1+1],al
L1:
jmp L
jmp L
mov eax,edx
ret
The magic is in the mov byte[L1+1]. When al=0, it replaces the first JMP with a JMP to the next statement, which is again JMP L, so it loops.
When al=2, it replaces the first JMP to skip 2 bytes, so it skips the second jump, so the loop ends. At the end edx is 12 (5 + 7)
Why is that?
The JMP instructions used here are short jumps. They are coded as 2 bytes: EB followed by a single byte representing the relative number of bytes to jump. The mov instruction replaces the second byte by either 0 (jump to next instruction) or 2 (jump 2 bytes ahead).