Difference between revisions of "Assembly Language FOR"
(Created page with "==C# example== <syntaxhighlight lang=csharp> for (int i=0; i < 10; i++ { } </syntaxhighlight> ==Assembly Version== MOV R0, #0 MOV R1, #10 .start CMP R0, R1...") |
(→C# example) |
||
Line 1: | Line 1: | ||
==C# example== | ==C# example== | ||
<syntaxhighlight lang=csharp> | <syntaxhighlight lang=csharp> | ||
− | for (int i=0; i < 10; i++ | + | for (int i=0; i < 10; i++) |
{ | { | ||
Revision as of 10:40, 20 June 2019
C# example
for (int i=0; i < 10; i++)
{
}
Assembly Version
MOV R0, #0 MOV R1, #10 .start CMP R0, R1 BEQ .end BGT .end ADD R0, R0, #1 .doCodeHere B .start .end
Line 1 sets the value of Register 0 to the value 0. i.e. i in the C# code.
Line 2 sets the value of Register 1 to the value 10. i.e. the condition to continue in the C# code.
Line 3 is the .start label.
Line 4 compares the value in Register 0 with the in Register 1.
Line 5 we branch to the end if equal to.
Line 6 we branch to the end if greater than.
Line 7 adds the value 1 to the current value in Register 0 and stores the value back into Register 0.
Line 8 a label to show where the code inside the for loop will go.
Line 9 will branch to the .start label.
Line 10 is label for the .end of the program.