What is the meaning of the following assembler-code line?

assembly, x86

Solution

mov DWORD PTR[esp], OFFSET FLAT:.LCO

Moves the 4 bytes, that is the address specified .LCO to the memory location specified by ESP.

- .LCO is the memory address where the string "Hello World!" beings.

- ESP is the top of the stack, this code assumes that the value in ESP is a memory location

- The "FLAT" refers to the address space: http://en.wikipedia.org/wiki/Flat_memory_model

- .text signals the beginning of the code segment: http://en.wikipedia.org/wiki/Code_segment

Problem

I´ve written the following code in C to let create assembler code from that and to learn something about assembler. I start with a hello world of course, and in one line, there is following: ``` mov DWORD PTR[esp], OFFSET FLAT:.LCO ``` and about `LC0`, it says: ``` .string "Hello World!" .text .globl main .type main,@function ``` So, and I asked myself, what the meaning of line with `OFFSET FLAT:.LCO` ? Am I right, when I say, that something like a pointer which points to the string is given to `esp`? So that `esp` is now pointing to the string hello world, too? Is that right? Because this would be logical.

Original source