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.
MakaAlbarn001
Posts: 20 Joined: Fri Jun 16, 2017 1:51 am
Libera.chat IRC: Maka_Albarn
Post
by MakaAlbarn001 » Thu Jan 31, 2019 6:56 pm
I'm trying to enable paging. For some reason, I keep getting this error:
Code: Select all
make[1]: Entering directory '/mnt/c/Users/tim21/Projects/firststep/arch/i686'
i686-elf-as paging_init.s -o paging_init.o
paging_init.s: Assembler messages:
paging_init.s:17: Error: operand type mismatch for `mov'
Makefile:14: recipe for target 'paging_init.o' failed
make[1]: *** [paging_init.o] Error 1
make[1]: Leaving directory '/mnt/c/Users/tim21/Projects/firststep/arch/i686'
Makefile:28: recipe for target 'arch.o' failed
make: *** [arch.o] Error 2
here is my assembly code:
Code: Select all
.section .text
.global loadPageDirectory
loadPageDirectory:
push %ebp
mov %esp, %ebp
mov 8(%esp), %eax
mov %eax, %cr3
mov %ebp, %esp
pop %ebp
ret
.global enablePaging
enablePaging:
push %ebp
mov %esp, %ebp
mov %cr0, $eax
or $0x80000000, %eax
mov %eax, %cr0
mov %ebp, %esp
pop %ebp
ret
Can anyone help me with this?
pat
Member
Posts: 36 Joined: Tue Apr 03, 2018 2:44 pm
Libera.chat IRC: patv
Post
by pat » Thu Jan 31, 2019 7:11 pm
MakaAlbarn001 wrote: I'm trying to enable paging. For some reason, I keep getting this error:
Code: Select all
paging_init.s:17: Error: operand type mismatch for `mov'
In cases like these, always examine what the tool is trying to point out to you. Look closely at line 17, and then compare it to line 18. Pay attention in particular to the prefix symbols.
is my operating system.
"...not because [it is] easy, but because [it is] hard; because that goal will serve to organize and measure the best of [my] energies and skills..."
iansjack
Member
Posts: 4706 Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK
Post
by iansjack » Fri Feb 01, 2019 12:41 am
"$eax"?
MichaelPetch
Member
Posts: 798 Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch
Post
by MichaelPetch » Fri Feb 01, 2019 12:45 am
Yes, it should be %eax , not $eax
fpissarra
Posts: 8 Joined: Mon Nov 26, 2018 9:14 am
Post
by fpissarra » Fri Feb 01, 2019 8:05 am
Since you are dealing with AT&T assembly style, it is imperative to use the correct mnemonics: movl , movw or movb instead of mov .
The same applies to push/pop, "or", ...
And, of course, as pointed out: $eax is wrong too.
Octocontrabass
Member
Posts: 5586 Joined: Mon Mar 25, 2013 7:01 pm
Post
by Octocontrabass » Fri Feb 01, 2019 8:58 am
fpissarra wrote: Since you are dealing with AT&T assembly style, it is imperative to use the correct mnemonics: movl , movw or movb instead of mov .
Not really. When the assembler can infer the operand size from the operands, you may use "mov" without a suffix.
MichaelPetch
Member
Posts: 798 Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch
Post
by MichaelPetch » Fri Feb 01, 2019 11:48 am
Octocontrabass wrote: Not really. When the assembler can infer the operand size from the operands, you may use "mov" without a suffix.
My personal coding preference when using AT&T syntax isn't to use the instruction suffixes unless they can't be inferred.