Hey

I'm using NASM and UBuntu.

I'm trying to make a loop that writes to the console for each iteration. My current asm code is as follows:

----------------------------------------------------------
section .data
        prompt1:                db      'Type how many times you want hej to be printed', 10
        promptLen1:          equ    $-prompt1
        prompt2:                db      'hej'
        promptLen2:          equ    $-prompt2
        zero                        db      0

section .bss
        input                      resd    10

section .text
        global _start
_start:
        mov eax,4                        ; The system call for write (sys_write)
        mov ebx,1                        ; File descriptor 1 - standard output
        mov ecx,prompt1            ; Put the offset of prompt in ecx
        mov edx,promptLen1        ; promptLen is a constant, so we don't need to say
                                                    ;  mov edx, to get it's actual value
        int 80h                              ; Call the kernel


        mov eax,3
        mov ebx,1
        mov ecx,input
        mov edx,2

        int 80h

        mov ecx,
        cmp ecx,0
        je end
beginning:
        mov eax,4                          ; The system call for write (sys_write)
        mov ebx,1                          ; File descriptor 1 - standard output
        mov ecx,prompt2              ; Put the offset of prompt in ecx
        mov edx,promptLen2        ; promptLen is a constant, so we don't need to say
                                                  ; mov edx, to get it's actual value
        int 80h                              ; Call the kernel

        mov ecx,
        dec ecx
        jnz beginning

end:
        mov    eax,1
        mov    ebx,0
        int        80h                        ; Exit
----------------------------------------------------------

I want to be able to prompt the user for a number X. The loop should then iterate X times. Where am I going wrong?
Posted on 2008-02-21 06:09:50 by Herter
Not that I had a intense look but one error is here:


        mov ecx,
        dec ecx
        jnz beginning


never gets decreased. At each loop you reuse the same value (10). After you decrease ecx you need to store it in again. Or decrease directly.
Posted on 2008-02-21 18:07:50 by JimmyClif