mov operand type mismatch problem

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.
Post Reply
MakaAlbarn001
Posts: 20
Joined: Fri Jun 16, 2017 1:51 am
Libera.chat IRC: Maka_Albarn

mov operand type mismatch problem

Post by MakaAlbarn001 »

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
Member
Posts: 36
Joined: Tue Apr 03, 2018 2:44 pm
Libera.chat IRC: patv

Re: mov operand type mismatch problem

Post by pat »

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.
Image 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..."
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: mov operand type mismatch problem

Post by iansjack »

"$eax"?
MichaelPetch
Member
Member
Posts: 798
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: mov operand type mismatch problem

Post by MichaelPetch »

Yes, it should be %eax, not $eax
fpissarra
Posts: 8
Joined: Mon Nov 26, 2018 9:14 am

Re: mov operand type mismatch problem

Post by fpissarra »

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
Member
Posts: 5586
Joined: Mon Mar 25, 2013 7:01 pm

Re: mov operand type mismatch problem

Post by Octocontrabass »

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
Member
Posts: 798
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: mov operand type mismatch problem

Post by MichaelPetch »

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.
Post Reply