Sum
START                              ; void main() {                        ;   void main() {          
        LD      R1, sum            ;         R1 = sum;                    ;     int sum=0;           
        LD      R2, i              ;         R2 = i;                      ;     int i;               
        LD      R3, ten            ;         R3 = ten;                    ;     for (i=0; i<=10; i++)
        LD      R4, one            ;         R4 = one;                    ;       sum += i;          
FOR:    CMP     R2, R3             ;         if (R2 > R3)//(i > 10)       ;   }                      
        JGT     EXIT               ;            goto EXIT;                ;                          
        ADD     R1, R2, R1         ;         R1 = R2 + R1;                ;                          
        ADD     R2, R4, R2         ;         R2 = R2 + R4;                ;                          
        JMP     FOR                ;         goto FOR;                    ;                          
EXIT:   RET                        ; EXIT:   return;                      ;                          
i       RESW    1                  ;         int i;                       ;                          
sum     WORD    0                  ;         int sum = 0;                 ;                          
ten     WORD    10                 ;         int ten = 10;                ;                          
one     WORD    1                  ;         int one = 1;                 ;                          
END                                ; }                                    ;
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License