English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2006-07-26 08:16:06 · 4 answers · asked by khile 1 in Computers & Internet Programming & Design

4 answers

Intel 8 bit assembly:

MOV R0, 07H; load register r0 with 7
LOOP:
DEC R0; decrement r0
CJNE R0, 00H, LOOP; if not 0 then go to LOOP

2006-07-26 09:45:06 · answer #1 · answered by justme 7 · 1 0

Yes. Looping in assembly language is accomplished through comparisons and conditional jumps. Conceptually, you do things like "if this register is not equal to zero", jump back to this point (the top of the loop). Since assembly language is different for different processors, I won't list any code. However, if you're using gcc (most Linux and Unix systems have it, including Mac OS X, and Cygwin on Windows), then note that you can compile a program with the -S switch and it will dump the assembly language output so you can see how it works.

2006-07-26 15:25:24 · answer #2 · answered by msabramo 2 · 0 0

First answer is correct for loops, but thats high-level language... for assembly language what you want to do is have your condition statement then your branch statement right after... as long as the condition statement is true branch to someone where... when the condition is not true it will not branch... syntax varies depending upon compiler and what program.

2006-07-26 15:28:20 · answer #3 · answered by rachelle105210 5 · 0 0

int a,
for (a = 1; a < some condition; a ++)
{
do this or that
}

while (Some condition)
{
do this or that
}

2006-07-26 15:21:50 · answer #4 · answered by Mag 7 · 0 1

fedest.com, questions and answers