Uživatel:Labradan

Z MAM wiki

Přejít na: navigace, hledání

Obsah

[editovat] Diferents Operation Loops

We worked with ATtiny2313:

Soubor:ATtiny2313.png

And it is conected like this to Dragon:

Soubor:DW-Dragon-ATtiny2313.png


[editovat] Variable definition:


.include "tn2313def.inc"

           .EQU VARA = 0
           .EQU VARS = 1
           .EQU VARL = 2
           .EQU VARR = 3

MAIN:      LDI r30, 0      // Load number '0' to register r30
           LDI r31, 1      // Load number '1' to register r31
           LDI r29, 9      // Load number '9' to register r29
           LDI r28, 8      // Load number '8' to register r28
           LDI r27, 0      // Load number '0' to register r27
           OUT $18, r30    // Load the value of r30 in the direction $18, its means in PORTB
           RJMP CALLA      // Relative Jump to subroutine CALLA

[editovat] Now we make a Adder:


ADDER:     ADD r30, r31    // Adds the value of r30 to the value r31 and save it in r30
           OUT $18, r30    // Load the value of r30 to the direction of PORTB
           CP r30, r29     // Compare value r29 and r30
           BREQ CALLS      // If this values are equal, then jump to subroutine CALLS
           BRNE ADDER      // Else, return to ADDER

[editovat] Now we make a Subber:


SUBBER:    SUB r30, r31    // Substrate the value of r31 to the value of r30 and save it in r30
           OUT $18, r30    // Load the value of r30 to the direction of PORTB
           CP r30, r31     // Compare the value r30 and r31
           BREQ CALLL      // If are equal, jump to CALLL
           BRNE SUBBER     // Else, return to SUBBER

[editovat] Now we will move our bits to the Left:


MLEFT:     LSL r30         // Move the value of r30 to left
           OUT $18, r30    // Load the value of r30 to the direction of PORTB
           CP r30, r28     // Compare the value r30 and r28
           BREQ CALLR      // If this values are equals, then jump to CALLR
           BRNE MLEFT      // If not, return to MLEFT

[editovat] Now we will move our bits to the Right:


MRIGHT:    LSR r30         // Move the value of r30 to right
           OUT $18, r30    // Load the value of r30 to the direction of PORTB
           CP r30, r27     // Compare the value r30 and r27
           BREQ EXIT       // If this values are equals, then jump to EXIT
           BRNE MRIGHT     // Else, return to MRIGHT

CALLA:     SBI PORTD, VARA
           RJMP ADDER

CALLS:     CBI PORTD, VARA
           SBI PORTD, VARS
           RJMP SUBBER

CALLL:     CBI PORTD, VARS
           SBI PORTD, VARL
           RJMP MLEFT

CALLR:     CBI PORTD, VARL
           SBI PORTD, VARR
           RJMP MRIGHT

EXIT:      NOP


Soubor:Pic2.jpg


Soubor:Pic1.jpg


Soubor:Pic3.jpg


Soubor:Pic4.jpg

Osobní nástroje