Here’s a nice article explaining what really is the difference between the two. In a nutshell, example 1 is using
str as a string literal and example 2 uses it as an array of characters.
Below, I’m showing what’s happening in the assembly to reconfirm what Antoine Wood has said in the aforementioned article.
Here’s the assembler directive for
Here’s how the array of characters
str is being formed.
mov instructions are used to move the integers (first operand), that represent the concatenated bytes of characters of the string into consecutive memory locations pointed by the second operand, i.e.,
ebp (Base Pointer) register content
+ the offsets. Here’s where you can learn the meaning of
movw in further details.