OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Mar 19, 2024 12:32 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Error: Operation Size not Specified
PostPosted: Thu Jan 12, 2023 9:44 pm 
Offline
Member
Member

Joined: Tue Sep 13, 2022 9:29 pm
Posts: 61
I am trying to acquire a lock in assembly but come across an error
Quote:
operation size not specified
.

This is the line causing the error:
Code:
lock bts [lock_addr], 0


The OSDev Wiki has this exact line in the documentation but I know that it can be flawed. Any help would be much appreciated!


Top
 Profile  
 
 Post subject: Re: Error: Operation Size not Specified
PostPosted: Thu Jan 12, 2023 10:06 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5069
For whatever reason, NASM is unable to guess the correct operand size for this instruction (even though the obvious choice here is dword). Add the "dword" keyword and the error will go away.

Do you really need to write this code in assembly? C and C++ both have built-in functionality for this kind of thing.


Top
 Profile  
 
 Post subject: Re: Error: Operation Size not Specified
PostPosted: Thu Jan 12, 2023 11:02 pm 
Offline
Member
Member

Joined: Tue Sep 13, 2022 9:29 pm
Posts: 61
I have tried adding dword to the line so that it appears as this
Code:
lock bts dword [lock_addr], 0
and then I get an error saying that lock_addr is undefined anywhere it is used.


Top
 Profile  
 
 Post subject: Re: Error: Operation Size not Specified
PostPosted: Thu Jan 12, 2023 11:29 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5069
Did you define it anywhere?


Top
 Profile  
 
 Post subject: Re: Error: Operation Size not Specified
PostPosted: Thu Jan 12, 2023 11:32 pm 
Offline
Member
Member

Joined: Tue Sep 13, 2022 9:29 pm
Posts: 61
I defined the variable in C


Top
 Profile  
 
 Post subject: Re: Error: Operation Size not Specified
PostPosted: Thu Jan 12, 2023 11:43 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5069
You need to tell NASM that it was defined elsewhere.


Top
 Profile  
 
 Post subject: Re: Error: Operation Size not Specified
PostPosted: Thu Jan 12, 2023 11:46 pm 
Offline
Member
Member

Joined: Tue Sep 13, 2022 9:29 pm
Posts: 61
I have done this. However, I could never figure out if it is next to add the underscore before the name. (I know it’s a stupid question but might as well clear everything up)


Top
 Profile  
 
 Post subject: Re: Error: Operation Size not Specified
PostPosted: Thu Jan 12, 2023 11:50 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5069
It depends on your ABI. The System V ABI doesn't require it: symbols are the same in C and in assembly. The 32-bit Windows ABI does require it: symbols in C will have an extra underscore in assembly.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: DotBot [Bot], Google [Bot] and 14 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