ASM function calling error (wrong efective address)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: ASM function calling error (wrong efective address)

Post 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
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: ASM function calling error (wrong efective address)

Post 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 :D
Thanks in advance,

Jules
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: ASM function calling error (wrong efective address)

Post 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
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: ASM function calling error (wrong efective address)

Post by Combuster »

You're still using the host platform's linker (ld), not the cross-linker (i386-elf-ld) #-o
(I bet the same holds for gcc vs i386-elf-gcc)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: ASM function calling error (wrong efective address)

Post by suthers »

](*,) , I am now officially retarded....
I haven't tried it, give me a second, but...
Thanks,

Jules
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: ASM function calling error (wrong efective address)

Post by suthers »

Damn it..., God,why must you thwart me at each stage of my plan to overtake the world with my super OS :lol:
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... :cry: 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 :D
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Re: ASM function calling error (wrong efective address)

Post 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.
Free energy is indeed evil for it absorbs the light.
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: ASM function calling error (wrong efective address)

Post 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
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Re: ASM function calling error (wrong efective address)

Post 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:

Code: Select all

extern void start(void);
And that should work. Good luck.
Free energy is indeed evil for it absorbs the light.
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: ASM function calling error (wrong efective address)

Post by suthers »

Thanks,

but what's with the start, then _start, why do you do that?
Thanks in advance,

Jules
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Re: ASM function calling error (wrong efective address)

Post 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.
Free energy is indeed evil for it absorbs the light.
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: ASM function calling error (wrong efective address)

Post by suthers »

Ok I'll try..
Jules
Post Reply