I'm building a KMDF device driver (64 bit) project with assembly code which is located in a separate .ASM file. I'm using the MASM (ml64.exe) compiler integrated within Visual Studio 2019 Community to build the .ASM into an object file and linked to the 64 bit project. I'm trying the following code which does a PUSH of an imm64 value onto the stack. I'm getting the error below. How can I accomplish this ?
PUSH FFFF0820CADBA78D //
The above instruction gives me the following error
Error A2006 undefined symbol : FFFF0820CADBA78Dh
CodePudding user response:
Recall that numbers must begin with a digit in MASM syntax (refer to the MASM manual for details) and must be suffixed with a h
, indicating a hexadecimal number. So the correct syntax would be
PUSH 0FFFF0820CADBA78Dh
Then please notice that no PUSH imm64
instruction exists on amd64. Only 32 bit constants sign extended to 64 bit can be pushed. So this will not assemble. Instead, first load the constant into a register and then push that.
MOV RAX, 0FFFF0820CADBA78Dh
PUSH RAX