add register code generate function