A terminal device for use in a software rewriting system configured to rewrite a software package of a control device, including a storage unit configured to store one or more pieces of source code in a text format for generating one or more pieces of object code in a binary format executable by the control device. The terminal device retrieves a piece of difference source code which is a difference in a piece of source code corresponding to a current piece of object code stored in the storage unit, generates a latest piece of source code based on the piece of difference source code retrieved and the one or more pieces of source code stored in the storage unit, converts the latest piece of source code into a latest piece of object code, and transmits the latest piece of object code obtained from the conversion to the control device.