Assembly Segments in opcodes

后端 未结 2 1087
小蘑菇
小蘑菇 2021-02-04 12:44

I noticed that in Assembly segments are used in opcodes.

Example:

MOV DWORD PTR SS:[EBP-30],30

I think that \"PTR SS:\" is used to spec

2条回答
  •  猫巷女王i
    2021-02-04 12:51

    MOV DWORD PTR SS:[EBP-30],30
    

    There are two separate modifiers here, DWORD PTR and SS:.

    The first one tells us that we want to store a word at the address pointed to. This is needed when the assembler cannot tell that from the operands of the instruction. Here 30 could just as well be a byte to store.

    The SS: is a segment prefix, saying that we want to use an address relative to the stack segment. In this case it isn't strictly needed, because that is the default when using the ESP or EBP registers. So the second version of the instruction is identical to the first one.

    Had you used EBX instead of EBP there would have been a difference!

提交回复
热议问题