'Using write() to output string on stack

On Ubuntu 20, in x86-assembly, I am attempting to output a string pushed onto the stack using the write syscall. The little endian hexadecimal bytes pushed onto the stack are "hello world" in ASCII. My goal is to output the string solely from the stack. Why? To understand the stack more and how arguments are passed to syscalls/functions via registers.

From my basic understanding I should push the arguments onto the stack and mov the esp register (pointing to the top of the stack) into registers in the order of write's required arguments.

Here is my attempt (this outputs nothing):

; compile: nasm -f elf32 -g test.asm && ld -melf_i386 test.o -o test
section .text
global  _start

_start:
    xor  eax, eax

    push 0xc
    mov  ebx, esp

    push eax
    push 0x00646c72
    push 0x6f77206f
    push 0x6c6c6568

    mov  ecx, esp
    mov  edx, 1
    mov  eax, 4
    int  0x80

    mov  eax, 1
    int  0x80

Expected output:

hello world

How do I correct my code to display the expected output? And what am I doing wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source