主页 Swift UNIX C Assembly Go Plan 9 Web MCU Research Non-Tech

Size Directives in Assembly

2022-07-10 | Assembly | #Words: 210

During the assembly, you may need to specify some data size, such as the size of stack. In this case, you need to use the size command (Size Directives).

There are three types of size for command (can be lowercase):

  1. BYTE PTR [eax]: represents 1 byte starting from the address stored in eax.
  2. WORD PTR [eax]: represents the 2 bytes starting from the address stored in eax.
  3. DWORD PTR [eax]: represents the 4 bytes starting from the address stored in eax.

What needs to be noted here is if you use the mov instruction to set a position, then:

  1. mov BYTE PTR [eax],32: means to move 32 in the format of 8-bit integer (1 byte) (00100000) to the position of 1 byte starting from the address stored in eax.
  2. mov WORD PTR [eax],32: Indicates moving 32 in the format of a 16-bit integer (2 bytes) (00000000 00100000) to the position of 2 bytes starting from the address stored in eax.
  3. mov DWORD PTR [eax],32: Indicates moving 32 in the format of a 32-bit integer (4 bytes) (00000000 00000000 00000000 00100000) to the 4-byte address starting from the address stored in eax Location.