Page 1 of 1
Error: Operation Size not Specified
Posted: Thu Jan 12, 2023 9:44 pm
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:
The OSDev Wiki has this exact line in the documentation but I know that it can be flawed. Any help would be much appreciated!
Re: Error: Operation Size not Specified
Posted: Thu Jan 12, 2023 10:06 pm
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.
Re: Error: Operation Size not Specified
Posted: Thu Jan 12, 2023 11:02 pm
by FunnyGuy9796
I have tried adding dword to the line so that it appears as this
and then I get an error saying that lock_addr is undefined anywhere it is used.
Re: Error: Operation Size not Specified
Posted: Thu Jan 12, 2023 11:29 pm
by Octocontrabass
Did you define it anywhere?
Re: Error: Operation Size not Specified
Posted: Thu Jan 12, 2023 11:32 pm
by FunnyGuy9796
I defined the variable in C
Re: Error: Operation Size not Specified
Posted: Thu Jan 12, 2023 11:43 pm
by Octocontrabass
Re: Error: Operation Size not Specified
Posted: Thu Jan 12, 2023 11:46 pm
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)
Re: Error: Operation Size not Specified
Posted: Thu Jan 12, 2023 11:50 pm
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.