Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

x86

assembly

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.

like image 407
user3097712 Avatar asked Dec 13 '13 01:12

user3097712


1 Answers

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
like image 148
George Avatar answered Nov 20 '22 04:11

George