User Tools

Site Tools


This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
useful_programs [2019/07/31 13:22]
emozolyak [Debug printing]
useful_programs [2019/09/17 08:23] (current)
emozolyak [Bit functions]
Line 47: Line 47:
 end  end 
-function outbit(condition,​ x, b) -- output bool conditoin ​as 0 /1 into a bit +function outbit(condition,​ x, b) -- output bool condition ​as 0 /1 into a bit 
      if condition then           if condition then     
          ​return hasbit(x, b) and x or x + bw(b)           ​return hasbit(x, b) and x or x + bw(b) 
Line 53: Line 53:
          ​return hasbit(x, b) and x - bw(b) or x           ​return hasbit(x, b) and x - bw(b) or x 
      ​end ​      ​end ​
 +function outBit(condition,​ alias, b) -- output bool condition as 0 /1 into a bit of a internal register ​
 +     local new_value = outbit(condition,​ R(alias), b)
 +     ​W(alias,​ new_value)
 end  end 

Page Tools