Re: Read N from keybord. Double even numbers. Using LOOP instruction
- From: "SpooK" <keith@xxxxxxxxxxx>
- Date: 26 Feb 2007 11:18:01 -0800
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 ;)
.
- Follow-Ups:
- Re: Read N from keybord. Double even numbers. Using LOOP instruction
- From: //\\\\o//\\\\annabee
- Re: Read N from keybord. Double even numbers. Using LOOP instruction
- From: Frank Kotler
- Re: Read N from keybord. Double even numbers. Using LOOP instruction
- 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
- 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: i8086 architectural fix
- 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
|