Page 2 of 2
Re: ASM function calling error (wrong efective address)
Posted: Thu Jul 03, 2008 11:55 am
by suthers
Wow thanks man, that's really helpful, but now I get this error:
Code: Select all
/cygdrive/c/toolchain/ld: cannot perform PE operations on non PE output file 'a.
exe'.
I thought that was one of the errors you use a cross binutils/compiler to get around...
Thanks in advance,
Jules
Re: ASM function calling error (wrong efective address)
Posted: Thu Jul 03, 2008 11:59 am
by suthers
Well, if I just use the cross compiler and still use my version of ld, I still get the wrong addresses though...
Thanks for putting me out of my misery by the way...
And have I ever told you how much I appreciate your work as an admin
Thanks in advance,
Jules
Re: ASM function calling error (wrong efective address)
Posted: Thu Jul 03, 2008 12:03 pm
by suthers
Since I pressume you have no problem with calling asm functions, I presume the problems my linker is at fault...
So I'll try to see what I can do with the format to make your linker happy...
Jules
Re: ASM function calling error (wrong efective address)
Posted: Thu Jul 03, 2008 12:09 pm
by Combuster
You're still using the host platform's linker (ld), not the cross-linker (i386-elf-ld)
(I bet the same holds for gcc vs i386-elf-gcc)
Re: ASM function calling error (wrong efective address)
Posted: Thu Jul 03, 2008 12:11 pm
by suthers
, I am now officially retarded....
I haven't tried it, give me a second, but...
Thanks,
Jules
Re: ASM function calling error (wrong efective address)
Posted: Thu Jul 03, 2008 12:55 pm
by suthers
Damn it..., God,why must you thwart me at each stage of my plan to overtake the world with my super OS
I am now using the i386-elf- cross binutils/compiler, but know GCC is demanding cc1, I've put cc1 in the same file as it, but it still says no such file or directory...
I don't know what to do...
damn win32...
Any help?
Thanks in advance,
Jules
P.S. I realise this forum isn't for idiots who can't get their compiler working, but could you make a special exception for me
Re: ASM function calling error (wrong efective address)
Posted: Thu Jul 03, 2008 3:43 pm
by Omega
Sorry if this is wasting your time but it looks like you're trying to do this:
Code: Select all
void switch_page_directory(page_directory_t *dir)
{
current_directory = dir;
asm volatile("mov %0, %%cr3":: "r"(&dir->tablesPhysical));
u32int cr0;
asm volatile("mov %%cr0, %0": "=r"(cr0));
cr0 |= 0x80000000; // Enable paging!
asm volatile("mov %0, %%cr0":: "r"(cr0));
}
Just got mine working last night thanks to JamesM's awesome tutorial, and this is code from that tutorial. Hope it helps.
Re: ASM function calling error (wrong efective address)
Posted: Thu Jul 03, 2008 3:54 pm
by suthers
vst_0201 wrote:Sorry if this is wasting your time but it looks like you're trying to do this:
Code: Select all
void switch_page_directory(page_directory_t *dir)
{
current_directory = dir;
asm volatile("mov %0, %%cr3":: "r"(&dir->tablesPhysical));
u32int cr0;
asm volatile("mov %%cr0, %0": "=r"(cr0));
cr0 |= 0x80000000; // Enable paging!
asm volatile("mov %0, %%cr0":: "r"(cr0));
}
Just got mine working last night thanks to JamesM's awesome tutorial, and this is code from that tutorial. Hope it helps.
yah that was exactly what I was trying to do and I'll implement it this way, but it's still an issue I need to fix...
Jules
Re: ASM function calling error (wrong efective address)
Posted: Thu Jul 03, 2008 4:01 pm
by Omega
I had the same issue you are having and I solved it by assembling as COFF. I use DJGPP so I had to:
Code: Select all
global start, _start
start:
_start:
That makes start callable from C in DJGPP. I don't think you need the underscore for GCC (Linux).
Then in your C file you do:
And that should work. Good luck.
Re: ASM function calling error (wrong efective address)
Posted: Thu Jul 03, 2008 4:12 pm
by suthers
Thanks,
but what's with the start, then _start, why do you do that?
Thanks in advance,
Jules
Re: ASM function calling error (wrong efective address)
Posted: Thu Jul 03, 2008 5:07 pm
by Omega
You may not have to because I don't do that in my HAL.asm but I needed to in my loader because I am using GRUB for stage 1 and 2 and I saw in the GRUB Multiboot specs example code the use of that and without it I could not get my code to work like with my HAL.asm, so once I added that it worked, so maybe for you it will too. So, the short answer is I think it is a linker/djgpp thing. It may not relate to your problem.
Re: ASM function calling error (wrong efective address)
Posted: Thu Jul 03, 2008 5:11 pm
by suthers
Ok I'll try..
Jules