linux - The assembly code (x86) with jumps and a syscall read function -
i ask understanding assembly code. problem is: code after label l2 important, calls subroutine function. seems me program never code after label l2, because according me syscall read (after l1) reads 0 , after compare 1. 0 never equals one, seems me program never jumps l2. guess must wrong. appreciate help
jmp l1 l2: movzbl -0x11(%ebp), %eax movsbl %al, %eax mov %eax, (%esp) call subroutine_fnc <...> l1: mov $0x0, %ebx lea -0x11(%ebp), %ecx mov $0x1, %edx mov $0x3, %eax int $0x80 mov %eax, -0x10(%ebp) cmpl $0x1, -0x10(%ebp) je l2
the syscall corresponds read , looks trying read 1 byte @ time. read
should return number of actual bytes read, if call successful return value of 1, compare true, , jump l2, i.e.
l2: subroutine_fnc(...); if (read(fd, buff, 1) == 1) // read 1 byte goto l2; // if 1 byte read loop l2
or, in more structured form:
while (read(fd, buff, 1) == 1) { subroutine_fnc(...) }
Comments
Post a Comment