I've been teaching myself x86 Assembly and machine code. I ran into some trouble.

Note: This is all under FreeBSD using the NASM assembler. FreeBSD pushes kernel call arguments onto the stack rather than in Linux where the arguments are moved into registers.

Here's my Macro code for NASM
%define stdin 0
%define stdout 1
%define stderr 2

%define SYS_nosys 0
%define SYS_exit 1
%define SYS_fork 2
%define SYS_read 3
%define SYS_write 4

section .text
align 4

        int 80h

%macro system 1
        mov eax, %1
        call access.the.bsd.kernel

%macro sys.exit 0
        system SYS_exit

%macro sys.fork 0
        system SYS_fork

%macro sys.read 0
        system SYS_read

%macro sys.write 0
        system SYS_write
Here's the code for my program.
%include 'system.inc'

section .data
    msg db "above",0Ah
    len equ msg
    msg2 db "below",0Ah
    len2 equ msg2
    msg3 db "done",0Ah
    len3 equ msg3

section .text
global _start

    mov eax, 5 
    cmp eax, 3
    jl .ifbelow

    push dword len
    push dword msg
    push dword stdout
    jmp .done

    push dword len2
    push dword msg2
    push dword stdout
    push dword len3
    push dword msg3
    push dword stdout
    push dword 0
Now the problem is that when I call the kernel to print out msg it takes the whole .data section with it. It displays msg, msg2, and msg3.

Like so:
matt@mdwuni2:~/programming/Assembly/cmp# ./cond

The reason it prints out done twice is that the unconditional jump is working and sends it to the end of the program where I print out done again.

When I try to change the comparison to: cmp eax, 7
Where the program goes on the conditional jump to .ifbelow and prints out below.

Like so:
matt@mdwuni2:~/programming/Assembly/cmp# ./cond

The kernel call is dragging msg2 and msg3 and displaying it.

I've tried rearranging the .data section and it all seems to be having the same problem.

Am I doing something completely wrong?
All the jumps are working properly, it's just the displaying of the .data section that's messing up.

If anybody can help me I'd be extremely thankful


EDIT: Also if anybody can tell me a way to display the values of registers that'd be really awesome! That's something that I haven't figured out.