OSDev.org
https://forum.osdev.org/

mov operand type mismatch problem
https://forum.osdev.org/viewtopic.php?f=1&t=33475
Page 1 of 1

Author:  MakaAlbarn001 [ Thu Jan 31, 2019 6:56 pm ]
Post subject:  mov operand type mismatch problem

I'm trying to enable paging. For some reason, I keep getting this error:

Code:
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:
.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?

Author:  pat [ Thu Jan 31, 2019 7:11 pm ]
Post subject:  Re: mov operand type mismatch problem

MakaAlbarn001 wrote:
I'm trying to enable paging. For some reason, I keep getting this error:

Code:
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.

Author:  iansjack [ Fri Feb 01, 2019 12:41 am ]
Post subject:  Re: mov operand type mismatch problem

"$eax"?

Author:  MichaelPetch [ Fri Feb 01, 2019 12:45 am ]
Post subject:  Re: mov operand type mismatch problem

Yes, it should be %eax, not $eax

Author:  fpissarra [ Fri Feb 01, 2019 8:05 am ]
Post subject:  Re: mov operand type mismatch problem

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.

Author:  Octocontrabass [ Fri Feb 01, 2019 8:58 am ]
Post subject:  Re: mov operand type mismatch problem

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.

Author:  MichaelPetch [ Fri Feb 01, 2019 11:48 am ]
Post subject:  Re: mov operand type mismatch problem

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.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/