Search code examples
assemblyx86ida

use of PTR during label assignment x86


So I've disassembled a small c++ program (learning a lot more about assembly since I've started this) and one of the first things that the assembly does at the top of the main procedure is

var_E4= byte ptr -0E4h

I know that ptr is used to declare the size of data the assembler can't implicitly know but after a lot of looking around I haven't found an example or explanation of this particular setup. Is the byte ptr telling the assembler to assign -228 to var_E4 (essentially telling to treat it as a single signed hex value)? If not what is happening?


Solution

  • That's just a macro definition that lets it write [rsp + var_E4] instead of [rsp - 0E4h], to help improve the readability of the disassembly output for instructions that are accessing local variables on the stack.

    You didn't tell us which disassembler exactly you used, or give any context (like lines that use this macro). I think there's probably not much more to say, though. Writing it this way vs. substituting in the value everywhere the macro is used has zero effect on the binary machine code you'd get from assembling.