Hello, dear programmers.
Now I master the assembler (and the AT & T syntax is under the Ubuntu 10.10 system), and I have a question, why does this code work?

.data msg: .string "Hello, world!\n" .text .globl main main: pushl $msg #вот здесь-то у меня и возникает вопрос call printf addl $4, %esp 

So, the question is, why am I pushing a stack of 4 bytes at a time when my message takes up more bytes?

    1 answer 1

    You're not pushing a word onto the stack, but the address where the msg label is located. The size of data pushed onto the stack is determined by the suffix l (push) - a double word, 4 bytes.
    Here is a good article , I study it myself)

    • I still don’t understand a bit, because I’m pushing the link to the first element on 'H', but the size of the link is equal to the size of the object to which it refers (in C, anyway, I think the link is in Africa as well) - sudo97
    • The size of the pointer (the link is from C ++) is not always equal to the size of the object to which it points. It is machine-dependent and in essence is an unsigned integer type. In x32 it is 4 bytes in size, in x86_64 it is 8 bytes. And it can point to the beginning of a section of memory containing anything, any type of data of any size. - skegg
    • > the size of the link is equal to the size of the object. This is not about a link but about a pointer or an address. And to say that the size of the address is equal to the size of the object is the same as saying that the size of the address of the house is equal to the size of the house itself :) With reference to memory, the address is just the number of the cell from which the object begins. Whatever the size of the object, the cell number will still be a 32- (or 64-) bit integer. - insolor
    • Thanks to everyone for their help - sudo97