Page 1 of 1
Assembly errors in my boot loader code
Posted: Thu Sep 09, 2004 5:22 pm
by chris
Hi,
In the process of creating my boot loader I've come upon a few Assembly errors that I don't know how to fix. Any help would be appreciated.
[font=Courier]
pmode.s:7: error: invalid combination of opcode and operands
[/font]
This one is weird. It tells me that a symbol isn't defined when I do define it. It is called before it's defined though, but I though this was OK?
[font=Courier]
pmode.s:38: error: symbol `.empty_8024_end_loop' undefined
[/font]
No idea for this one. I'm assuming the line of code it points to has nothing to do with the error.
[font=Courier]
pmode.s:180: error: phase error detected at end of assembly.
[/font]
----
I'm also wondering what I need to do after setting the bit in cr0 for protected mode. Currently I just make a "jmp main32".
Re:Assembly errors in my boot loader code
Posted: Thu Sep 09, 2004 5:41 pm
by bakery2k
Which assembler are you using?
Re:Assembly errors in my boot loader code
Posted: Thu Sep 09, 2004 5:48 pm
by Dreamsmith
First of all, there is no such instruction on Intel processors as "move an immediate value into the SS register", thus that error. Do something like this instead:
As far as your undefined reference and your phase error, you didn't list the code where you define the reference, so we can't possibly say for sure what the problem is. However, although labels can be forward referenced, equates cannot, IIRC. Is it possible that's your problem?
Re:Assembly errors in my boot loader code
Posted: Thu Sep 09, 2004 6:20 pm
by chris
bakery2k wrote:
Which assembler are you using?
NASM. Sorry, should have mentioned that in my OP.
I fixed the first problem with Dreamsmith's solution. As for the other two, I still don't know what's going on. Here is the code:
Code: Select all
.empty_8042_loop:
dec cx
jz .empty_8024_end_loop ***
mov dx, 064h
in al, dx
test al, 01h
jz .no_output
mov dx, 064h
in al, dx
jmp .empty_8042_loop
.no_output:
test al, 02h
jnz .empty_8042_loop
.empty_8042_end_loop:
pop cx
ret
And I don't know what to give you for the phase thing? It just points me to the last line in the boot loader, which I gave in my OP.
Re:Assembly errors in my boot loader code
Posted: Thu Sep 09, 2004 9:12 pm
by Dreamsmith
chris wrote:Code: Select all
jz .empty_8024_end_loop
...
.empty_8042_end_loop:
And I don't know what to give you for the phase thing? It just points me to the last line in the boot loader, which I gave in my OP.
Fixing the undefined reference should fix the phase error. As for the undefined reference, do you see it now? 8024 vs. 8042?
Re:Assembly errors in my boot loader code
Posted: Fri Sep 10, 2004 2:48 am
by bakery2k
chris wrote:
I'm also wondering what I need to do after setting the bit in cr0 for protected mode. Currently I just make a "jmp main32".
You need to make a far jump, setting CS to the value for your code segment. Since you want a 32-bit jump offset from 16-bit code, you need a "jmp dword". You then need to load all of the other segment registers. Eg
Code: Select all
BITS 16
mov eax, cr0
or eax, 1
mov cr0, eax
jmp dword 0x08:main32
BITS 32
main32:
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
Re:Assembly errors in my boot loader code
Posted: Fri Sep 10, 2004 4:28 am
by chris
Dreamsmith wrote:
chris wrote:Code: Select all
jz .empty_8024_end_loop
...
.empty_8042_end_loop:
And I don't know what to give you for the phase thing? It just points me to the last line in the boot loader, which I gave in my OP.
Fixing the undefined reference should fix the phase error. As for the undefined reference, do you see it now? 8024 vs. 8042?
Oh man, I can't beleive I missed that. I looked at those two labels hard too! Thank you Dreamsmith.
And thanks to bakery2k for the others