]> cloudbase.mooo.com Git - avrcpm.git/blobdiff - macros.inc
* New macros sbiw and INTERRUPT:
[avrcpm.git] / macros.inc
index b1091655455e4eeff4c2a180e462357f5d2ea0ba..d1178b77642d2fae263f37cdfcf5de27d55b4eb4 100644 (file)
        sbci    @0h, high(-@1)
 .endm
 
+;------------------------------------------------
+; sub 16 bit constant from register pair
+
+.macro subiw
+       subi    @0l, low(@1)  
+       sbci    @0h, high(@1)
+.endm
+
 ;------------------------------------------------
 ; Move single bit between two registers
 ;
        bld     @0,@1
 .endm
 
+;------------------------------------------------
+; 
+;
+;
+.macro  INTERRUPT
+  .set pos_ = PC
+  .org @0                      ; vector address
+  .if abs(pos_ - PC) > 2048
+       jmp     pos_
+  .else
+       rjmp    pos_            ; jump to handler
+  .endif
+  .org pos_                    ; restore PC
+.endm
+
 ;------------------------------------------------
 ; Print string.
 ;      printstring "String"