- ; SUB instructions
- sub r0,r1,r2 ; sub
- sub. r0,r1,r2 ; sub, set carry
- subc r0,r1,r2 ; sub with carry
- subc. r0,r1,r2 ; sub with carry, set carry
-
- sra r0,r1,r2 ; arithmetic rightshift
-
- ; Logical instructions
- or r0,r1,r2 ; bitwise OR
- and r0,r1,r2 ; bitwise AND
- xor r0,r1,r2 ; bitwise XOR
- sr r0,r1,r2 ; rightshift
- sl r0,r1,r2 ; leftshift
-
- srx 7,8,r0,r1,r2 ; eXtended right shift (two input regs)
-
- rl r0,r1,r2 ; rotate left
- rr r0,r1,r2 ; rotate right
- nand r0,r1,r2 ; clear bits (notmask + and)
-
- orx 7,8,r0,r1,r2 ; eXtended OR
-
- ; Copy instruction. This is a virtual instruction
- ; translated to more lowlevel stuff like OR.
- mov r0,r2 ; copy data
-
- ; Jumps
- jmp label ; unconditional jump
- jand r0,r1,label ; jump if binary AND
- jnand r0,r1,label ; jump if not binary AND
- js r0,r1,label ; jump if all bits set
- jns r0,r1,label ; jump if not all bits set
- je r0,r1,label ; jump if equal
- jne r0,r1,label ; jump if not equal
- jls r0,r1,label ; jump if less (signed)
- jges r0,r1,label ; jump if greater or equal (signed)
- jgs r0,r1,label ; jump if greater (signed)
- jles r0,r1,label ; jump if less or equal (signed)
- jl r0,r1,label ; jump if less
- jge r0,r1,label ; jump if greater or equal
- jg r0,r1,label ; jump if greater
- jle r0,r1,label ; jump if less or equal
-
- jzx 7,8,r0,r1,label ; Jump if zero after shift and mask
- jnzx 7,8,r0,r1,label ; Jump if nonzero after shift and mask
-
- ; jump on external conditions
- jext ECOND_MAC_ON,r0,r0,label ; jump if external condition is TRUE
- jnext ECOND_MAC_ON,r0,r0,label ; jump if external condition is FALSE
-
- ; Subroutines
- call lr0,label ; store PC in lr0, call func at label
- ret lr0,lr1 ; store PC in lr0, return to lr1
- ; Both link registers can be the same
- ; and don't interfere.
-
- ; TKIP sbox lookup
- tkiph r0,r2 ; Lookup high
- tkiphs r0,r2 ; Lookup high, byteswap
- tkipl r0,r2 ; Lookup low
- tkipls r0,r2 ; Lookup low, byteswap
-
- nap ; sleep until event
-
- ; raw instruction
- @160 r0,r1,r2 ; equivalent to or r0,r1,r2
+ /* SUB instructions */
+ sub r0,r1,r2 /* sub */
+ sub. r0,r1,r2 /* sub, set carry */
+ subc r0,r1,r2 /* sub with carry */
+ subc. r0,r1,r2 /* sub with carry, set carry */
+
+ sra r0,r1,r2 /* arithmetic rightshift */
+
+ /* Logical instructions */
+ or r0,r1,r2 /* bitwise OR */
+ and r0,r1,r2 /* bitwise AND */
+ xor r0,r1,r2 /* bitwise XOR */
+ sr r0,r1,r2 /* rightshift */
+ sl r0,r1,r2 /* leftshift */
+
+ srx 7,8,r0,r1,r2 /* eXtended right shift (two input regs) */
+
+ rl r0,r1,r2 /* rotate left */
+ rr r0,r1,r2 /* rotate right */
+ nand r0,r1,r2 /* clear bits (notmask + and) */
+
+ orx 7,8,r0,r1,r2 /* eXtended OR */
+
+ /* Copy instruction. This is a virtual instruction
+ * translated to more lowlevel stuff like OR. */
+ mov r0,r2 /* copy data */
+
+ /* Jumps */
+ jmp label /* unconditional jump */
+ jand r0,r1,label /* jump if binary AND */
+ jnand r0,r1,label /* jump if not binary AND */
+ js r0,r1,label /* jump if all bits set */
+ jns r0,r1,label /* jump if not all bits set */
+ je r0,r1,label /* jump if equal */
+ jne r0,r1,label /* jump if not equal */
+ jls r0,r1,label /* jump if less (signed) */
+ jges r0,r1,label /* jump if greater or equal (signed) */
+ jgs r0,r1,label /* jump if greater (signed) */
+ jles r0,r1,label /* jump if less or equal (signed) */
+ jl r0,r1,label /* jump if less */
+ jge r0,r1,label /* jump if greater or equal */
+ jg r0,r1,label /* jump if greater */
+ jle r0,r1,label /* jump if less or equal */
+
+ jzx 7,8,r0,r1,label /* Jump if zero after shift and mask */
+ jnzx 7,8,r0,r1,label /* Jump if nonzero after shift and mask */
+
+ /* jump on external conditions */
+ jext ECOND_MAC_ON,label /* jump if external condition is TRUE */
+ jnext ECOND_MAC_ON,label /* jump if external condition is FALSE */
+
+ /* Subroutines */
+ call lr0,label /* store PC in lr0, call func at label */
+ ret lr0,lr1 /* store PC in lr0, return to lr1
+ * Both link registers can be the same
+ * and don't interfere. */
+
+ /* TKIP sbox lookup */
+ tkiph r0,r2 /* Lookup high */
+ tkiphs r0,r2 /* Lookup high, byteswap */
+ tkipl r0,r2 /* Lookup low */
+ tkipls r0,r2 /* Lookup low, byteswap */
+
+ nap /* sleep until event */
+
+ /* raw instruction */
+ @160 r0,r1,r2 /* equivalent to or r0,r1,r2 */