assemblysyntaxx86masm

How to force the argument size for PUSH in MASM 32-bit code?


How do I control the size of the push instruction in MASM 5.0+?

push 42  ; I need this to be 2 bytes: opcode + 1 byte of data.
push 42  ; I need this to be 5 bytes: opcode + 4 bytes of data.

In NASM it's push strict byte 42 and push strict dword 42. I'm looking for the MASM equivalent.


Solution

  • This seems to work in Microsoft (R) Macro Assembler (x64) Version 14.37.32822.0

    push byte ptr 42
    push word ptr 42
    push dword ptr 42
    push 42
    

    The opcodes generated are

    6a2a            push    2Ah
    66682a00        push    2Ah
    682a000000      push    2Ah
    6a2a            push    2Ah
    

    The stack layout is

    000000da`eb36fbf6 000000000000002a 
    000000da`eb36fbfe 000000000000002a 
    000000da`eb36fc06 00000000002a002a