LINEAR_ADRESS causes error in nasm
LINEAR_ADRESS causes error in nasm
Hello!
I am sorry, if I ask an obvious question here, but I tried searching the forum with no result.
I had some trouble getting Interrupts to work, so I looked into the wiki-section about getting this to work.
When I try to bring the asm-example from http://wiki.osdev.org/I_Cant_Get_Interrupts_Working to compile with nasm, I get an error about the LINEAR_ADRESS thing: "error: comma expected after operand 1".
It refers to this line: "dd LINEAR_ADDRESS(idt)"
Why a comma after this operand and where? And what after it?
Can anybody help me and explain to me, what is wrong there?
Thanks!
I am sorry, if I ask an obvious question here, but I tried searching the forum with no result.
I had some trouble getting Interrupts to work, so I looked into the wiki-section about getting this to work.
When I try to bring the asm-example from http://wiki.osdev.org/I_Cant_Get_Interrupts_Working to compile with nasm, I get an error about the LINEAR_ADRESS thing: "error: comma expected after operand 1".
It refers to this line: "dd LINEAR_ADDRESS(idt)"
Why a comma after this operand and where? And what after it?
Can anybody help me and explain to me, what is wrong there?
Thanks!
Who is General Error - and why is he reading my harddisk?
- Combuster
- 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: LINEAR_ADRESS causes error in nasm
The idea is that you fill that macro in for yourself 
Re: LINEAR_ADRESS causes error in nasm
Aaah!
Okay
Then another question comes to my mind: How?
I'am sorry - I'm quite new to this and now I am confused, how to get a linear address?
Okay
Then another question comes to my mind: How?
I'am sorry - I'm quite new to this and now I am confused, how to get a linear address?
Who is General Error - and why is he reading my harddisk?
Re: LINEAR_ADRESS causes error in nasm
It depends on how your kernel is linked. If it's supposed to run at 0xC0100000 and the bootloader loads it at 0x00100000, then the macro just has to subtract 0xC0000000 from a pointer to get its physical (linear) address.
Re: LINEAR_ADRESS causes error in nasm
thx 
Who is General Error - and why is he reading my harddisk?
- Combuster
- 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: LINEAR_ADRESS causes error in nasm
The linear address is the address after segmentation (before is virtual address), but before page translation (which turns it into a physical address). So if your kernel is at 0xC0000000, then the linear address is somewhere in 0xC0000000. If you're in real mode, then you'll need to add the segment offset, i.e. if your code runs at 0x1000:0x0000, then the linear address is idt_offset + 16 * segment, or 0x10000 + idt
@Codecat: time to fix your GDT and IDT code
@Codecat: time to fix your GDT and IDT code
Re: LINEAR_ADRESS causes error in nasm
I currently have not Paging 
By the way: I have no clue, where exactly Grub puts my Kernel in Memory
I think this information may be obtained using the multiboot-structure?
By the way: I have no clue, where exactly Grub puts my Kernel in Memory
I think this information may be obtained using the multiboot-structure?
Who is General Error - and why is he reading my harddisk?
- Combuster
- 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: LINEAR_ADRESS causes error in nasm
Grub puts you exactly where you told it to.
Assuming that you have an ELF kernel - look at your linker script and see what its puts into the headers for GRUB to find
Amusingly enough, it makes the same changes in the binary, meaning that if you grab the address of something you already have its true address. But having met the required knowledge you should've known that
Assuming that you have an ELF kernel - look at your linker script and see what its puts into the headers for GRUB to find
Amusingly enough, it makes the same changes in the binary, meaning that if you grab the address of something you already have its true address. But having met the required knowledge you should've known that
Re: LINEAR_ADRESS causes error in nasm
Ah 
You know - I am really unsure about, what I got right and what I got wrong. But with this, I was right in the first place and then considered it as wrong. Dammit.
You know - I am really unsure about, what I got right and what I got wrong. But with this, I was right in the first place and then considered it as wrong. Dammit.
Who is General Error - and why is he reading my harddisk?
Re: LINEAR_ADRESS causes error in nasm
Oops, I mixed up linear and physical addresses in that post.Combuster wrote:@Codecat: time to fix your GDT and IDT code
