Hi i trying to make a loop in Nasm. I have the loop working but want to change the string when it loops and cant seem to get this to work.
I have this working:
main:
mov ebx,0 ; set ebx to 0
myloop: ;
inc ebx ;
mov [msg], 2Ah ; Immediate move * to msg
mov eax, 2Ah ;
push ecx ; save ecx as printf uses it
push OFFSET msg ; parameter used by printf
call printf ; print string msg
add esp, 4 ; remove pointer to msg
pop ecx ; restore ecx
cmp ebx,[len] ;
jl myloop ;
ret
.DATA
msg db "Hello, World+!", 0Ah, 0 ; 0A cariage return
; 0 end of string
star BYTE 2Ah ; 2A (hex) = Ascii *
len equ $ - (msg +1) ; length of string msg
end
and it outputs *ello, World! the right number of times but i want it to output this
*ello, World!
**llo, World!
***lo, World!
****o, World!
and so on.
Can anyone help me please.
I must also note that it is linked to a C library to use printf for out put.
I won't comment it
SECTION .data
msg db "Hello, World+!", 0Ah, 0
len equ $ - msg - 2
SECTION .text
main:
xor ebx, ebx
mov esi, msg
push esi
call printf
add esp, 4
.DoStar:
mov byte [esi + ebx], 2Ah
push esi
call printf
add esp, 4
inc ebx
cmp ebx, len
jne .DoStar
ret