| | |
learning nasm assembly, need some help
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jan 2008
Posts: 49
Reputation:
Solved Threads: 0
Hello!
I've started learning assembly and I have some problems with a program. I'm trying to write a program that would print some text x-times (x would be inputed by me), but I always get an infinite loop, because it seems that the counter value doesn't get updated in the register in each iteration, therefore it never reaches the "x".
My code
Any help would be much appriciated.
I've started learning assembly and I have some problems with a program. I'm trying to write a program that would print some text x-times (x would be inputed by me), but I always get an infinite loop, because it seems that the counter value doesn't get updated in the register in each iteration, therefore it never reaches the "x".
My code
Assembly Syntax (Toggle Plain Text)
BITS 32 extern printf extern scanf global main section .data text db "Random text",10,0 input db "%d",10,0 number dd 0 section .text main: push dword number push dword input call scanf add esp,8 mov eax,[number] mov ecx,1 .loop: push dword text call printf add esp,4 inc ecx cmp ecx,eax jle .loop ret
Any help would be much appriciated.
•
•
Join Date: Jan 2008
Posts: 49
Reputation:
Solved Threads: 0
You're probably right, because i tried to increment the value in it twice in a row outside the loop, withouth using printf before. I only used it after and the value was indeed incremented twice like it was supposed to be.
Also, eax getting messed up isn't the only problem in my code, ecx doesn't get incremented either.
EDIT: well actually it does get, but it resets back after the code jumps back to the start of the loop
Also, eax getting messed up isn't the only problem in my code, ecx doesn't get incremented either.
EDIT: well actually it does get, but it resets back after the code jumps back to the start of the loop
Last edited by flash121; Nov 11th, 2008 at 9:45 am.
![]() |
Similar Threads
- Question on Interrupts... (Assembly)
- Opcodes? (Assembly)
- is a86 good compiler? and network programming (Assembly)
- newb and nasm (Assembly)
- Questions about assembly and boolean algebra (Assembly)
- Starting ASM (Assembly)
Other Threads in the Assembly Forum
- Previous Thread: need help generating graphic
- Next Thread: Data forwarding
| Thread Tools | Search this Thread |





