]> cloudbase.mooo.com Git - avrcpm.git/blobdiff - avrcpm/avr/macros.inc
* More rcall --> lcall changes.
[avrcpm.git] / avrcpm / avr / macros.inc
index e6559c54972a4393fcd19fc3272061d1da83da0b..5152902f3f2ff09a5da8ab120b1025ffeb05b060 100644 (file)
        ldi    @0h, high(@1)
 .endm
 
+;------------------------------------------------
+; load 16 bit direct from data space
+
+.macro ldsw
+       lds    @0l, @1 
+       lds    @0h, @1+1
+.endm
+
+;------------------------------------------------
+; store 16 bit direct to data space
+
+.macro stsw
+       sts    @0,  @1l 
+       sts    @0+1,@1h
+.endm
+
 ;------------------------------------------------
 ; add 16 bit constant to register pair
 
        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
+
+;------------------------------------------------
+; 
+;
+.macro  ljmp
+  .if FLASHEND > 0x0fff
+       jmp     @0
+  .else
+       rjmp    @0
+  .endif
+.endm
+
+;------------------------------------------------
+;
+;
+.macro  lcall
+  .if FLASHEND > 0x0fff
+;      call    @0
+
+    .ifdef @0
+      .if abs(PC - @0) > 2047
+       call    @0
+      .else
+       rcall   @0
+      .endif
+    .else
+       call    @0
+    .endif
+  .else
+       rcall   @0
+  .endif
+.endm
+
 ;------------------------------------------------
 ; Print string.
 ;      printstring "String"
 
 .macro printstring
-  rcall        printstr
+  .if FLASHEND > 0x0fff
+       call    printstr
+  .else
+       rcall   printstr
+  .endif
   .if strlen(@0) % 2
     .db @0,0
   .else
 ;      print cr, lf
 
 .macro printnewline
-  rcall        printstr
+  lcall        printstr
   .db 13,0
 .endm