123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- ;------------------------------------------------;
- ; Push/Pop register pair
- ;
- ; pushw Z
- .macro pushw
- push @0H
- push @0L
- .endm
- .macro popw
- pop @0L
- pop @0H
- .endm
- ;------------------------------------------------;
- ; Load/store word from/to direct memory/immediate
- ;
- ; ldsw Z,mem
- ; ldiw Z,imm
- .macro ldiw
- ldi @0L,low(@1)
- ldi @0H,high(@1)
- .endm
- .macro ldsw
- lds @0L,@1
- lds @0H,@1+1
- .endm
- .macro lddw
- ldd @0L,@1
- ldd @0H,@1+1
- .endm
- .macro stsw
- sts @0,@1L
- sts @0+1,@1H
- .endm
- .macro stdw
- std @0,@1L
- std @0+1,@1H
- .endm
- ;------------------------------------------------;
- ; Store immediate into indirect memory via r16
- ;
- ; sti Z,imm
- ; stdi Z+d,imm
- .macro sti
- ldi r16,@1
- st @0,r16
- .endm
- .macro stdi
- ldi r16,@1
- std @0,r16
- .endm
- ;------------------------------------------------;
- ; add/sub/subc/cp/cpc/lsl/lsr/rol/ror to register pair
- ;
- .macro addiw
- subi @0L,low(-(@1))
- sbci @0H,high(-(@1))
- .endm
- .macro subiw
- subi @0L,low(@1)
- sbci @0H,high(@1)
- .endm
- .macro addw
- add @0L,@1L
- adc @0H,@1H
- .endm
- .macro adcw
- adc @0L,@1L
- adc @0H,@1H
- .endm
- .macro subw
- sub @0L,@1L
- sbc @0H,@1H
- .endm
- .macro sbcw
- sbc @0L,@1L
- sbc @0H,@1H
- .endm
- .macro cpw
- cp @0L,@1L
- cpc @0H,@1H
- .endm
- .macro cpcw
- cpc @0L,@1L
- cpc @0H,@1H
- .endm
- .macro andw
- and @0L,@1L
- and @0H,@1H
- .endm
- .macro andiw
- andi @0L,low(@1)
- andi @0H,high(@1)
- .endm
- .macro orw
- or @0L,@1L
- or @0H,@1H
- .endm
- .macro oriw
- ori @0L,low(@1)
- ori @0H,high(@1)
- .endm
- .macro lslw
- lsl @0L
- rol @0H
- .endm
- .macro lsrw
- lsr @0H
- ror @0L
- .endm
- .macro rolw
- rol @0L
- rol @0H
- .endm
- .macro rorw
- ror @0H
- ror @0L
- .endm
- .macro clrw
- clr @0L
- clr @0H
- .endm
- .macro comw
- com @0L
- com @0H
- .endm
- .macro movew
- mov @0L, @1L
- mov @0H, @1H
- .endm
- ;------------------------------------------------;
- ; Store immediate into direct memory via r16
- ;
- ; stsi var,imm
- .macro stsi
- ldi r16,@1
- sts @0,r16
- .endm
- ;------------------------------------------------;
- ; Output port immediate via r16
- ;
- ; outi port,var
- .macro outi
- ldi r16,@1
- out @0,r16
- .endm
- ;------------------------------------------------;
- ; Add immediate to register
- .macro addi
- subi @0,-(@1)
- .endm
- ;------------------------------------------------;
- ; Long branch
- .macro rjne
- breq PC+2
- rjmp @0
- .endm
- .macro rjeq
- brne PC+2
- rjmp @0
- .endm
- .macro rjcc
- brcs PC+2
- rjmp @0
- .endm
- .macro rjcs
- brcc PC+2
- rjmp @0
- .endm
- .macro rjtc
- brts PC+2
- rjmp @0
- .endm
- .macro rjts
- brtc PC+2
- rjmp @0
- .endm
- .macro retcc
- brcs PC+2
- ret
- .endm
- .macro retcs
- brcc PC+2
- ret
- .endm
- .macro reteq
- brne PC+2
- ret
- .endm
- .macro retne
- breq PC+2
- ret
- .endm
- ;------------------------------------------------;
- ; Move single bit between two registers
- ;
- ; bmov dstreg,dstbit,srcreg.srcbit
- .macro bmov
- bst @2,@3
- bld @0,@1
- .endm
|