Issue with Assembly Code: Program Crashes at movb store to stack memory (%esp)

35 Views Asked by At

I am currently learning assembly and I am trying to write a simple program. I have the following code:

.global do_main

.section .text
do_main:
    sub $4, %esp
    movb $'H', (%esp)
    movb $'e', 1(%esp)
    movb $'y', 2(%esp)
    movb $'!', 3(%esp)
    mov $4, %eax
    mov $1, %ebx
    mov %esp, %ecx
    mov $1, %edx
    int $0x80
    mov $1, %eax
    mov $0, %ebx
    int $0x80

However, the program crashes at the movb instructions where I try to move characters onto the stack. I have watched tutorials on YouTube that use similar code, but for some reason, it doesn't work for me.

Can someone help me understand why my program is crashing at these specific instructions? Any insights or suggestions would be greatly appreciated.

0

There are 0 best solutions below