0

I am in the process of learning assembly.

So far I have learned about different segments called text for the instructions, bss for variables, and data for constants.

section .bss:
    var     resb 4

section .text:
    global _start

_start:
    mov dword [var], 0 ;

loop:
    inc dword [var]
    jmp loop

I have a run.sh script to simplify the testing process:

nasm -f elf main.asm && ld -m elf_i386 -s -o main main.o && ./main

I get the following error when i compile with nasm:

$ sh run.sh
main.asm:16: warning: uninitialized space declared in non-BSS section `.bss:': zeroing [-w+zeroing]
run.sh: line 1: 49015 Segmentation fault      (core dumped) ./main

What did I do wrong?

I was expecting the var variable to get incremented. Instead I got an error

0 Answers0