I am a beginner in Assembly Language Programming and I am looking for some help in creating a for loop that runs in n/10 seconds.
I am having trouble understanding how I would convert this Java for loop into an assembly language for loop. N is a value that user enters. for(i = 1; i<= n; i++)
Am I heading in the right direction? And if I am not where am I making a mistake? I am just trying to get the loop working and I will worry about run time later.
CODE:
.586
.MODEL FLAT
INCLUDE io.h ; header file for input/output
.STACK 4096
.DATA
number1 DWORD ?
sum DWORD ?
prompt1 BYTE "Enter a number between 1-100", 0
string BYTE 40 DUP (?)
.CODE
_MainProc PROC
input prompt1, string, 40 ; read ASCII characters
atod string ; convert to integer
mov ecx, eax ; store input to memory this is n
mov eax, 0 ; //set eax to 0
mov edx, 0 //This is sum
mov ebx, 1 //Create i
cmp ecx, ebx //compare i to n
jnle ecx //jump when negative or less than ecx
add edx, ebx //adds i to sum
inc ebx //i++
jmp ebx //jump to ebx repeat
_MainProc ENDP
END ; end of source code