Hi,

I was wondering if anyone could help me on this problem i am having. I am using a nested loop in my program so i have to try and temporarily store the value of the cx register,

mov counter, cx

(i have declared counter as a WORD.)

when i try store the value of counter back to the CX register i think it is storing the wrong value back because the loop executes more times than it should.

an example of what im trying to do is:


mov cx, 5

L1:
mov counter, cx

mov cx, 2

L2:
.... ; here is where the code of my loop 2 will be
Loop L2

....; here is where the code of my loop1 will be
mov cx, counter ;i think this is where the problem lies, the counter is storing some other value rather than 5.

Loop L1

I would be very greatful if anyone could give me an idea why its not working.

And also, is there anyway i can declare a LONG variable?

When i try this:

counter LONG ?

the assembler says that it does not recognise LONG

Thanks for anyhelp
:) Programmer_to_be
Posted on 2003-12-31 14:57:07 by Programmer_to_be
 

mov cx, 5

L1:
mov counter, cx

mov cx, 2

L2:
.... ; here is where the code of my loop 2 will be
Loop L2


You say the loop executes more times that it should so I think
you might have code in the loop that modifies e(cx). Maybe you can
try preserving ecx.

 

L2:
push ecx
...
pop ecx
Loop L2:




When i try this:

counter LONG ?

the assembler says that it does not recognise LONG


There is not long data type in masm, DWORD is what you need.
Posted on 2003-12-31 15:22:43 by Odyssey