OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Jun 15, 2019 11:08 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: mov operand type mismatch problem
PostPosted: Thu Jan 31, 2019 6:56 pm 
Offline

Joined: Fri Jun 16, 2017 1:51 am
Posts: 18
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?


Top
 Profile  
 
 Post subject: Re: mov operand type mismatch problem
PostPosted: Thu Jan 31, 2019 7:11 pm 
Offline
Member
Member

Joined: Tue Apr 03, 2018 2:44 pm
Posts: 33
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.

_________________
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..."


Top
 Profile  
 
 Post subject: Re: mov operand type mismatch problem
PostPosted: Fri Feb 01, 2019 12:41 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 3368
Location: Chichester, UK
"$eax"?


Top
 Profile  
 
 Post subject: Re: mov operand type mismatch problem
PostPosted: Fri Feb 01, 2019 12:45 am 
Online
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 421
Yes, it should be %eax, not $eax


Top
 Profile  
 
 Post subject: Re: mov operand type mismatch problem
PostPosted: Fri Feb 01, 2019 8:05 am 
Offline

Joined: Mon Nov 26, 2018 9:14 am
Posts: 6
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.


Top
 Profile  
 
 Post subject: Re: mov operand type mismatch problem
PostPosted: Fri Feb 01, 2019 8:58 am 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: mov operand type mismatch problem
PostPosted: Fri Feb 01, 2019 11:48 am 
Online
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 421
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: MichaelPetch and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group