examples/ASM/data-indirect.S
raw| 1 | |
| 2 | ddrb = 0x17 |
| 3 | portb = 0x18 |
| 4 | |
| 5 | .section .data |
| 6 | var1: |
| 7 | |
| 8 | .section .text ; denotes code section |
| 9 | .global main |
| 10 | main: |
| 11 | LDI R16, 0xff ; load r16 with 255 |
| 12 | OUT ddrb, R16 ; make all bits of port B as output |
| 13 | |
| 14 | LDI R17, 0b10101010 ; set r17 to 10101010b |
| 15 | STS var1, R17 ; store it to RAM at var1 |
| 16 | LDI R26, lo8(var1) ; R26 and R27 forms X, the 16 bit address |
| 17 | LDI R27, hi8(var1) |
| 18 | LD R16, X ; Load R16 from location pointed to by X |
| 19 | |
| 20 | OUT portb, R16 ; display R16 contents |
| 21 | .end |