Which variable size to use (db, dw, dd) with x86 assembly?

Quick review,

  • DB – Define Byte. 8 bits
  • DW – Define Word. Generally 2 bytes on a typical x86 32-bit system
  • DD – Define double word. Generally 4 bytes on a typical x86 32-bit system

From x86 assembly tutorial,

The pop instruction removes the 4-byte data element from the top of the hardware-supported stack into the specified operand (i.e. register or memory location). It first moves the 4 bytes located at memory location [SP] into the specified register or memory location, and then increments SP by 4.

Your num is 1 byte. Try declaring it with DD so that it becomes 4 bytes and matches with pop semantics.

1 thought on “Which variable size to use (db, dw, dd) with x86 assembly?”

  1. whoah this blog is wonderful i really like reading your articles. Keep up the great paintings! You realize, a lot of people are hunting round for this info, you could help them greatly.

    Reply

Leave a Comment