Why doesn't this NASM program work? It loops endlessly
From: Francesca (spamtrap_at_crayne.org)
Date: 03/25/05
- Next message: Benjamin David Lunt: "Re: Why doesn't this NASM program work? It loops endlessly"
- Previous message: Grumble: "Re: How assembler /boot/i386/boot0/boot0.s in freeBSD"
- Next in thread: Benjamin David Lunt: "Re: Why doesn't this NASM program work? It loops endlessly"
- Reply: Benjamin David Lunt: "Re: Why doesn't this NASM program work? It loops endlessly"
- Reply: Charles A. Crayne: "Re: [Clax86list] Why doesn't this NASM program work? It loops endlessly"
- Reply: Mark Tolonen: "Re: Why doesn't this NASM program work? It loops endlessly"
- Reply: Mark Tolonen: "Re: Why doesn't this NASM program work? It loops endlessly"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 25 Mar 2005 18:49:40 +0000 (UTC)
section .data
hello: db 'Hello, World',10 ; 'Hello world!' plus a linefeed character
helloLen: equ $-hello ; Length of the 'Hello world!' string
;---------------------------------
section .bss
;---------------------------------
section .text
global start
start:
mov cx, 1 ; initialize induction variable i
jmp L2
L1:
mov eax,4 ; The system call for write (sys_write)
mov ebx,1 ; File descriptor 1 - standard output
mov ecx,hello ; Put the offset of hello in ecx
mov edx,helloLen ; helloLen is a constant, so we don't need to say
; mov edx,[helloLen] to get it's actual value
inc cx
int 80h ; Call the kernel
L2: cmp cx, 10
jle L1
mov eax,1 ; The system call for exit (sys_exit)
mov ebx,0 ; Exit with return code of 0 (no error)
int 80h
I compiled it on Mandrake Linux, but it prints "ello World", without H,
endlessly.
Francesco
- Next message: Benjamin David Lunt: "Re: Why doesn't this NASM program work? It loops endlessly"
- Previous message: Grumble: "Re: How assembler /boot/i386/boot0/boot0.s in freeBSD"
- Next in thread: Benjamin David Lunt: "Re: Why doesn't this NASM program work? It loops endlessly"
- Reply: Benjamin David Lunt: "Re: Why doesn't this NASM program work? It loops endlessly"
- Reply: Charles A. Crayne: "Re: [Clax86list] Why doesn't this NASM program work? It loops endlessly"
- Reply: Mark Tolonen: "Re: Why doesn't this NASM program work? It loops endlessly"
- Reply: Mark Tolonen: "Re: Why doesn't this NASM program work? It loops endlessly"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]