Patent ID: 7707431

Claim:
A device of applying protection bit codes to encrypt a program for protection, comprising: a protection-bit-code generator, which generates a corresponding plurality of protection bit codes in accordance with a plurality of instructions of the program, wherein each instruction has P (positive integer) bits, and the protection bit codes are parity bits; a first protection-bit-code location generator, which generates a respective insertion position N (positive integer) for each protection bit code in accordance with processor status when executing the program; a protection-bit-code insertion unit, which inserts each protection bit code in a position between (N−1)th- and Nth-bit of a respective instruction in accordance with each insertion position N generated by the first protection-bit-code location generator, thereby generating an encrypted instruction; a second protection-bit-code location generator, which generates a respective insertion position N for each protection bit code in accordance with processor status when executing the program; and a protection-bit-code removal unit, which inputs the program and removes Nth bit of the respective instruction of the program in accordance with the insertion position N generated by the second protection-bit-code location generator; wherein the first protection-bit-code location generator and the second protection-bit-code location generator generate their insertion positions in accordance with a processor status when executing the program, and each protection-bit-code location generator comprises: an access status register (ASR), which indicates that the processor is accessing data or program block; a program status register (PSR), which indicates current processor status; a plurality of insertion position generators, which generate insertion positions in accordance with the predetermined functions; and a multiplexer, which has multiple input terminals respectively connected to output terminals of the insertion position generators in order to select one of the insertion positions generated by the insertion position generators through the input terminals for output.