Last active
November 26, 2016 15:16
-
-
Save mahdavipanah/2410ec96c87599ff4b7fdd42f7767938 to your computer and use it in GitHub Desktop.
AVR Assembly examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.include "m32def.inc" | |
.macro array_operation | |
push r16 | |
push xl | |
push xh | |
push yl | |
push yh | |
push zl | |
push zh | |
ldi r16, @1 | |
ldi xl, low(@2) | |
ldi xh, high(@2) | |
ldi yl, low(@3) | |
ldi yh, high(@3) | |
ldi zl, low(@4) | |
ldi zh, high(@4) | |
loop: | |
ld r20, x+ | |
ld r21, y+ | |
@0 r20, r21 | |
st z+, r20 | |
dec r16 | |
brne loop | |
pop zh | |
pop zl | |
pop yh | |
pop yl | |
pop xh | |
pop xl | |
pop r16 | |
.endmacro | |
ldi r16, low(ramend) | |
out spl, r16 | |
ldi r16, high(ramend) | |
out sph, r16 | |
clc | |
array_operation adc, 8, 0x100, 0x108, 0x110 | |
clc | |
array_operation sbc, 8, 0x100, 0x108, 0x118 | |
forever: rjmp forever |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment