Skip to content

Instantly share code, notes, and snippets.

@mahdavipanah
Last active November 26, 2016 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahdavipanah/2410ec96c87599ff4b7fdd42f7767938 to your computer and use it in GitHub Desktop.
Save mahdavipanah/2410ec96c87599ff4b7fdd42f7767938 to your computer and use it in GitHub Desktop.
AVR Assembly examples
.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