Re: Read N from keybord. Double even numbers. Using LOOP instruction
- From: //\\\\o//\\\\annabee <Wannabee@xxxxxxxxxxxx>
- Date: Tue, 27 Feb 2007 04:45:37 -0000
På Mon, 26 Feb 2007 19:18:01 -0000, skrev SpooK <keith@xxxxxxxxxxx>:
On Feb 26, 10:58 am, "aeter" <A.ele...@xxxxxxxxx> wrote:Thank you All..u guys are the best..im going to work on it..concerning
doubling the even numbers is like: S = 1 + (2+2) + 3 + (4+4) + 5 +
(6+6) +.....N
In that case, this should work
;##### DOUBLE ALL THE EVEN NUMBERS IN A GIVEN RANGE #####
;Double all the even numbers
xor eax,eax ;Sum Holder
mov ecx,10 ;Counter and Number, all in one!!!
DOUBLE_LOOP:
test ecx,1
jnz ODD
;Process an "Even" Number
mov edx,ecx
shl edx,1
add eax,edx
loop DOUBLE_LOOP
jmp END
;Process an "Odd" Number
ODD:
add eax,ecx
loop DOUBLE_LOOP
;Continue on with the rest of the code...
END:
;##### WASN'T THAT FUN??? #####
I would double-check the use of that "test" instruction, I'm kind of
rusty at it ;)
ok, so he wants to add them together and the range is known.
maybe:
mov eax (4+8+12+16+20 + 1+2+3+4+5)
is the answer to our little funny poster.
.
- References:
- Read N from keybord. Double even numbers. Using LOOP instruction
- From: aeter
- Re: Read N from keybord. Double even numbers. Using LOOP instruction
- From: SpooK
- Re: Read N from keybord. Double even numbers. Using LOOP instruction
- From: Rod Pemberton
- Re: Read N from keybord. Double even numbers. Using LOOP instruction
- From: SpooK
- Re: Read N from keybord. Double even numbers. Using LOOP instruction
- From: aeter
- Re: Read N from keybord. Double even numbers. Using LOOP instruction
- From: SpooK
- Read N from keybord. Double even numbers. Using LOOP instruction
- Prev by Date: Re: Read N from keybord. Double even numbers. Using LOOP instruction
- Next by Date: Re: Read N from keybord. Double even numbers. Using LOOP instruction
- Previous by thread: Re: Read N from keybord. Double even numbers. Using LOOP instruction
- Next by thread: Re: Read N from keybord. Double even numbers. Using LOOP instruction
- Index(es):
Relevant Pages
|