Re: Read N from keybord. Double even numbers. Using LOOP instruction
- From: Frank Kotler <fbkotler@xxxxxxxxxxx>
- Date: Mon, 26 Feb 2007 14:42:51 GMT
aeter wrote:
Hello im new to this group and new to assembly langage.
"Abandon hope, all ye who enter here." :)
i have a simple question how can i double even number?
Apparently too simple, or not simple enough for us. I'm not sure what you mean. Same way you'ld double an odd number - "shl", or perhaps on a machine with slow shifts, "add" would be faster(???)...
my code so far:
*Now* we can communicate! :)
INCLUDE Irvine32.inc
.code
main PROC ; Label for the start of the main program
mov edx, 0
mov ebx, 1
mov ecx, 10 ;loop can be excuted 10 times
label1:
add edx, ebx
Okay, so far...
add ebx, 1
inc ebx
These lines do about the same thing. Why not "add ebx, 2"? Or maybe you want either/or?
jmp label1
This will never exit, and following code will never be reached. You almost certainly don't want this here, no matter *what* you're trying to do.
loop label1
(this loop could be optimized to "mov edx, ????" - too lazy to figure it out - but I suppose that's not the point :)
exit
I suppose "Irvine32.inc" is providing sensible code here? Don't you want to see the result first? "Irvine32.inc" may provide code to help you - I'm not familiar with it. It's "traditional" to return the "result" in eax, so you might want to do "mov eax, edx", or better yet(?), use eax as the "result" register in the first place.
main ENDP
END main
Best,
Frank
.
- References:
- Prev by Date: Re: Accessing Command-line text
- Next by Date: Re: Help me about this question.
- 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
|