IA-32 assembly:
pushl %ebp
movl %esp, %ebp
movl 12(%ebp), %eax
addl 8(%ebp), %eax
movzbl (%eax), %eax # <-
movsbl %al,%eax # <-
popl %ebp
ret
I highlighted which lines are confusing for me. I kind of understand what movzbl and movsbl do separately, but what purpose do they serve by being side by side?
Why not just use movl
. If we wanted to use sign extend, why don't we just use movsbl
from the start, or aren't we losing data when we are extending al
register, which is only only byte (when size of data is more than 1 byte)?
EDIT: i found this Q&A, but I still could not get it: need help understanding the movzbl call in this function
EDIT2: I realized that I'm dealing with characters, so that clears some things up.