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

## [editovat] Diferents Operation Loops

We worked with ATtiny2313:

And it is conected like this to Dragon:

# [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
```

# [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
```

# [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
```

# [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
```

# [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
```
```
CALLA:     SBI PORTD, VARA
```
```
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

```