Hello all, Quick question about syntax and what exactly this code is doing...
So I understand that the arithmetic shift command multiplies or divides by 2^n, depending on the n. However I am confused on some assembly( i386 architecture for 32 bit )coding. here is a part of the code that I am confused about.
In C it reads....
arr[j+1] = arr[j];
the assembly equivalent is
1 movl 8(%ebp), %edx
2 addl $4, %edx
3 movl -16(%ebp), %eax
4 sall $2, %eax
5 addl %eax, %edx
6 movl -16(%ebp), %eax
7 sall $2, %eax
8 addl 8(%ebp), %eax
9 movl (%eax), %eax
10 movl %eax, (%edx)
my confusion comes from line 4....what exactly does that mean...n is equal to 2 and divides eax by 4?...OR maybe I am confusing the use of sal in this situation and it does something completely different (probably whats happening) but in either case if someone could clear this up for me it would be very much appreciated....Thanks so much
So I understand that the arithmetic shift command multiplies or divides by 2^n, depending on the n. However I am confused on some assembly( i386 architecture for 32 bit )coding. here is a part of the code that I am confused about.
In C it reads....
arr[j+1] = arr[j];
the assembly equivalent is
1 movl 8(%ebp), %edx
2 addl $4, %edx
3 movl -16(%ebp), %eax
4 sall $2, %eax
5 addl %eax, %edx
6 movl -16(%ebp), %eax
7 sall $2, %eax
8 addl 8(%ebp), %eax
9 movl (%eax), %eax
10 movl %eax, (%edx)
my confusion comes from line 4....what exactly does that mean...n is equal to 2 and divides eax by 4?...OR maybe I am confusing the use of sal in this situation and it does something completely different (probably whats happening) but in either case if someone could clear this up for me it would be very much appreciated....Thanks so much