Difference between revisions of "Assembly Language DO WHILE"
(Created page with "==C# example== <syntaxhighlight lang=csharp> int a = 0; do { a++ } while ( A != 99); </syntaxhighlight> ==Assembly Version== LDR R0, #0 .loop ADD R0, R0, #1...") |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
a++ | a++ | ||
} | } | ||
− | while ( | + | while ( a != 99); |
</syntaxhighlight> | </syntaxhighlight> | ||
==Assembly Version== | ==Assembly Version== | ||
− | + | MOV R0, #0 | |
− | + | loop: | |
ADD R0, R0, #1 | ADD R0, R0, #1 | ||
CMP R0, #99 | CMP R0, #99 | ||
− | BNE | + | BNE loop |
Line 1 sets the value of Register 0 to the value 0.<br> | Line 1 sets the value of Register 0 to the value 0.<br> |
Latest revision as of 09:29, 22 January 2020
C# example
int a = 0;
do
{
a++
}
while ( a != 99);
Assembly Version
MOV R0, #0 loop: ADD R0, R0, #1 CMP R0, #99 BNE loop
Line 1 sets the value of Register 0 to the value 0.
Line 2 is a label which will be used to branch too.
Line 3 adds the value 1 to the current value in Register 0 and stores the value back into Register 0.
Line 4 compares the value in Register 0 with the value 99.
Line 5 will branch to the .loop label if the previous compare was NOT EQUAL.