Storing three integer values
Some ideas:


I'd try encapsulating the position and mask parameters to one parameter. Maybe a struct would be fine for this. It is easy to mix up the parameters of ret, for example, somebody could call it accidentally with 

`ret(output, secondnum_pos, firstnum_mask)` 


or with 

`ret(output, firstnum_mask, firstnum_pos)`. 


(Note the parameter order.)
Consider writing tests which store the i, j, k values in different order. Currently they do not detect if storing at the firstnum_pos overrides the second or the third values.
Consider making copies of i, j and k for the assert calls before you call the marcos. If a macro accidentally changes values of i, j or k the assert will not detect it.
A unit testing framework would be better for the testing: Unit Testing C Code