Error: Operation Size not Specified

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
FunnyGuy9796
Member
Member
Posts: 61
Joined: Tue Sep 13, 2022 9:29 pm
Libera.chat IRC: FunnyGuy9796

Error: Operation Size not Specified

Post by FunnyGuy9796 »

I am trying to acquire a lock in assembly but come across an error
operation size not specified
.

This is the line causing the error:

Code: Select all

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

Re: Error: Operation Size not Specified

Post by Octocontrabass »

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.
FunnyGuy9796
Member
Member
Posts: 61
Joined: Tue Sep 13, 2022 9:29 pm
Libera.chat IRC: FunnyGuy9796

Re: Error: Operation Size not Specified

Post by FunnyGuy9796 »

I have tried adding dword to the line so that it appears as this

Code: Select all

lock bts dword [lock_addr], 0
and then I get an error saying that lock_addr is undefined anywhere it is used.
Octocontrabass
Member
Member
Posts: 5562
Joined: Mon Mar 25, 2013 7:01 pm

Re: Error: Operation Size not Specified

Post by Octocontrabass »

Did you define it anywhere?
FunnyGuy9796
Member
Member
Posts: 61
Joined: Tue Sep 13, 2022 9:29 pm
Libera.chat IRC: FunnyGuy9796

Re: Error: Operation Size not Specified

Post by FunnyGuy9796 »

I defined the variable in C
FunnyGuy9796
Member
Member
Posts: 61
Joined: Tue Sep 13, 2022 9:29 pm
Libera.chat IRC: FunnyGuy9796

Re: Error: Operation Size not Specified

Post by FunnyGuy9796 »

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

Re: Error: Operation Size not Specified

Post by Octocontrabass »

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