Reversible structural transformations in amorphous semiconductors for memory and logic