I am currently reading 'Linux Kernel Development' by Robert Love and I do not understand what this bit of assembly is doing.
Basically, in each process kernel stack, there is a struct thread_info which resides at the end of the stack. Now, on the x86 architecture, we can apparently grab this (assuming 8KB stack size) by using the following assembly
movl $-8192, %eax
andl %esp, %eax
So basically ANDing the stack pointer by 0xffffe000. I'm confused as to what is going on here? I don't see why masking the least significant 13 bits of %esp takes us to the struct. I know I'll feel stupid once it is explained, but it is bugging me.
Thanks.
-8192is0xffffe000? How negative numbers are stored in CPU's registers? - patryk.beza