I take the operating system development class in which they gave us a microkernel written in C that we build on top. The kernel seems to have been designed with 32-bit machines in mind, and I'm running a snow leopard. So, a friend in the class, and I tried to crack it into 64-bit addressing.
The biggest problem is one line of code in which the built-in assembly is used to copy the current stack pointer to a temporary variable used by the dispatcher:
#define SET_STACK(s) asm("movl temp,%esp");
Naturally, the compiler throws errors at me because %esp is a 32-bit register.
/var/folders/0A/0AVWZC-5HhOg6twWZBlDgU+++TI/-Tmp-//cckS2oq7.s:523:32-bit absolute addressing is not supported for x86-64 /var/folders/0A/0AVWZC-5HhOg6twWZBlDgU+++TI/-Tmp-//cckS2oq7.s:523:cannot do signed 4 byte relocation
So, I replaced it with %rsp because it is a 64-bit stack pointer register (and I think that just %sp works, I read somewhere else here that GAS is smart enough to place the correct prefix). After replacing %esp with %rsp , I get this error:
/var/folders/0A/0AVWZC-5HhOg6twWZBlDgU+++TI/-Tmp-//cc8TLdjH.s:523:Incorrect register `%sp' used with `l' suffix
Now I'm a little confused because I'm not very good at assembler. I tried replacing movl with mov and movq , but nothing works. What makes me think that maybe temp is the wrong size?
Temp is a global variable declared like this:
void* temp;
I wrote a short program for printing the sizes of different types of data, and it seems that void * in x86-64 is 8 bytes in size, which should be the right size, right?
In any case, obviously, I do not expect anyone to solve this problem for me, but any advice that can point me in the right direction will be very grateful!