[go: up one dir, main page]

CN1168005C - Method and system for processing local defect memory - Google Patents

Method and system for processing local defect memory Download PDF

Info

Publication number
CN1168005C
CN1168005C CNB011104082A CN01110408A CN1168005C CN 1168005 C CN1168005 C CN 1168005C CN B011104082 A CNB011104082 A CN B011104082A CN 01110408 A CN01110408 A CN 01110408A CN 1168005 C CN1168005 C CN 1168005C
Authority
CN
China
Prior art keywords
program code
mentioned
address
memory
storage unit
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CNB011104082A
Other languages
Chinese (zh)
Other versions
CN1378139A (en
Inventor
林锡聪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Winbond Electronics Corp
Original Assignee
Winbond Electronics Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Winbond Electronics Corp filed Critical Winbond Electronics Corp
Priority to CNB011104082A priority Critical patent/CN1168005C/en
Publication of CN1378139A publication Critical patent/CN1378139A/en
Application granted granted Critical
Publication of CN1168005C publication Critical patent/CN1168005C/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

A processing method of local defect memory scans the original program code, and determines a first break point and a second break point before and after the defect address corresponding to the defect memory cell. Moving the section program code between to the first address and the second address of the program code which do not correspond to the defect address. Connecting the execution sequence of the moved section program code and the unmoved part in the original program code, and adjusting the reference address between the moved section program code and the unmoved part in the original program code or the section program code. The modified program may be loaded into memory. The defective memory cells can be avoided without affecting the execution function of the original program code.

Description

局部缺陷内存的处理方法和系统Method and system for processing local defect memory

技术领域technical field

本发明是有关于一种局部缺陷内存的处理方法和系统,特别涉及一种处理方法和系统,能够针对还未加载内存或是已存在于内存内的程序代码加以调整,而使得此程序代码仍可以加载至具有局部缺陷存储单元的内存内并且加以执行。The present invention relates to a processing method and system for locally defective memory, and in particular to a processing method and system, which can adjust the program code that has not been loaded into the memory or already exists in the memory, so that the program code is still Can be loaded into memory with partially defective memory cells and executed.

背景技术Background technique

以往如果内存IC内存在任何缺陷存储单元(defective memorycell)时,一般是不会将这样的内存IC在市面上贩售。为了减少因单一或少数缺陷而废弃整个IC的情况,目前有许多技术可以让局部缺陷的内存IC,在操作上如同完全正常的内存IC。In the past, if there were any defective memory cells in the memory IC, such memory IC would not be sold on the market. In order to reduce the scrapping of the entire IC due to a single or a small number of defects, there are currently many technologies that can make a partially defective memory IC operate like a completely normal memory IC.

例如,美国专利NO.4939694中即揭露一种能够自我测试(self-testing)和自我修补(self-repairing)的内存系统。此内存系统可以在使用现场进行自我测试,以便定位出其中的缺陷存储单元。一旦发现任何缺陷存储单元,此内存系统便会使用一种称为错误修正码引擎(error correction code engine)的装置,对于这些缺陷存储单元进行修补。如果错误修正码引擎无法负荷,则内存系统便会取代掉这些缺陷存储单元。For example, US Patent No. 4939694 discloses a memory system capable of self-testing and self-repairing. The memory system can be self-tested in the field to locate defective memory cells. Once any defective memory cells are found, the memory system will use a device called an error correction code engine (error correction code engine) to repair these defective memory cells. If the error correction code engine is overwhelmed, the memory system will replace the defective memory cells.

另外在美国专利No.5644541中则是利用替换内存(substitutionmemory)来处理含有缺陷存储单元的半导体内存。当半导体内存在数个已知位置的错误位时,则利用一映像逻辑(mapping logic)将所有需要存取到这些错误位的存取请求,导向到替换内存内良好的存储单元,借此取代原本的缺陷存储单元。In addition, in US Patent No. 5,644,541, a substitution memory is used to process a semiconductor memory containing defective memory cells. When there are several error bits at known positions in the semiconductor memory, a mapping logic is used to direct all access requests that need to access these error bits to a good storage unit in the replacement memory, thereby replacing Originally defective memory cells.

美国专利No.5278847中则是揭露一种使用错误侦测/修正码(error detecting and correcting code,EDAC)的容错(fault-tolerating)记忆系统。储存数据的可靠度可以利用对于每个数据字符加入EDAC编码和增加备用位(spare-bit)而达成。US Patent No. 5278847 discloses a fault-tolerating memory system using error detecting and correcting code (EDAC). The reliability of stored data can be achieved by adding EDAC codes and adding spare-bits to each data character.

美国专利No.5579266中则是利用雷射修补技术和可程化熔丝修补技术来处理缺陷存储单元,可以利用冗余内存来取代缺陷内存。In US Patent No. 5579266, laser repair technology and programmable fuse repair technology are used to deal with defective memory cells, and redundant memory can be used to replace defective memory.

其中像是美国专利NO.4939694中所揭露的错误检测和修补技术、美国专利No.5278847中所揭露的编码和备用位技术,亦或是美国专利No.5644541中所揭露的存取导向技术,不仅会增加硬件设计上的困难度,同时在可执行机器码每次执行时也会造成程序执行上的负担。另外,如美国专利No.5579266所揭露的冗余内存技术,在硬件设计上或是在实际进行修补的程序上也都十分复杂。Among them, such as the error detection and repair technology disclosed in US Patent No. 4939694, the encoding and spare bit technology disclosed in US Patent No. 5278847, or the access guidance technology disclosed in US Patent No. 5644541, Not only will it increase the difficulty of hardware design, but it will also cause a burden on program execution each time the executable machine code is executed. In addition, the redundant memory technology disclosed in US Pat. No. 5,579,266 is also very complicated in terms of hardware design and actual repair procedures.

另一方面,一般可执行的机器程序代码是由计算机程序的原始码(source code),利用编辑器(compiler)和连结器(linker)所产生。机器程序代码则可以直接加载内存中来执行。第1图表示一般单芯片计算机(single chip computer)或单芯片系统(system-on-a-chip)的系统配置图。如图所示,此系统包括CPU(central processing unit,或称微处理器)1、RAM(random access memory,随机存取内存)3、ROM(read-only memory,只读存储器)5、I/O界面7以及外部储存装置9,例如硬盘机、软盘机或CD-ROM等等。在正常操作情况下,CPU1会通过数据/地址总线10,由I/O界面7或是外部储存装置9将预备执行的机器程序代码,加载到RAM3中。一般机器程序代码中包含了三个部分,分别为指令(instruction)、数据(data)和堆栈(stack)。CPU1会从指令部分的程序进入点(entry point)开始执行此机器程序代码。On the other hand, generally executable machine program code is generated from the source code of a computer program using a compiler and a linker. Machine program code can be loaded directly into memory for execution. Figure 1 shows a system configuration diagram of a general single chip computer (single chip computer) or a single chip system (system-on-a-chip). As shown in the figure, this system includes CPU (central processing unit, or microprocessor) 1, RAM (random access memory, random access memory) 3, ROM (read-only memory, read-only memory) 5, I/ O interface 7 and external storage device 9, such as hard disk drive, floppy disk drive or CD-ROM and so on. Under normal operating conditions, the CPU 1 loads the machine program code to be executed into the RAM 3 through the I/O interface 7 or the external storage device 9 through the data/address bus 10 . General machine program code contains three parts, namely instruction (instruction), data (data) and stack (stack). CPU1 will start to execute the machine program code from the program entry point (entry point) of the instruction part.

第2图表示一般机器程序代码在执行(execution)时的流程图。首先,取得程序进入点(S1)。接着取得下一个指令的地址(address)(S2),并且根据此地址,读取下一个指令中的操作码(opcode)(S3)。接着将操作码进行译码(S4),并且根据指令形式来判断是否需要操作数(operand)。如果此指令需要操作数,则再从后续地址中读取操作数(S5)。最后根据操作码所代表的指令动作以及操作数所代表的数据内容或参考地址,执行该指令(S6)。如果此指令为程序终止指令(S7),则机器程序代码执行完成(S8),否则回到步骤S2取得下一个指令的地址。必须说明的是,每个指令并不一定包含相同的位组长度,这与所采用的CPU类型有关。一般CPU所采用的指令集可分为可变长度码字指令集和固定长度码字指令集。Fig. 2 shows a flow chart of general machine program code during execution (execution). First, a program entry point is acquired (S1). Then the address (address) of the next instruction is obtained (S2), and according to the address, the operation code (opcode) in the next instruction is read (S3). Then the operation code is decoded (S4), and it is judged whether an operand (operand) is needed according to the instruction form. If the instruction requires an operand, the operand is read from the subsequent address (S5). Finally, the instruction is executed according to the instruction action represented by the operation code and the data content or reference address represented by the operand (S6). If the instruction is a program termination instruction (S7), the execution of the machine program code is completed (S8), otherwise, return to step S2 to obtain the address of the next instruction. It must be noted that each instruction does not necessarily contain the same byte length, which is related to the type of CPU used. The instruction set adopted by the general CPU can be divided into a variable-length codeword instruction set and a fixed-length codeword instruction set.

在上述执行流程中,主要是针对机器程序代码中的指令部分。如果相同的执行程序应用于数据部分或是堆栈部分,其译码结果则会完全错乱。当某个数据字节由CPU1译码成某个错误的操作码后,则会根据错误的操作码让后面数个数据被误认为操作数。一般CPU1是无法通过标准的撷取和译码动作来辨认出何者为指令部分,何者为数据部分或堆栈部分。另外,程序代码的指令部分和数据/堆栈部分亦不可以任意地加以分断,指令部分的分断必须根据各指令的格式而定,亦即各指令(包含操作数和操作码)的位组长度。而数据/堆栈部分一般是无法分断的,这是因此在数据/堆栈部分中可能包含只有在执行时才能判断的数据关连性,例如数据结构中的数组。In the above-mentioned execution flow, it is mainly for the instruction part in the machine program code. If the same execution program is applied to the data part or the stack part, the decoding result will be completely confused. When a data byte is decoded into a wrong opcode by CPU1, the following data will be mistaken for operands according to the wrong opcode. Generally, the CPU 1 cannot identify which is the instruction part, which is the data part or the stack part through standard fetching and decoding operations. In addition, the instruction part and data/stack part of the program code cannot be divided arbitrarily. The division of the instruction part must be determined according to the format of each instruction, that is, the byte length of each instruction (including operands and opcodes). The data/stack part is generally inseparable, which is why the data/stack part may contain data dependencies that can only be judged during execution, such as arrays in data structures.

发明内容Contents of the invention

有鉴于此,本发明的主要目的,在于提供一种局部缺陷内存的处理方法和系统,能够在不改变硬件配置和不增加软件执行负担的前提下,分别可以在程序代码未加载或是程序代码已存在的情况中,修改程序代码在此局部缺陷内存中的储存方式,以避免使用到缺陷存储单元。In view of this, the main purpose of the present invention is to provide a method and system for processing locally defective memory, which can be used when the program code is not loaded or the program code is not loaded without changing the hardware configuration and without increasing the software execution burden. Where this already exists, modify the way program code is stored in the local defective memory to avoid using defective memory locations.

本发明的目的可以通过以下措施来达到:The object of the present invention can be achieved through the following measures:

一种将程序代码加载内存以供执行的方法,适用于包含多个存储单元的一内存和待加载于上述内存的一原始程序代码,其包括下列步骤:A method for loading program code into a memory for execution, applicable to a memory including a plurality of storage units and an original program code to be loaded into the memory, comprising the following steps:

决定上述内存是否包含缺陷存储单元;determining whether said memory contains defective memory cells;

当上述内存不包含缺陷存储单元时,则加载上述原始程序代码至上述内存;When the above-mentioned memory does not contain defective storage units, then load the above-mentioned original program code into the above-mentioned memory;

当上述内存包含至少一缺陷存储单元时,则执行下列步骤:When the memory includes at least one defective storage unit, the following steps are performed:

扫描上述原始程序代码,在上述缺陷存储单元所对应于上述原始程序代码的一缺陷地址前后,决定第一分断点和第二分断点;Scanning the above-mentioned original program code, before and after a defect address corresponding to the above-mentioned original program code in the above-mentioned defective storage unit, determine a first breaking point and a second breaking point;

移动上述第一分断点和上述第二分断点之间的区段程序代码,至第一地址和第二地址之间,上述第一地址和上述第二地址之间的地址皆不对应于上述内存的上述缺陷地址;Move the section program code between the above-mentioned first breakpoint and the above-mentioned second breakpoint to between the first address and the second address, and the addresses between the above-mentioned first address and the above-mentioned second address do not correspond to the above-mentioned memory The above defect address of ;

当上述区段程序代码包含至少一可执行的指令时,提供一连接指令,用以连接移动后的上述区段程序代码与上述原始程序代码中未移动部分的执行顺序;以及When the segment program code includes at least one executable instruction, a connection instruction is provided to connect the execution sequence of the moved segment program code and the unmoved part of the original program code; and

加载上述原始程序代码中未移动部分、上述连接指令和移动后的上述区段程序代码至上述内存中。Loading the unmoved part of the above original program code, the above connection instruction and the moved above section program code into the above memory.

一种内存处理系统,用以处理一包含多个存储单元的内存,其包括:A memory processing system for processing a memory comprising a plurality of storage units, comprising:

一微处理器,耦接于上述内存,用以加载一原始程序代码,当上述原始程序代码被加载的存储单元皆为无缺陷存储单元时,则加载上述原始程序代码于上述内存,当上述原始程序代码被加载的存储单元包含至少一缺陷存储单元时,则扫描上述原始程序代码,在上述缺陷存储单元所对应于上述原始程序代码的一缺陷地址前后,决定第一分断点和第二分断点,并且移动上述第一分断点和上述第二分断点之间的区段程序代码至第一地址和第二地址之间,并且当上述区段程序代码包含至少一可执行的指令时,提供一连接指令,用以连接上述区段程序代码与上述原始程序代码中未移动部分的执行顺序,并且加载上述原始程序代码中未移动部分、上述连接指令和移动后的上述区段程序代码至上述内存中,其中上述第一地址和上述第二地址之间的程序代码所对应的内存地址不包含上述缺陷地址。A microprocessor, coupled to the above-mentioned memory, is used to load an original program code. When the storage units to which the above-mentioned original program code is loaded are all non-defective storage units, then load the above-mentioned original program code into the above-mentioned memory. When the above-mentioned original program code When the storage unit where the program code is loaded includes at least one defective storage unit, the original program code is scanned, and the first breakpoint and the second breakpoint are determined before and after a defective address corresponding to the original program code in the defective storage unit , and move the segment program code between the first breakpoint and the second breakpoint to between the first address and the second address, and when the segment program code contains at least one executable instruction, provide a A connection instruction, used to connect the execution order of the above-mentioned section program code and the unmoved part of the above-mentioned original program code, and load the unmoved part of the above-mentioned original program code, the above-mentioned connection instruction and the above-mentioned section program code after moving to the above-mentioned memory , wherein the memory address corresponding to the program code between the above-mentioned first address and the above-mentioned second address does not include the above-mentioned defective address.

一种防治局部弱化内存处理方法,适用于已载负一原始程序代码的一内存,其包括下列步骤:A memory processing method for preventing local weakening, suitable for a memory loaded with an original program code, comprising the following steps:

检查上述内存,用以找出上述内存中功能弱化的缺陷存储单元;Examining the above-mentioned memory to find defective storage units with weakened functions in the above-mentioned memory;

当上述内存中包含至少一功能弱化的存储单元,则执行下列步骤:When the above-mentioned memory contains at least one storage unit with weakened function, the following steps are performed:

扫描上述原始程序代码,在上述缺陷存储单元对应于上述原始程序代码的一缺陷地址前后,决定第一分断点和第二分断点;Scanning the original program code, determining a first breakpoint and a second breakpoint before and after a defect address of the defective storage unit corresponding to the original program code;

移动上述第一分断点和上述第二分断点之间的区段程序代码,至上述内存中的第一存储单元和第二存储单元之间,上述第一存储单元和上述第二存储单元之间不包含上述缺陷存储单元;以及Move the section program code between the above-mentioned first breakpoint and the above-mentioned second breakpoint to between the first storage unit and the second storage unit in the above-mentioned internal memory, between the above-mentioned first storage unit and the above-mentioned second storage unit does not contain the defective memory cells described above; and

当上述区段程序代码包含至少一可执行的指令时,连接移动后的上述区段程序代码与上述原始程序代码中未移动部分的执行顺序。When the segment program code includes at least one executable instruction, link the execution sequence of the moved segment program code and the unmoved portion of the original program code.

一种内存处理系统,用以处理一包含多个存储单元并且已储存一原始程序代码的内存,其包括:A memory processing system for processing a memory comprising a plurality of storage units and storing an original program code, comprising:

一微处理器,耦接于上述内存,用以检查上述内存的存储单元是否有功能弱化的存储单元,当上述弱化的存储单元存在并且已储存上述原始程序代码时,则扫描上述原始程序代码,在上述弱化的存储单元对应于上述原始程序代码的一弱化地址前后,决定第一分断点和第二分断点,并且移动上述第一分断点和上述第二分断点之间的区段程序代码至上述内存中的第一存储单元和第二存储单元之间,并且当上述区段程序代码包含至少一可执行的指令时,连接移动后的上述区段程序代码与上述原始程序代码中未移动部分的执行顺序,其中上述第一存储单元和上述第二存储单元之间不包含上述缺陷存储单元。A microprocessor, coupled to the above-mentioned memory, is used to check whether the storage unit of the above-mentioned memory has a weakened storage unit, and when the weakened storage unit exists and has stored the above-mentioned original program code, then scan the above-mentioned original program code, Before and after the weakened storage unit corresponds to a weakened address of the original program code, determine a first breakpoint and a second breakpoint, and move the section program code between the first breakpoint and the second breakpoint to Between the first storage unit and the second storage unit in the above-mentioned internal memory, and when the above-mentioned section program code contains at least one executable instruction, connect the moved section of the above-mentioned program code and the unmoved part of the above-mentioned original program code The execution sequence of , wherein the defective storage unit is not included between the first storage unit and the second storage unit.

一种内存处理方法,适用于包含多个存储单元的一内存和待加载于上述内存的一原始程序代码,其包括下列步骤:A memory processing method is applicable to a memory comprising a plurality of storage units and an original program code to be loaded in the memory, comprising the following steps:

决定上述内存是否包含缺陷存储单元;determining whether said memory contains defective memory cells;

当上述内存不包含缺陷存储单元或上述原始程序代码不被加载于上述内存中缺陷存储单元所对应的缺陷地址时,则加载上述原始程序代码至上述内存;When the above-mentioned memory does not contain a defective storage unit or the above-mentioned original program code is not loaded in the defective address corresponding to the defective storage unit in the above-mentioned memory, then load the above-mentioned original program code into the above-mentioned memory;

当上述原始程序代码被加载上述内存内至少一缺陷存储单元所对应的缺陷地址时,则执行下列步骤:When the above-mentioned original program code is loaded into the defective address corresponding to at least one defective storage unit in the above-mentioned memory, the following steps are performed:

扫描上述原始程序代码,在上述缺陷存储单元所对应于上述原始程序代码的一缺陷地址前后,决定第一分断点和第二分断点;Scanning the above-mentioned original program code, before and after a defect address corresponding to the above-mentioned original program code in the above-mentioned defective storage unit, determine a first breaking point and a second breaking point;

加载上述原始程序代码至上述内存中;loading the above original program code into the above memory;

加载上述第一分断点和上述第二分断点之间的区段程序代码,至第一存储单元和第二存储单元之间,上述第一存储单元和上述第二存储单元之间不包含上述缺陷存储单元;以及Load the section program code between the above-mentioned first breakpoint and the above-mentioned second breakpoint to between the first storage unit and the second storage unit, and the above-mentioned defect is not included between the above-mentioned first storage unit and the above-mentioned second storage unit storage unit; and

当上述区段程序代码包含至少一可执行的指令时,连接位于上述第一存储单元和第二存储单元之间的上述区段程序代码与上述原始程序代码中其它部分的执行顺序。When the segment program code includes at least one executable instruction, link the execution sequence of the segment program code located between the first storage unit and the second storage unit with other parts of the original program code.

一种内存处理系统,用以处理一包含多个存储单元的内存,其包括:A memory processing system for processing a memory comprising a plurality of storage units, comprising:

一微处理器,耦接于上述内存,用以加载一原始程序代码,当上述原始程序代码被加载的存储单元包含至少一缺陷存储单元时,则该系统能扫描上述原始程序代码,且在上述缺陷存储单元所对应于上述原始程序代码的一缺陷地址前后,决定第一分断点和第二分断点,并且加载上述原始程序代码至上述内存中以及加载上述第一分断点和上述第二分断点之间的区段程序代码至第一存储单元和第二存储单元之间,并且当上述区段程序代码包含至少一可执行的指令时,连接位于上述第一存储单元和第二存储单元之间的上述区段程序代码与上述原始程序代码中其它部分的执行顺序,其中上述第一存储单元和上述第二存储单元之间不包含上述缺陷存储单元。A microprocessor, coupled to the above-mentioned memory, is used to load an original program code. When the storage unit where the above-mentioned original program code is loaded contains at least one defective storage unit, the system can scan the above-mentioned original program code, and in the above-mentioned Determining a first breakpoint and a second breakpoint before and after a defective address corresponding to the original program code in the defective storage unit, and loading the original program code into the memory and loading the first breakpoint and the second breakpoint The segment program code between the first storage unit and the second storage unit, and when the segment program code contains at least one executable instruction, the connection is between the first storage unit and the second storage unit The execution order of the above segment program code and other parts of the above original program code, wherein the defective storage unit is not included between the first storage unit and the second storage unit.

一种程序代码扫描处理方法,用以决定一原始程序代码的可分断点,上述程序代码扫描处理方法包括下列步骤:A program code scanning processing method for determining a separable breaking point of an original program code, the above-mentioned program code scanning processing method includes the following steps:

提供一第一数据表和一第二数据表,上述第一数据表用以记录上述原始程序代码中的条件分支指令相关的待扫描地址,上述第二数据表用以记录已读取的地址范围;Provide a first data table and a second data table, the first data table is used to record the address to be scanned related to the conditional branch instruction in the original program code, and the second data table is used to record the read address range ;

依序读取上述原始程序代码;Read the above original program code in sequence;

当所读取的指令为一条件分支指令时,记录上述条件分支指令相关的待扫描地址于上述第一数据表,并且依上述条件分支指令的下一地址或分支目的地址继续扫描;When the read instruction is a conditional branch instruction, record the address to be scanned related to the conditional branch instruction in the above-mentioned first data table, and continue scanning according to the next address or branch destination address of the above-mentioned conditional branch instruction;

随指令的读取,更新上述第二数据表的地址范围,并且当完成读取至少一完整指令时,输出可分断点;以及updating the address range of the second data table as the instruction is read, and outputting a detachable breakpoint when at least one complete instruction is read; and

当所读取的指令为一结束指令或其地址在上述第二数据表的地址范围内时,则根据上述第一数据表的一待扫描地址继续读取,并将该待扫描地址从上述第一数据表中除去。When the read command is an end command or its address is within the address range of the second data table, continue reading according to an address to be scanned in the first data table, and transfer the address to be scanned from the first Datasheet removed.

本发明相比现有技术具有如下优点:Compared with the prior art, the present invention has the following advantages:

根据上述的目的,本发明提出一种局部缺陷内存的处理方法,可以适用在包含多个存储单元的内存和待加载此内存的原始程序代码之间。假设在此内存中具有至少一缺陷存储单元。首先,扫描此原始程序代码,并且在缺陷存储单元于原始程序代码中所对应的缺陷地址前后,决定出第一分断点和第二分断点。接着移动第一分断点和第二分断点之间的区段程序代码到第一地址和第二地址之间,其中第一地址和第二地址之间不包含上述缺陷地址。当被移动的区段程序代码中包含至少一可执行的指令时(亦即包含指令部分),则需要连接移动后的区段程序代码与原始程序代码中未移动部分的执行顺序。而当移动后的区段程序代码与原始程序代码中未移动部分之间存在参考地址或是区段程序代码本身的内部存在参考地址,则视情况进行调整。最后,便可以将原始程序代码中未移动部分、连接指令以及移动后的区段程序代码依序加载至内存中。由于利用上述方式所加载的程序代码为可执行状态并且不会储存于已知的缺陷存储单元之中,因此即使内存中存在缺陷存储单元,此内存仍可以正常地使用。另外,上述处理过程中不涉及硬件电路的修改或变更,因此实施成本相当低。According to the above purpose, the present invention proposes a method for processing locally defective memory, which can be applied between a memory containing multiple storage units and the original program code to be loaded into the memory. Assume that there is at least one defective memory cell in the memory. Firstly, the original program code is scanned, and the first breakpoint and the second breakpoint are determined before and after the defect address corresponding to the defective memory unit in the original program code. Then move the section program code between the first breakpoint and the second breakpoint to between the first address and the second address, wherein the defect address is not included between the first address and the second address. When the moved segment program code contains at least one executable instruction (ie, includes an instruction part), it is necessary to connect the execution sequence of the moved segment program code and the unmoved part of the original program code. And when there is a reference address between the moved section program code and the unmoved part of the original program code or there is a reference address inside the section program code itself, adjustment is made according to the situation. Finally, the unmoved part of the original program code, the connection instruction and the moved segment program code can be sequentially loaded into the memory. Since the program code loaded by the above method is in an executable state and will not be stored in a known defective storage unit, even if there is a defective storage unit in the memory, the memory can still be used normally. In addition, the above processing does not involve modification or change of hardware circuits, so the implementation cost is quite low.

另外,如果待加载的原始程序代码本身已经过模块化处理,则在进行程序代码扫描时便可以直接决定所需要的分断点。但是如果原始程序代码并未预先加以模块化处理,则依序读取原始程序代码,再依据原始程序代码中各指令组成,输出多个可分断点,最后便可以根据缺陷地址和待插入的连接指令长度,决定出所需要的第一分断点和第二分断点。要确定扫描到完整的原始程序代码,本发明则提供下列方法。首先,提供第一数据表和第二数据表,其中第一数据表用来记录原始程序代码中条件分支指令的分支目的地址,而第二数据表则用来记录已读取的地址范围。当所读取的指令为一条件分支指令时,便在第一数据表中记录下条件分支指令的分支目的地址;当完成一指令的读取时,则更新第二数据表的地址范围。当所读取的指令为一结束指令或是其地址在第二数据表的地址范围内时,则只要第一数据表的分支目的地址不属于第二数据表的地址范围内,便可以根据第一数据表的分支目的地址继续读取。通过上述处理分支和循环的方式,便可以确保扫描到所有的指令。In addition, if the original program code to be loaded has been modularized, the required breaking point can be directly determined when the program code is scanned. However, if the original program code is not pre-modularized, the original program code is read in sequence, and then multiple breakpoints are output according to the composition of the instructions in the original program code, and finally the defect address and the connection to be inserted can be used. The command length determines the required first breakpoint and second breakpoint. To confirm that the complete original program code has been scanned, the present invention provides the following methods. First, a first data table and a second data table are provided, wherein the first data table is used to record the branch destination address of the conditional branch instruction in the original program code, and the second data table is used to record the read address range. When the read instruction is a conditional branch instruction, the branch destination address of the conditional branch instruction is recorded in the first data table; when an instruction is read, the address range of the second data table is updated. When the read instruction is an end instruction or its address is within the address range of the second data table, as long as the branch destination address of the first data table does not belong to the address range of the second data table, the The branch destination address of the data table continues to be read. Through the above method of processing branches and loops, it is possible to ensure that all instructions are scanned.

另外,要连接移动后的区段程序代码和原始程序代码中未移动部分,可以插入两个无条件分支指令来完成。第一个无条件分支指令插入在第一分断点的地址上,其目的地址为区段程序代码移动后的第一地址;第二个无条件分支指令插入在区段程序代码移动后的第二地址,其目的地址则为第二分断点。In addition, two unconditional branch instructions can be inserted to connect the moved section program code with the unmoved part of the original program code. The first unconditional branch instruction is inserted at the address of the first breakpoint, and its destination address is the first address after the section program code moves; the second unconditional branch instruction is inserted at the second address after the section program code moves, Its destination address is the second breakpoint.

上述处理方式在实用上亦可以略加变更。缘此,本发明另外提出了一种局部缺陷内存处理方法,其程序与上述方式有少量不同。首先,扫描原始程序代码并且在缺陷存储单元对应的缺陷地址前后,决定第一分断点和第二分断点。接着,先将原始程序代码整个加载到内存中,而另外在不包含缺陷存储单元的第一存储单元和第二存储单元之间,再次加载位于第一分断点和第二分断点之间的区段程序代码。接着则与前述方式相同:连接再加载的区段程序代码与原始程序代码中其它部分的执行顺序、修正彼此间的参考地址。通过此方式,除了可以达到前一方式的目的外,由于程序代码先被加载到内存中,还可以加快后续处理步骤的速度,例如修正参考地址的处理。The above processing method can also be changed slightly in practice. For this reason, the present invention additionally proposes a local defect memory processing method, the procedure of which is slightly different from the above method. Firstly, the original program code is scanned and a first breaking point and a second breaking point are determined before and after the defective address corresponding to the defective memory unit. Next, load the entire original program code into the memory first, and in addition, between the first storage unit and the second storage unit that does not contain the defective storage unit, load the area between the first breakpoint and the second breakpoint again segment program code. Then, it is the same as the aforementioned method: connect the execution sequence of the reloaded segment program code and other parts of the original program code, and correct the reference addresses between them. In this way, in addition to achieving the purpose of the previous way, because the program code is first loaded into the memory, the speed of the subsequent processing steps, such as the processing of modifying the reference address, can also be accelerated.

另外,本发明另提供一种局部缺陷内存的处理方法,可以适用于原始程序代码已存在于内存中的情况。首先,检查内存并且找出内存中功能弱化的至少一缺陷存储单元。接着扫描原始程序代码,以便在缺陷存储单元所对应的缺陷地址前后,决定出第一分断点和第二分断点。接着将第一分断点和第二分断点之间的区段程序代码,移动到至内存中不包含上述缺陷存储单元的第一存储单元和第二存储单元之间。接着则与前述方式相同:连接移动后的区段程序代码与原始程序代码中未移动部分的执行顺序、修正彼此间的参考地址。由于此方式可以适用于使用中的内存,因此在应用上更为方便。In addition, the present invention also provides a method for processing partially defective memory, which is applicable to the situation where the original program code already exists in the memory. Firstly, the memory is checked and at least one defective storage unit with weakened function is found in the memory. Then scan the original program code so as to determine the first breaking point and the second breaking point before and after the defective address corresponding to the defective memory unit. Then move the section program code between the first breaking point and the second breaking point to between the first storage unit and the second storage unit which do not contain the defective storage unit in the internal memory. Then, it is the same as the aforementioned method: connect the execution sequence of the moved segment program code and the unmoved part of the original program code, and correct the reference addresses between them. Since this method can be applied to the memory in use, it is more convenient in application.

综合以上所述,本发明的局部缺陷内存的处理方法和系统具有下列优点:Based on the above, the local defect memory processing method and system of the present invention have the following advantages:

1.本发明中解决局部缺陷存储单元的方式,并不需要变更硬件(内存配置)上的设计或是增加硬件线路,而是通过修改程序代码的方式来避免使用到缺陷存储单元;而程序代码在执行时所增加的负担也不严重,在最佳情况下只需要加入两个无条件分支命令(即JMP)即可。因此在实现复杂度以及成本上,本发明的确具有极佳的产业利用价值。1. In the present invention, the method for solving the local defect storage unit does not need to change the design on the hardware (memory configuration) or increase the hardware circuit, but avoids using the defective storage unit by modifying the program code; and the program code The increased burden during execution is not serious, and only two unconditional branch commands (ie JMP) need to be added in the best case. Therefore, in terms of implementation complexity and cost, the present invention does have excellent industrial application value.

2.本发明不仅可以适用于已知缺陷内存的情况,也可以适用于正在使用中的内存,如第三实施例所述。现有技术中的硬件修正方式通常在执行时都必须将内存抽出单独加以修改,而本发明则可以对于使用中的内存调整其中的程序代码,因此应用上更为方便。2. The present invention is applicable not only to known defective memory, but also to memory in use, as described in the third embodiment. The hardware correction method in the prior art usually needs to extract the memory and modify it separately during execution, but the present invention can adjust the program code in the memory in use, so the application is more convenient.

为使本发明的上述目的、特征和优点能更明显易懂,下文特举一较佳实施例,并配合所附图式,作详细说明如下:In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and understandable, a preferred embodiment is specifically cited below, and in conjunction with the accompanying drawings, the detailed description is as follows:

附图说明Description of drawings

第1图表示一般单芯片计算机(single chip computer)或单芯片系统(system-on-a-chip)的系统配置图。Figure 1 shows a system configuration diagram of a general single chip computer (single chip computer) or a single chip system (system-on-a-chip).

第2图表示一般机器程序代码在执行(execution)时的流程图。Fig. 2 shows a flow chart of general machine program code during execution (execution).

第3图表示本发明第一实施例的局部缺陷内存处理系统的配置图。Fig. 3 shows a configuration diagram of a local defect memory processing system according to the first embodiment of the present invention.

第4图表示本发明第一实施例的局部缺陷内存处理方法的流程图。FIG. 4 shows a flow chart of the local defect memory processing method according to the first embodiment of the present invention.

第5图表示在本发明中程序代码扫描方法的流程图。Fig. 5 shows a flow chart of the program code scanning method in the present invention.

第6图表示根据本发明的程序代码扫描方法处理一程序代码范例的示意图。FIG. 6 shows a schematic diagram of processing a program code example by the program code scanning method of the present invention.

第7图表示在本发明中连接移动后区段程序代码和原始程序代码未移动部分的示意图。Fig. 7 shows a schematic diagram of connecting the moved section program code and the unmoved part of the original program code in the present invention.

第8图表示在本发明中修正参考地址的示意图。Fig. 8 shows a schematic diagram of modifying reference addresses in the present invention.

第9图表示本发明第二实施例的局部缺陷内存处理方法的流程图。FIG. 9 shows a flow chart of the local defect memory processing method according to the second embodiment of the present invention.

第10图表示本发明第三实施例的局部缺陷内存处理系统的配置图。Fig. 10 shows a configuration diagram of a local defect memory processing system according to a third embodiment of the present invention.

第11图表示本发明第三实施例的局部缺陷内存处理方法的流程图。FIG. 11 shows a flow chart of a local defect memory processing method according to the third embodiment of the present invention.

符号说明1~CPU;3~RAM(内存);5~ROM;7~I/O界面;9~外部储存装置;10~数据/地址总线;20~原始程序代码;30~第一数据表;40~第二数据表;C1-C7~指令段部分;D1-D3~数据/堆栈部分;21~缺陷地址;51、52~连接指令;50~移动区段程序代码后的程序代码;60~完成参考地址修正的程序代码;R1-R3、R1’-R3’~参考地址。Symbol Description 1~CPU; 3~RAM (memory); 5~ROM; 7~I/O interface; 9~external storage device; 10~data/address bus; 20~original program code; 30~first data table; 40~second data table; C1-C7~command segment part; D1-D3~data/stack part; 21~defect address; 51, 52~connection instruction; 50~program code after moving segment program code; 60~ Complete program code for reference address correction; R1-R3, R1'-R3'~reference address.

具体实施方式Detailed ways

本发明的局部缺陷内存处理方法和系统,主要是修正待加载或已存在的原始程序代码,以避开发生缺陷的存储单元,借此让具有局部缺陷存储单元的内存IC仍可以正常运作。修正原始程序代码的处理方式,主要是通过辨识机器程序代码的可分断点(break point)和移动区段程序代码的方式来达成。亦即,先辨识出原始程序代码中的可分断点,再根据实际发生缺陷的存储单元所对应到的程序位置,决定出可以移动的区段程序代码;将此区段程序代码移动到可以正常工作的内存单元后,再利用连接指令,维持移动后的区段程序代码和原始程序代码之间的执行顺序,便可以避开使用到缺陷存储单元。由于本发明并不需要变更或重新设计硬件电路,并且在软件执行上所增加的额外负担也非常有限(仅增加连接指令),因此可以达到本发明的目的。以下配合图式,详细说明本发明各实施例的技术内容。The local defect memory processing method and system of the present invention mainly corrects the original program code to be loaded or existing to avoid the defective storage unit, so that the memory IC with the partial defective storage unit can still operate normally. Modifying the processing method of the original program code is mainly achieved by identifying the break point of the machine program code and moving the segment program code. That is to say, first identify the separable breakpoints in the original program code, and then determine the section of program code that can be moved according to the program position corresponding to the actual defective storage unit; move the section of program code to the normal After the working memory unit is used, the connection instruction is used to maintain the execution sequence between the moved segment program code and the original program code, so that the defective memory unit can be avoided. Because the present invention does not need to change or redesign the hardware circuit, and the additional burden added on software execution is also very limited (only connection instructions are added), so the purpose of the present invention can be achieved. The technical content of each embodiment of the present invention will be described in detail below with reference to the drawings.

第一实施例:First embodiment:

第3图表示第一实施例的局部缺陷内存处理系统的配置图。在第3图中,内存3包含至少一个缺陷存储单元,而在以下的描述中,除了特别指出外,均以单一缺陷存储单元或相邻的一组缺陷存储单元为预设条件。CPU1则是预备通过数据/地址总线10将原始程序代码20加载到内存3,而原始程序代码20原本预备加载的存储单元中就包括上述的缺陷存储单元。因此,在CPU1中所执行的加载器(loader),必须执行一些前置处理动作,才能够保证加载后的原始程序代码20不会占用到缺陷存储单元,同时原始程序代码20本身仍可以正常的执行。在本实施例中,CPU1和内存3可以共存于同一集成电路中,例如单芯片系统(system on a chip)的应用,另外,亦可以是个别独立的集成电路,此时CPU1与内存3通过特定的IC接脚相连接,用来执行后续所描述的缺陷检查、处理等等步骤。Fig. 3 shows a configuration diagram of the local defect memory processing system of the first embodiment. In FIG. 3 , the memory 3 includes at least one defective storage unit. In the following descriptions, unless otherwise specified, a single defective storage unit or a group of adjacent defective storage units is used as a preset condition. The CPU 1 is preparing to load the original program code 20 into the memory 3 through the data/address bus 10 , and the storage units to be loaded by the original program code 20 include the defective storage units mentioned above. Therefore, the loader (loader) executed in CPU1 must perform some pre-processing actions to ensure that the loaded original program code 20 will not occupy the defective storage unit, and the original program code 20 itself can still be normal. implement. In this embodiment, CPU1 and memory 3 can coexist in the same integrated circuit, such as the application of a single chip system (system on a chip), in addition, it can also be an individual independent integrated circuit. At this time, CPU1 and memory 3 pass a specific The IC pins are connected to perform the defect inspection, processing and other steps described later.

第4图表示第一实施例的局部缺陷内存处理方法的流程图,其中详述CPU1在加载原始程序代码20前所必须执行的各种步骤。首先,CPU1必须决定在内存3中缺陷存储单元的位置(S10)。亦即,需要对于内存3进行缺陷测试,以便检查出其中是否包含有缺陷存储单元以及其实体位置。一种检查存储单元是否为缺陷的例子,是将数据”1”和”0”写入每个存储单元,再读出其数据是否正确,如果写入数据和读出数据不吻合,即表示该存储单元有缺陷。实际执行测试的装置可以是CPU1本身,亦可以由外部的测试器或计算机来执行。FIG. 4 shows a flow chart of the local defect memory processing method of the first embodiment, which details various steps that the CPU 1 must perform before loading the original program code 20 . First, the CPU 1 has to decide the location of the defective memory cell in the memory 3 (S10). That is, it is necessary to perform a defect test on the memory 3 in order to check whether there is a defective memory unit and its physical location. An example of checking whether a memory cell is a defect is to write data "1" and "0" into each memory cell, and then read whether the data is correct. If the written data and the read data do not match, it means the The storage unit is defective. The device for actually executing the test may be the CPU 1 itself, or may be executed by an external tester or computer.

根据经测试所得到的缺陷存储单元实体地址以及原始程序代码20的加载讯息(例如加载开始点地址),便可以决定出此缺陷存储单元在原始程序代码20中所对应的缺陷地址(S11),亦即此缺陷存储单元在原始程序代码20所代表的绝对参考地址。由于缺陷存储单元无法正常操作,因此CPU1所执行的加载器必须让原本预定储存于此缺陷存储单元的程序代码部分,变更加载到其它的存储单元,以避免数据的流失。然而,根据前述对于一般机器程序代码的描述可知,机器程序代码是不可以任意分断的,某一个字节可能仅是某个指令的一部分,不可以单独加以移动,以避免指令和数据的错乱。因此,CPU1必须在原始程序代码20中找出适当的分断点,才能正确地移动原本占用到缺陷存储单元的字节。According to the physical address of the defective storage unit obtained through testing and the loading information of the original program code 20 (such as the address of the loading start point), the corresponding defective address of the defective storage unit in the original program code 20 can be determined (S11), That is, the absolute reference address represented by the defective storage unit in the original program code 20 . Since the defective storage unit cannot operate normally, the loader executed by the CPU 1 must change and load the program code originally scheduled to be stored in the defective storage unit to other storage units to avoid data loss. However, according to the foregoing description of general machine program codes, it can be seen that machine program codes cannot be divided arbitrarily, and a certain byte may only be a part of a certain instruction and cannot be moved separately to avoid confusion of instructions and data. Therefore, the CPU 1 must find an appropriate breaking point in the original program code 20, so as to correctly move the byte originally occupying the defective storage unit.

接着,对于原始程序代码20进行扫描(S12),以便找出原始程序代码20中的所有可分断点。在一般机器程序代码中,指令部分中的个别指令间均为可分断点,这是因为即使个别指令被分断,在执行时CPU1仍可以正确译码出正确的指令讯息;相对地,数据部分和堆栈部分则不可分断,这是因为数据和堆栈之间可能具有在执行时才可能检查出来的相关性,例如数组数据。另一方面,CPU1无法直接分辨出机器程序代码中的指令部分和其它部分。因此,CPU1必须对原始程序代码20中的指令部分整个进行扫描,才可以决定出所有的可分断点。Next, scan the original program code 20 ( S12 ), so as to find out all the breakable points in the original program code 20 . In general machine program codes, the individual instructions in the instruction part are separable breakpoints, this is because even if the individual instructions are cut off, CPU1 can still correctly decode the correct instruction message during execution; relatively, the data part and The stack part is inseparable because there may be dependencies between the data and the stack that can only be checked at execution time, such as array data. On the other hand, the CPU 1 cannot directly distinguish the instruction part from other parts in the machine program code. Therefore, the CPU1 must scan the entire instruction part in the original program code 20 to determine all the separable breakpoints.

第5图表示本实施例中原始程序代码20的扫描方法流程图。此处所谓的”扫描”,是包含撷取操作码、译码、撷取操作数这些动作,但是不需要执行。为了扫描原始程序代码20的整个指令部分,必须特别处理一般机器程序代码中常见的两种特殊型态,即分支(branch)和循环(loop)。Fig. 5 shows a flowchart of the scanning method of the original program code 20 in this embodiment. The so-called "scanning" here includes operations such as fetching opcodes, decoding, and fetching operands, but does not need to be executed. In order to scan the entire instruction portion of the original program code 20, two special types commonly seen in general machine program codes, namely branch and loop, must be specially handled.

分支型态会在原始程序代码20中产生两种不同的指令执行顺序,一般是由条件分支指令(conditional branch instruction)所造成,例如JNE、JE、JG等等。在扫描过程中,为了确定处理到所有的指令,因此两种指令执行顺序都需要加以扫描。在本实施例中,扫描过程中会建立第一数据表30(如第5图所示),当遇到任何条件分支指令时,会将该分支指令的下一地址或该分支指令的分支目的地址(branch-toaddress)储存于第一数据表30中。借此,当主要指令执行顺序完成扫描后,便可以根据第一数据表30进行其它执行顺序的扫描。另外需要说明的是,一般分支指令还包含一种无条件分支指令(unconditionalbranch instruction),例如JMP,但是由于这种指令并不会造成两条不同的指令执行顺序,因此本实施例中的扫描可依其目的地址(branch-to address)继续扫描。另一方面,循环型态则会造成扫描无法终止。而在本实施例中,则是在扫描过程中建立第二数据表40,用来记录已经被扫描过的地址范围,而每扫描一个指令,即会更新第二数据表40。当重复扫描到循环内部时,便可以根据第二数据表40判断出已扫描过此部分,因此可以防止继续扫描后续的指令。The branch type will generate two different instruction execution sequences in the original program code 20, generally caused by conditional branch instructions, such as JNE, JE, JG and so on. In the scanning process, in order to ensure that all instructions are processed, both instruction execution sequences need to be scanned. In this embodiment, the first data table 30 (as shown in FIG. 5 ) will be established during the scanning process. When any conditional branch instruction is encountered, the next address of the branch instruction or the branch purpose of the branch instruction will be displayed. The address (branch-toaddress) is stored in the first data table 30 . In this way, after the main instruction execution sequence is scanned, other execution sequences can be scanned according to the first data table 30 . In addition, it should be noted that general branch instructions also include an unconditional branch instruction (unconditional branch instruction), such as JMP, but since this instruction does not cause two different instruction execution sequences, the scanning in this embodiment can be based on Its destination address (branch-to address) continues to scan. On the other hand, the loop type will cause the scan to not be terminated. In this embodiment, the second data table 40 is created during the scanning process to record the scanned address range, and the second data table 40 is updated every time an instruction is scanned. When repeated scanning reaches the inside of the loop, it can be judged according to the second data table 40 that this part has been scanned, thus preventing further scanning of subsequent instructions.

以下详细说明第5图中各步骤的动作。首先取得程序进入点(S110)。接着取得并指定下一个指令的地址(S111),并且根据此地址,读取下一个指令中的操作码并且进行译码(S112)。如果此指令需要操作数,则再从后续地址中读取操作数(S113)。此时所读取者为一完整指令,因此可以记录为一可分断点。接着判断此指令是否为条件分支指令(S114),如果是,则可:(i)将此条件分支指令的分支目的地址加入到第一数据表30中(S115),而依该条件分支指令的下一地址继续扫描;或(ii)将该条件分支指令的下一地址加入到第一数据表中,而依该条件分支指令的分支目的地址继续扫描。接着决定出扫描的下一个地址(S116),判断此地址的指令是否为返回指令(例如RET)或程序结束指令(例如END)(S117)。如果下一个地址的指令不是返回指令或是程序结束指令,则根据第二数据表40来判断此一地址是否为已扫描地址范围(S121)。如果此下一个地址亦非已扫描地址范围,则修改第二数据表40以更新已扫描地址范围之后(S122),继续处理下一个指令。如果在步骤S117中下一个地址的指令的确是返回指令或是程序结束指令,亦或在步骤S121中下一个地址为已扫描过的地址范围,则判断第一数据表30中是否仍有待扫描地址(S118)。如果仍有,则从第一数据表30中取得一待扫描地址并且将其从第一数据表30中移去(S119),再修改第二数据表40中的已扫描地址范围(S122),继续处理此一待扫描地址的后续指令。如果第一数据表30中已经没有待扫描地址时,则表示已经扫描完成全部的指令(S120)。此时已经得到所有的可分断点,并且可以判断出原始程序代码20中的指令部分和数据/堆栈部分。在第5图中,虚线框P1表示处理分支型态的相关步骤,虚线框P2则表示处理循环型态的相关步骤。The operation of each step in Fig. 5 will be described in detail below. First, the program entry point is acquired (S110). Then obtain and designate the address of the next instruction (S111), and read and decode the operation code in the next instruction according to the address (S112). If the instruction requires an operand, the operand is read from the subsequent address (S113). What is read at this time is a complete instruction, so it can be recorded as a separable breakpoint. Then judge whether this instruction is a conditional branch instruction (S114), if so, then can: (i) add the branch destination address of this conditional branch instruction in the first data table 30 (S115), and according to the conditional branch instruction Continue scanning at the next address; or (ii) add the next address of the conditional branch instruction into the first data table, and continue scanning according to the branch destination address of the conditional branch instruction. Then determine the next address to be scanned (S116), and judge whether the instruction at this address is a return instruction (such as RET) or a program end instruction (such as END) (S117). If the instruction at the next address is not a return instruction or a program end instruction, it is judged according to the second data table 40 whether the address is within the scanned address range ( S121 ). If the next address is not in the scanned address range, modify the second data table 40 to update the scanned address range ( S122 ), and continue to process the next instruction. If in step S117 the instruction of the next address is indeed a return instruction or a program end instruction, or in step S121 the next address is the scanned address range, then it is judged whether there is still an address to be scanned in the first data table 30 (S118). If there are still, then obtain an address to be scanned from the first data table 30 and remove it from the first data table 30 (S119), then modify the scanned address range in the second data table 40 (S122), Continue to process subsequent instructions of the address to be scanned. If there is no address to be scanned in the first data table 30, it means that all instructions have been scanned (S120). At this point, all the separable breakpoints have been obtained, and the instruction part and data/stack part in the original program code 20 can be judged. In FIG. 5 , the dotted box P1 represents the relevant steps for processing the branch type, and the dotted line box P2 represents the relevant steps for processing the loop type.

上述扫描过程中的处理动作,可以简要描述如下:(1)当所读取的指令为一条件分支指令(例如JNE、JE、JG等等)时,将条件分支指令的分支目地址或下一地址记录于第一数据表30中;(2)当完成读取一指令时,便更新第二数据表40的地址范围并且输出可分断点;(3)如果所读取的指令为一结束指令或返回指令或者是其地址在第二数据表40的地址范围内,只要第一数据表30的某个待扫描地址不属于第二数据表40的地址范围,便从第一数据表30的这个待扫描地址继续读取。The processing actions in the above-mentioned scanning process can be briefly described as follows: (1) when the read instruction is a conditional branch instruction (such as JNE, JE, JG, etc.), the branch destination address or the next address of the conditional branch instruction Recorded in the first data table 30; (2) when finishing reading an instruction, just update the address range of the second data table 40 and output the break point; (3) if the read instruction is an end instruction or Return instruction or its address is in the address range of the second data table 40, as long as a certain address to be scanned of the first data table 30 does not belong to the address range of the second data table 40, just from this waiting address range of the first data table 30 The scan address continues to read.

根据第5图所述的扫描程序,以下以一实例来说明其扫描的动作。第6图表示根据第5图扫描方法来处理一程序代码范例的示意图。其中,程序进入点为Q1。当从Q1扫描至Q2,读取到一个条件分支指令JNE,此时在第一数据表30中记录此条件分支指令JNE的分支目的地址Q6。当继续扫描至Q3时,则读取到一个非条件分支指令JMP。对于非条件分支指令JMP不需要储存其分支目的地址Q10,而是直接到其分支目的地址继续进行扫描。接着从Q10扫描到Q11,则依序读取到两个条件分支指令JG和JE。同样的,在第一数据表30则记录这两个指令的分支目的地址Q4和Q8后,继续进行扫描。当扫描到Q12时,读取到程序结束指令END,因此结束主程序段的扫描。此时,已扫描的区域包括C1、C2、C6、C7,而第一数据表30中则记录Q6、Q4和Q8的待扫描地址。接着,从第一个待扫描地址Q6继续进行扫描,直到Q7读取到返回指令RET为止。接着再从第二个待扫描地址Q4继续进行扫描,直到扫描到Q5,虽然并未读取到任何结束指令或是返回指令,不过其下一个地址Q6是属于已扫描区域,因此仍结束扫描。接着再从第三个待扫描地址Q8继续进行扫描,直到扫描到Q9。同样的,虽然并未读取到任何结束指令或是返回指令,不过其下一个地址Q10是属于已扫描区域,因此仍结束扫描。至此,第一数据表30中已经没有其它的待扫描地址,因此整个扫描工作完成。在扫描过程中,可以判断出所有的可分断点(即每一完整的指令的前后皆为可分断点),而且判断出C1-C7是属于指令部分,而D1-D3则属于数据或堆栈等非指令部分,并且当扫描完成但仍未被扫描到的一连续程序代码区段,可被视为一数据或堆栈等非指令区段。According to the scanning procedure described in FIG. 5 , an example is used below to illustrate its scanning operation. FIG. 6 is a schematic diagram of processing a program code example according to the scanning method of FIG. 5 . Among them, the program entry point is Q1. When scanning from Q1 to Q2, a conditional branch instruction JNE is read, and the branch destination address Q6 of the conditional branch instruction JNE is recorded in the first data table 30 at this time. When continuing to scan to Q3, an unconditional branch instruction JMP is read. The unconditional branch instruction JMP does not need to store its branch destination address Q10, but directly goes to its branch destination address to continue scanning. Then scan from Q10 to Q11, then read two conditional branch instructions JG and JE in sequence. Similarly, after the first data table 30 records the branch destination addresses Q4 and Q8 of the two instructions, the scan continues. When Q12 is scanned, the program end instruction END is read, so the scanning of the main program segment ends. At this time, the scanned areas include C1, C2, C6, and C7, and the addresses to be scanned of Q6, Q4, and Q8 are recorded in the first data table 30 . Next, continue scanning from the first address to be scanned Q6 until Q7 reads the return instruction RET. Then continue to scan from the second address Q4 to be scanned until Q5 is scanned. Although no end command or return command is read, the next address Q6 belongs to the scanned area, so the scan still ends. Then continue scanning from the third to-be-scanned address Q8 until Q9 is scanned. Similarly, although no end command or return command has been read, the next address Q10 belongs to the scanned area, so the scan still ends. So far, there are no other addresses to be scanned in the first data table 30, so the entire scanning work is completed. During the scanning process, it can be judged that all separable breakpoints (that is, every complete instruction is a separable breakpoint before and after), and it is judged that C1-C7 belong to the instruction part, while D1-D3 belong to data or stack, etc. The non-instruction part, and a continuous program code segment that has not been scanned after the scanning is completed, can be regarded as a non-instruction segment such as data or stack.

回到第4图,当完成原始程序代码20的扫描动作,便可以根据所得到的可分断点,在缺陷存储单元所对应的缺陷地址前后分别决定第一分断点和第二分断点(S13)。每一完整的指令之间或之前之后,皆为可分断点。第一分断点和第二分断点之间的指令部分(也可能包含数据/堆栈部分)称为区段程序代码,而区段程序代码需要被移动到其它的地址上,以避开缺陷地址。在本实施例中,第一分断点和第二分断点的决定方式,是选择以最接近缺陷地址但是与缺陷地址之间仍存在数个字节的分断点为准,亦即第一/第二分断点与缺陷地址之间仍存在数个良好的存储单元,可以用以储存连接指令(此点稍后详述)。在以下的描述中,均以此种情况为例进行说明。不过上述的分断点选择方式并非用以限定本发明。举例来说,第一/第二分断点也可以根据与缺陷地址间至少间隔数个可分断点的方式来选择。另外,如果后续的移动方式是采用将缺陷地址后的所有程序代码往下位移一定长度字节的方式,此时第一分断点可以根据在缺陷地址之前且与缺陷地址之间仍存在数个字节的方式来选择,而第二分断点则设在程序代码的最后,即该程序代码最后一个字节之后,而将缺陷地址附近及后方的程序代码设为需要移动的区段程序代码,而将该区段程序代码移至该缺陷地址之后,仍可以达到本发明的目的。Returning to Fig. 4, when the scanning action of the original program code 20 is completed, the first breaking point and the second breaking point can be respectively determined before and after the defective address corresponding to the defective memory unit according to the obtained separable breaking point (S13) . Between or before and after each complete instruction are separable breakpoints. The instruction part (may also include data/stack part) between the first breakpoint and the second breakpoint is called the segment program code, and the segment program code needs to be moved to other addresses to avoid the defect address. In this embodiment, the way to determine the first break point and the second break point is to select the break point closest to the defect address but still have several bytes between the defect address, that is, the first/second break point There are still several good storage units between the binary breakpoint and the defect address, which can be used to store connection instructions (this point will be described in detail later). In the following descriptions, this case is taken as an example for illustration. However, the above method of selecting the breaking point is not intended to limit the present invention. For example, the first/second breaking point can also be selected according to the distance between the defect address and the defect address by at least several breakable points. In addition, if the subsequent moving method is to shift all the program codes after the defect address down by a certain length of bytes, the first breakpoint can be based on the fact that there are still several words before the defect address and between the defect address. section, and the second breakpoint is set at the end of the program code, that is, after the last byte of the program code, and the program code near and behind the defect address is set as the segment program code that needs to be moved, and After moving the segment program code to the defect address, the object of the present invention can still be achieved.

决定第一分断点和第二分断点之间的区段程序代码之后,接着则可以将此区段程序代码移动到第一地址和第二地址之间(S14)。必须注意的是,缺陷地址不应该位于第一地址和第二地址之间,也就是区段程序代码在加载后的存储单元中不包含有缺陷存储单元。在完成区段程序代码的重新寻址后,如果被移动的区段程序代码包含指令部分,接着必须插入连接指令,让原始程序代码仍维持其程序执行顺序。在本实施例中,主要是插入两个无条件分支指令(JMP)来达成连接的目的。第一个无条件分支指令是插入于第一分断点的地址上,其分支目的地址是指向移动后的区段程序代码;第二个无条件分支指令是插入于移动后区段程序代码的后面,而其分支目的地址则是指向第二分断点的地址,但如果第二分断点的地址是设在程序代码的最后,则不需要该第二个无条件分支指令。因此,当程序代码执行到第一分断点地址上的指令(其为区段程序代码的开始部分)时,则会通过第一个无条件分支指令,跳到移动后的区段程序代码继续执行;当完成移动后区段程序代码的指令后,则通过第二个无条件分支指令跳回到第二分断点地址上的指令。另外,如果区段程序代码只是单纯的数据/堆栈部分,则不需要加入连接指令,只需要修改与其相关的参考地址即可。After determining the program code segment between the first breakpoint and the second breakpoint, the program code segment can be moved between the first address and the second address (S14). It must be noted that the defective address should not be located between the first address and the second address, that is, the segment program code does not contain defective memory cells in the loaded memory cells. After completing the re-addressing of the segment program code, if the moved segment program code contains instruction parts, then a link instruction must be inserted so that the original program code still maintains its program execution sequence. In this embodiment, two unconditional branch instructions (JMP) are mainly inserted to achieve the purpose of connection. The first unconditional branch instruction is inserted at the address of the first breakpoint, and its branch destination address points to the segment program code after the move; the second unconditional branch instruction is inserted behind the segment program code after the move, and Its branch destination address is the address pointing to the second breakpoint, but if the address of the second breakpoint is set at the end of the program code, then the second unconditional branch instruction is not needed. Therefore, when the program code is executed to the instruction on the first breakpoint address (which is the beginning part of the segment program code), it will jump to the moved segment program code to continue execution by the first unconditional branch instruction; After completing the instruction of the section program code after moving, then jump back to the instruction on the second breakpoint address by the second unconditional branch instruction. In addition, if the segment program code is only a simple data/stack part, there is no need to add connection instructions, only need to modify the reference address related to it.

第7图表示本实施例中连接移动后区段程序代码和原始程序代码未移动部分的示意图。如图所示,原始程序代码20包含了各程序代码A-G,而缺陷地址21则位于程序代码E内,在程序代码E的前后则分别决定出第一分断点和第二分断点。当移动程序代码E至新的地址范围内,即出现移动后的程序代码E’。符号51和52分别表示插入的第一个/第二个无条件分支指令。当程序代码D执行完成后,即通过第一个无条件分支指令跳到程序代码E’;当程序代码E’执行完成后,则再通过第二个无条件分支指令跳回程序代码F。因此,原始程序代码的程序执行顺序可以维持,仅需要多执行两个无条件分支指令即可。Fig. 7 shows a schematic diagram of connecting the moved section program code and the unmoved part of the original program code in this embodiment. As shown in the figure, the original program code 20 includes program codes A-G, and the defect address 21 is located in the program code E, and the first breakpoint and the second breakpoint are respectively determined before and after the program code E. When the program code E is moved to a new address range, the moved program code E' appears. Symbols 51 and 52 represent the inserted first/second unconditional branch instructions, respectively. After the program code D is executed, it jumps to the program code E' through the first unconditional branch instruction; after the program code E' is executed, it jumps back to the program code F through the second unconditional branch instruction. Therefore, the program execution sequence of the original program code can be maintained, and only two more unconditional branch instructions need to be executed.

当完成步骤S15的连接动作后,CPU1加载的前置动作已经大致完成,只剩下一般机器程序代码中常见的参考地址(reference address)还未处理。如果在原始程序代码20中的参考地址与移动后的区段程序代码有关,则必须进行检查和修正。因此,CPU1必须修正相关的参考地址(S16)。第8图表示在本实施例中修正参考地址的示意图。如图所示,原始程序代码20中有三种参考地址会与包含缺陷地址21的程序代码E有关,分别标示为R1、R2、R3。R1表示程序代码E中指令的参考地址指向程序代码E中地址的情况;R2表示其它程序代码(例如程序代码B)中指令的参考地址指向程序代码E中地址的情况;R3表示程序代码E中指令的参考地址指向其它程序代码(如程序代码B)的情况。这些参考地址必须在程序代码E移动后为程序代码E’后,修正其参考地址(如R1’,R2’,R3’),以便产生实际可以加载到内存3的机器程序代码60。After the connection action of step S15 is completed, the pre-loading action of the CPU1 has been roughly completed, leaving only the common reference address (reference address) in the general machine program code unprocessed. If the reference address in the original program code 20 is related to the moved section program code, it must be checked and corrected. Therefore, the CPU 1 must correct the relevant reference address (S16). Fig. 8 shows a schematic diagram of correcting reference addresses in this embodiment. As shown in the figure, there are three kinds of reference addresses in the original program code 20 that are related to the program code E including the defect address 21, which are respectively marked as R1, R2, and R3. R1 indicates that the reference address of the instruction in the program code E points to the address in the program code E; R2 indicates that the reference address of the instruction in other program codes (such as program code B) points to the address in the program code E; R3 indicates that in the program code E The reference address of the instruction points to other program codes (such as program code B). These reference addresses must be modified into the program code E' after the program code E is moved, and its reference addresses (such as R1', R2', R3') must be corrected so as to produce the machine program code 60 that can actually be loaded into the internal memory 3.

要修正参考地址,CPU1可对于整个原始程序代码20进行再次扫描,以便找出与包含缺陷地址的区段程序代码相关的参考地址。另外,一般参考地址又可以细分为两种寻址模式(addressing mode),分别为相对地址寻址模式(relative addressing mode)和绝对地址寻址模式(absolute addressing mode)。如果与上述三种参考地址情况一并考虑,则共有六种类型。在R1的参考地址中,只有绝对地址寻址模式的参考地址才需要修正。在R3的参考地址中,只有相对地址寻址模式的参考地址才需要修正。而在R2的参考地址中则相对及绝对地址都需要修正。当修正上述绝对地址寻址模式的参考地址时(均是指向区段程序代码E),则在此参考地址中加入程序代码E和移动后程序代码E’之间的相对位移量即可。若要修正上述相对地址寻址模式的参考地址,亦可以利用程序代码E和移动后程序代码E’之间的相对位移量来达成。不过相对地址寻址模式一般在使用上有其限制,亦即相对地址通常会限定在一定范围内,因此在处理相对地址寻址模式上会较为复杂。例如,本实施例中在缺陷地址21的前后都预留相当数量的可用存储单元,则可以利用此部分插入连接的指令而间接达到相同的效果;另外,也可以选择将缺陷地址21后面的所有程序代码往后方(即较高地址的方向)位移数个字节,以便避开缺陷存储单元,如此也可以避免因一区段程序代码移动过远以致超过相对地址寻址模式范围的困扰;另一种解决方式则是调整编辑器的编码格式,例如尽量采用绝对地址而避免使用相对地址进行编码,或将因一区段程序代码移动过远而受影响的相对地址的寻址码改为绝对地址寻址码。To correct the reference address, the CPU 1 can scan the entire original program code 20 again to find the reference address related to the program code section containing the defective address. In addition, the general reference address can be subdivided into two addressing modes, which are relative addressing mode and absolute addressing mode. If considered together with the above three reference address situations, there are six types in total. Among the reference addresses of R1, only the reference addresses of the absolute address addressing mode need to be corrected. Among the reference addresses of R3, only the reference addresses of the relative address addressing mode need to be corrected. In the reference address of R2, both relative and absolute addresses need to be corrected. When correcting the reference address of the above-mentioned absolute address addressing mode (both pointing to the segment program code E), then add the relative displacement between the program code E and the moved program code E' to the reference address. To modify the reference address of the above-mentioned relative address addressing mode, it can also be achieved by using the relative displacement between the program code E and the moved program code E'. However, the relative address addressing mode generally has its limitations in use, that is, the relative address is usually limited to a certain range, so it is more complicated to deal with the relative address addressing mode. For example, in this embodiment, a considerable number of usable storage units are reserved before and after the defective address 21, and this part can be used to insert connected instructions to indirectly achieve the same effect; The program code is shifted to the rear (ie, the direction of the higher address) by several bytes in order to avoid the defective storage unit, which can also avoid the trouble that a segment of the program code moves too far beyond the range of the relative address addressing mode; One solution is to adjust the encoding format of the editor, such as using absolute addresses as much as possible to avoid using relative addresses for encoding, or changing the addressing codes of relative addresses affected by the movement of a section of program code to absolute Address addressing code.

当完成上述的前置处理,CPU1的加载器便可以将原始程序代码、连接指令和移动后的区段程序代码加载到内存3中,完成所有的步骤(S17)。由于原本会占用缺陷存储单元的区段程序代码已经被移动,因此程序代码可以正常的执行和操作。When the above-mentioned pre-processing is completed, the loader of the CPU 1 can load the original program code, the connection instruction and the moved section program code into the memory 3 to complete all the steps (S17). Because the segment program code that would have occupied the defective storage unit has been moved, the program code can be executed and operated normally.

另外,上述说明虽然是以单一缺陷存储单元为例,但是对于熟习此技艺者而言,可以延伸应用到多个缺陷存储单元的情况,其基本处理模式仍然相同。另外,本实施例中虽然是以字节的扫描方式来决定出可分断点,但对于熟习此技艺者而言,也可以将原始程序代码加以模块化(modularized)以方便决定可分断点。此时不需要执行如本实施例中所描述的扫描动作,便可以利用较简单的扫描程序决定出缺陷地址前后的第一分断点和第二分断点。In addition, although the above description takes a single defective memory cell as an example, for those skilled in the art, it can be extended to the case of multiple defective memory cells, and the basic processing mode is still the same. In addition, although the detachable breakpoint is determined by byte scanning in this embodiment, for those skilled in the art, the original program code can also be modularized to conveniently determine the detachable breakpoint. At this time, there is no need to perform the scanning action described in this embodiment, and a relatively simple scanning procedure can be used to determine the first breakpoint and the second breakpoint before and after the defect address.

以上所揭露的局部缺陷内存的处理方法和系统,虽是以一般计算机系统为例,不过其最佳的应用范例应是在单芯片系统(system-on-a-chip)或单芯片计算机(single chip computer)上。在这类系统中,内存模块一般是内建的(embedded),无法任意替换。在发现部分存储单元有缺陷的情况下,便可以利用本实施例中所揭露的方法,整个芯片在处理后仍然可以正常执行程序代码。另外,本实施例中所揭露的局部缺陷内存亦可以适用在烧录程序的应用上,例如快擦写存储器(flash memory)或是电子可抹式PROM(electricallyerasable programmable read-only memory)的程序烧录上,即使局部存储单元有缺陷,仍然可以使用。最重要的是,本实施例在实施上并不会增加硬件设计的成本和复杂度,而对于软件执行时的负担也比现有技术来得轻。由此可知,本发明具有极高的产业利用价值。Although the processing method and system of the local defect memory disclosed above are taken as an example of a general computer system, its best application example should be in a single-chip system (system-on-a-chip) or a single-chip computer (single chip computer). chip computer). In such systems, the memory modules are generally embedded and cannot be replaced arbitrarily. In the case that some memory cells are found to be defective, the method disclosed in this embodiment can be used, and the entire chip can still execute program codes normally after processing. In addition, the local defect memory disclosed in this embodiment can also be applied to the application of programming programs, such as program programming of flash memory (flash memory) or electronically erasable programmable read-only memory (PROM). Recorded, even if the local storage unit is defective, it can still be used. Most importantly, the implementation of this embodiment does not increase the cost and complexity of hardware design, and the burden on software execution is lighter than that of the prior art. It can be seen that the present invention has extremely high industrial application value.

第二实施例:Second embodiment:

虽然第一实施例中已揭露一定程序的处理方式,可以解决局部缺陷内存的问题,但是其间仍有部分程序可以变更。例如,本实施例则是对于第一实施例改变其原始程序代码的扫描处理方式以及加载内存的顺序而产生。Although the processing method of a certain program has been disclosed in the first embodiment, which can solve the problem of partially defective memory, there are still some programs that can be changed. For example, this embodiment is produced by changing the scanning processing method of the original program code and the order of loading the memory from the first embodiment.

第9图表示第二实施例的局部缺陷内存处理方法的流程图。如第9图所示,一方面CPU1决定出缺陷存储单元的实体位置(S20)并且决定出缺陷存储单元在原始程序代码20中所对应的缺陷地址(S21),另一方面也对于原始程序代码20进行扫描(S22)。由步骤S20和步骤S21可以决定出缺陷存储单元的缺陷地址,而由步骤S22则可以决定出原始程序代码20中的可分断点。此同步处理可以适用于具有多任务功能的CPU或是多重CPU的系统中。接着根据缺陷地址以及可分断点的地址,便可以进一步决定出第一分断点和第二分断点(S23),也就是需要移动的区段程序代码范围。FIG. 9 shows a flow chart of the local defect memory processing method of the second embodiment. As shown in Figure 9, on the one hand, CPU1 determines the physical location of the defective storage unit (S20) and determines the corresponding defect address (S21) of the defective storage unit in the original program code 20; 20 performs scanning (S22). The defect address of the defective storage unit can be determined by step S20 and step S21, and the divisible break point in the original program code 20 can be determined by step S22. This synchronization processing can be applied to a CPU with multi-tasking function or a system with multiple CPUs. Then, according to the address of the defect and the address of the breakable point, the first breakpoint and the second breakpoint can be further determined ( S23 ), that is, the code range of the segment to be moved.

接着的步骤顺序则与第一实施例不同。先将整个原始程序代码20加载到内存3中(S24),此时包含缺陷地址的区段程序代码亦会加载到缺陷存储单元相邻的存储单元中,不过由于其中包含缺陷存储单元,因此这部分的区段程序代码并不会实际使用。接着,再次加载此区段程序代码到内存3中的第一存储单元和第二存储单元之间(S25),而在第一存储单元和第二存储单元之间则不包含缺陷存储单元。接着则与第一实施例相同,插入连接指令以便连接区段程序代码和原始程序代码20中的其它部分(S26),并且修正其中的参考地址(S27)。与第一实施例一样,此时在内存3中的程序代码是可以正常执行的,并且实际执行的程序代码不会储存到缺陷存储单元内。The sequence of the next steps is different from that of the first embodiment. First load the entire original program code 20 into the internal memory 3 (S24). At this time, the segment program code including the defective address will also be loaded into the storage unit adjacent to the defective storage unit, but because it contains the defective storage unit, this Some section codes are not actually used. Next, load the section program code again between the first storage unit and the second storage unit in the memory 3 (S25), and there is no defective storage unit between the first storage unit and the second storage unit. Then, as in the first embodiment, a connection instruction is inserted to connect the segment program code with other parts in the original program code 20 (S26), and the reference address therein is corrected (S27). Like the first embodiment, the program code in the memory 3 can be executed normally at this time, and the actually executed program code will not be stored in the defective storage unit.

在第二实施例中,是先分别加载原始程序代码20和移动后的区段程序代码,再进行连接以及修正参考地址的处理。此样的处理方式除了可以达到第一实施例相同的效果外,还可以得到较佳的处理效率。一般原始程序代码的来源大都是外部储存媒介,例如硬盘机、软盘机等等。要执行连接动作以及修正参考地址等处理时,在处理速度上较内存3来得慢,特别是在修正参考地址时,必须再次对于整个原始程序代码3进行扫描。而在本实施例中,所有待处理的程序代码均已被加载于内存3中,因此可以更快地完成上述的处理步骤。另外,原始程序代码亦可储存于一已知无缺陷的内存中,如ROM,RAM或PROM,可加快上述程序代码扫描的速度,不过此方式需要将该原始程序代码暂时或长久存放于另外的良好内存,或一内存中已确定不含缺陷存储单元的部分。In the second embodiment, the original program code 20 and the moved section program code are firstly loaded, and then the connection and reference address correction are performed. In addition to achieving the same effect as the first embodiment, such a processing method can also obtain better processing efficiency. Generally, the source of the original program code is mostly an external storage medium, such as a hard disk drive, a floppy disk drive, and the like. When performing connection actions and modifying reference addresses, the processing speed is slower than that of the memory 3, especially when modifying the reference addresses, the entire original program code 3 must be scanned again. However, in this embodiment, all the program codes to be processed have been loaded in the memory 3, so the above processing steps can be completed more quickly. In addition, the original program code can also be stored in a known non-defective memory, such as ROM, RAM or PROM, which can speed up the scanning speed of the above program code, but this method needs to temporarily or permanently store the original program code in another Good memory, or a portion of a memory that has been determined to be free of defective memory cells.

第三实施例:Third embodiment:

第一和第二实施例是适用于原始程序代码还未加载内存中的情况,此时CPU(微处理器)可以在原始程序代码还未加载内存前即施以前置处理,以便调整程序代码来避开缺陷存储单元。而本实施例所要处理的情况,则是当原始程序代码已经成功地加载内存中,但是部分存储单元在一段时间后却显示功能弱化的现象。这些功能弱化的存储单元目前虽然可以正常读取,但是在一定时间之后,从其读出的逻辑值就会变得越来越难以辨认。此时必须对于内存内的原始程序代码内容加以调整,以避开这些功能弱化的缺陷存储单元。The first and second embodiments are applicable to the situation that the original program code has not been loaded into the internal memory. At this time, the CPU (microprocessor) can perform pre-processing before the original program code is loaded into the internal memory, so as to adjust the program code to Avoid defective memory cells. However, the situation to be dealt with in this embodiment is the phenomenon that the original program code has been successfully loaded into the memory, but some storage units show weakened functions after a period of time. These degraded memory cells can be read normally at present, but after a certain period of time, the logic value read from them will become increasingly illegible. At this time, the original program code content in the memory must be adjusted to avoid these defective storage units with weakened functions.

第10图表示第三实施例的局部缺陷内存处理系统的配置图。如第10图所示,此时原始程序代码20已经加载于内存3中。而在系统操作过程中,则可以通过CPU1本身或其它外部的处理器或测试器,周期性地对于内存3中的每个存储单元进行测试。如果在测试中某个存储单元所读出的数据已经越来越难以辨认时,则CPU1即设定此存储单元为缺陷存储单元,并且执行本实施以下所揭露的处理方法,以便停止使用功能弱化的缺陷存储单元。Fig. 10 shows a configuration diagram of a local defect memory processing system of the third embodiment. As shown in FIG. 10, the original program code 20 has been loaded in the memory 3 at this moment. During system operation, the CPU 1 itself or other external processors or testers can periodically test each storage unit in the memory 3 . If the data read out by a certain storage unit during the test has become more and more difficult to identify, then CPU1 sets this storage unit as a defective storage unit, and executes the processing method disclosed below in order to stop using the weakened function. defective memory cells.

第11图表示第三实施例的局部缺陷内存处理方法的流程图。如第11图所示,原始程序代码20已经存在于内存3中(S30)。此时,一方面CPU1可以对于原始程序代码20进行扫描(S31),得到原始程序代码20中的所有可分断点;另一方面也对于内存3进行周期性测试并且决定出其中功能弱化的缺陷存储单元(S32)。由于原始程序代码20已经加载于内存3,因此可以根据缺陷存储单元很快地判断出对应的缺陷地址。接着根据缺陷地址以及所有可分断点的地址,便可以进一步决定出第一分断点和第二分断点(S33),也就是需要移动的区段程序代码范围。FIG. 11 shows a flow chart of the local defect memory processing method of the third embodiment. As shown in Fig. 11, the original program code 20 already exists in the memory 3 (S30). At this time, on the one hand, CPU1 can scan (S31) the original program code 20 to obtain all divisible breakpoints in the original program code 20; unit (S32). Since the original program code 20 has been loaded into the memory 3, the corresponding defective address can be quickly determined according to the defective storage unit. Then, according to the address of the defect and the addresses of all the breakpoints, the first breakpoint and the second breakpoint can be further determined ( S33 ), that is, the range of the segment program code that needs to be moved.

先在内存3中找出一段功能正常的内存区块(即第一存储单元和第二存储单元之间),以便容纳需要移动的区段程序代码。接着将此区段程序代码复制到第一存储单元和第二存储单元之间(S34)。接着则与第一实施例相同,插入连接指令以便连接区段程序代码和原始程序代码20中的其它部分(S35),并且修正其中的参考地址(S36)。此时在内存3中的程序代码是可以正常执行的,并且实际执行的程序代码不会储存到功能弱化的缺陷存储单元内。First find out a section of memory block with normal function (that is, between the first storage unit and the second storage unit) in the memory 3, so as to accommodate the section program code that needs to be moved. Then copy the section program code between the first storage unit and the second storage unit (S34). Next, as in the first embodiment, a link instruction is inserted to link the segment program code with other parts of the original program code 20 (S35), and the reference address therein is corrected (S36). At this time, the program code in the memory 3 can be executed normally, and the actually executed program code will not be stored in the defective storage unit with weakened functions.

另外,如上述内存中含多个并不相邻的缺陷存储单元,亦可应用本发明产生数组与这些缺陷存储单元相对应的可分断点组,而将这些可分断点组间的数个程序代码区段移至数个不同的新地址,并做相关的参考地址的更正,以产生一个在执行时可避开这些缺陷存储单元的更改过的程序代码。In addition, if the above-mentioned internal memory contains a plurality of non-adjacent defective storage units, the present invention can also be applied to generate an array of separable breakpoint groups corresponding to these defective memory units, and several programs between these separable breakpoint groups The code segment is moved to several different new addresses, and the associated reference address corrections are made to produce a modified program code that avoids these defective memory locations when executed.

本发明虽以一较佳实施例揭露如上,然其并非用以限定本发明,任何熟习此项技艺者,在不脱离本发明的精神和范围内,当可做少量的更动与润饰,因此本发明的保护范围当视权利要求并结合说明书和附图为准。Although the present invention is disclosed above with a preferred embodiment, it is not intended to limit the present invention. Anyone skilled in this art can make a small amount of changes and modifications without departing from the spirit and scope of the present invention. Therefore The scope of protection of the present invention should be determined by the claims in combination with the specification and drawings.

Claims (52)

1.一种将程序代码加载内存以供执行的方法,适用于包含多个存储单元的一内存和待加载于上述内存的一原始程序代码,其特征是:其包括下列步骤:1. A method for loading program code into memory for execution, applicable to a memory comprising a plurality of storage units and an original program code to be loaded in said memory, characterized in that: it comprises the following steps: 决定上述内存是否包含缺陷存储单元;determining whether said memory contains defective memory cells; 当上述内存不包含缺陷存储单元时,则加载上述原始程序代码至上述内存;When the above-mentioned memory does not contain defective storage units, then load the above-mentioned original program code into the above-mentioned memory; 当上述内存包含至少一缺陷存储单元时,则执行下列步骤:When the memory includes at least one defective storage unit, the following steps are performed: 扫描上述原始程序代码,在上述缺陷存储单元所对应于上述原始程序代码的一缺陷地址前后,决定第一分断点和第二分断点;Scanning the above-mentioned original program code, before and after a defect address corresponding to the above-mentioned original program code in the above-mentioned defective storage unit, determine a first breaking point and a second breaking point; 移动上述第一分断点和上述第二分断点之间的区段程序代码,至第一地址和第二地址之间,上述第一地址和上述第二地址之间的地址皆不对应于上述内存的上述缺陷地址;Move the section program code between the above-mentioned first breakpoint and the above-mentioned second breakpoint to between the first address and the second address, and the addresses between the above-mentioned first address and the above-mentioned second address do not correspond to the above-mentioned memory The above defect address of ; 当上述区段程序代码包含至少一可执行的指令时,提供一连接指令,用以连接移动后的上述区段程序代码与上述原始程序代码中未移动部分的执行顺序;以及When the segment program code includes at least one executable instruction, a connection instruction is provided to connect the execution sequence of the moved segment program code and the unmoved part of the original program code; and 加载上述原始程序代码中未移动部分、上述连接指令和移动后的上述区段程序代码至上述内存中。Loading the unmoved part of the above original program code, the above connection instruction and the moved above section program code into the above memory. 2.如权利要求1所述的将程序代码加载内存以供执行的方法,其特征是:还包括一步骤:2. The method for loading program code into memory for execution as claimed in claim 1, characterized in that: it also includes a step: 修正上述区段程序代码与上述原始程序代码中未移动部分之间的参考地址。Correct the reference address between the above section program code and the unmoved portion of the above original program code. 3.如权利要求2所述的将程序代码加载内存以供执行的方法,其特征是:上述修正步骤是用以修正移动后的上述区段程序代码对于上述原始程序代码中未移动部分的相对寻址模式参考地址,以及修正上述原始程序代码中未移动部分对于移动后的上述区段程序代码的相对寻址模式参考地址以及绝对寻址模式参考地址。3. The method for loading program code into memory for execution as claimed in claim 2, characterized in that: said correcting step is used to correct the relative difference between the moved section program code and the unmoved part in the above-mentioned original program code The addressing mode reference address, and the relative addressing mode reference address and the absolute addressing mode reference address of the unmoved portion of the above-mentioned original program code relative to the moved above-mentioned segment program code. 4.如权利要求2所述的将程序代码加载内存以供执行的方法,其特征是:还包括一步骤:4. The method for loading program code into memory for execution as claimed in claim 2, characterized in that: it also includes a step: 修正移动后的上述区段程序代码内的绝对寻址模式参考地址。Correct the absolute addressing mode reference address in the program code of the above segment after moving. 5.如权利要求1所述的将程序代码加载内存以供执行的方法,其特征是:其中扫描上述原始程序代码的步骤中还包括下列步骤:5. The method for loading program code into memory for execution as claimed in claim 1, wherein the step of scanning the above-mentioned original program code also includes the following steps: 依序读取上述原始程序代码;Read the above original program code in sequence; 依据上述原始程序代码中各指令组成,输出多个可分断点;以及According to the composition of each instruction in the above original program code, output a plurality of separable breakpoints; and 根据上述缺陷地址和插入的上述连接指令,决定上述第一分断点和上述第二分断点。The first breaking point and the second breaking point are determined based on the defect address and the inserted connection command. 6.如权利要求5所述的将程序代码加载内存以供执行的方法,其特征是:依序读取上述原始程序代码的步骤中还包括下列步骤:6. The method for loading program codes into memory for execution as claimed in claim 5, wherein the step of reading the original program codes in sequence also includes the following steps: 提供一第一数据表和一第二数据表,上述第一数据表用以记录上述原始程序代码中条件分支指令的分支目的地址,上述第二数据表用以记录已读取的地址范围;Provide a first data table and a second data table, the above-mentioned first data table is used to record the branch destination address of the conditional branch instruction in the above-mentioned original program code, and the above-mentioned second data table is used to record the read address range; 当所读取的指令为一条件分支指令时,记录上述条件分支指令的分支目的地址于上述第一数据表;When the read instruction is a conditional branch instruction, recording the branch destination address of the conditional branch instruction in the first data table; 当完成读取一指令时,更新上述第二数据表的地址范围;以及When finishing reading an instruction, update the address range of the above-mentioned second data table; and 当所读取的指令为一结束指令或其地址在上述第二数据表的地址范围内时,并且当上述第一数据表的分支目的地址不属于上述第二数据表的地址范围时,则根据上述第一数据表的分支目的地址继续读取。When the read instruction is an end instruction or its address is within the address range of the above-mentioned second data table, and when the branch destination address of the above-mentioned first data table does not belong to the address range of the above-mentioned second data table, then according to the above The branch destination address of the first data table continues to be read. 7.如权利要求1所述的将程序代码加载内存以供执行的方法,其特征是:上述连接步骤中,是插入第一无条件分支指令于上述第一分断点的地址上,上述第一无条件分支指令的目的地址为上述区段程序代码移动后的第一地址,并且插入第二无条件分支指令于上述区段程序代码移动后的第二地址,上述第二无条件分支指令的目的地址为上述第二分断点。7. The method for loading program code into memory for execution as claimed in claim 1, characterized in that: in the above-mentioned connecting step, the first unconditional branch instruction is inserted at the address of the first breakpoint, and the first unconditional The destination address of the branch instruction is the first address after the section program code is moved, and a second unconditional branch instruction is inserted into the second address after the section program code is moved, and the destination address of the second unconditional branch instruction is the above-mentioned first address. Bipartite breakpoint. 8.如权利要求1所述的将程序代码加载内存以供执行的方法,其特征是:上述第二分断点是在上述原始程序代码的最后一个字节之后。8. The method for loading program code into memory for execution as claimed in claim 1, wherein the second breaking point is after the last byte of the original program code. 9.一种内存处理系统,用以处理一包含多个存储单元的内存,其特征是:其包括:9. A memory processing system for processing a memory comprising a plurality of storage units, characterized in that: it comprises: 一微处理器,耦接于上述内存,用以加载一原始程序代码,当上述原始程序代码被加载的存储单元皆为无缺陷存储单元时,则加载上述原始程序代码于上述内存,当上述原始程序代码被加载的存储单元包含至少一缺陷存储单元时,则扫描上述原始程序代码,在上述缺陷存储单元所对应于上述原始程序代码的一缺陷地址前后,决定第一分断点和第二分断点,并且移动上述第一分断点和上述第二分断点之间的区段程序代码至第一地址和第二地址之间,并且当上述区段程序代码包含至少一可执行的指令时,提供一连接指令,用以连接上述区段程序代码与上述原始程序代码中未移动部分的执行顺序,并且加载上述原始程序代码中未移动部分、上述连接指令和移动后的上述区段程序代码至上述内存中,其中上述第一地址和上述第二地址之间的程序代码所对应的内存地址不包含上述缺陷地址。A microprocessor, coupled to the above-mentioned memory, is used to load an original program code. When the storage units to which the above-mentioned original program code is loaded are all non-defective storage units, then load the above-mentioned original program code into the above-mentioned memory. When the above-mentioned original program code When the storage unit where the program code is loaded includes at least one defective storage unit, the original program code is scanned, and the first breakpoint and the second breakpoint are determined before and after a defective address corresponding to the original program code in the defective storage unit , and move the segment program code between the first breakpoint and the second breakpoint to between the first address and the second address, and when the segment program code contains at least one executable instruction, provide a A connection instruction, used to connect the execution order of the above-mentioned section program code and the unmoved part of the above-mentioned original program code, and load the unmoved part of the above-mentioned original program code, the above-mentioned connection instruction and the above-mentioned section program code after moving to the above-mentioned memory , wherein the memory address corresponding to the program code between the above-mentioned first address and the above-mentioned second address does not include the above-mentioned defective address. 10.如权利要求9所述的内存处理系统,其特征是:上述第二分断点是在上述原始程序代码的最后一个字节之后。10. The memory processing system according to claim 9, wherein the second breaking point is after the last byte of the original program code. 11.如权利要求9所述的内存处理系统,其特征是:上述微处理器还修正移动后的上述区段程序代码与上述原始程序代码中未移动部分之间的参考地址,以及移动后的上述区段程序代码内的参考地址。11. The memory processing system as claimed in claim 9, characterized in that: said microprocessor also revises the reference address between the moved portion of the program code and the unmoved portion of the original program code, and the moved The reference address within the program code of the above section. 12.如权利要求9所述的内存处理系统,其特征是:上述微处理器的连接动作中,是插入第一无条件分支指令于上述第一分断点的地址上,上述第一无条件分支指令的目的地址为上述区段程序代码移动后的第一地址,并且插入第二无条件分支指令于上述区段程序代码移动后的第二地址,上述第二无条件分支指令的目的地址为上述第二分断点。12. The memory processing system as claimed in claim 9, characterized in that: in the connection action of the above-mentioned microprocessor, the first unconditional branch instruction is inserted on the address of the first breakpoint, and the first unconditional branch instruction The destination address is the first address after the section program code is moved, and a second unconditional branch instruction is inserted into the second address after the section program code is moved, and the destination address of the second unconditional branch instruction is the second breakpoint . 13.如权利要求9所述的内存处理系统,其特征是:上述内存和上述微处理器是置于同一芯片内。13. The memory processing system according to claim 9, wherein said memory and said microprocessor are placed in the same chip. 14.如权利要求9所述的内存处理系统,其特征是:上述内存和上述微处理器是置于独立的不同芯片内。14. The memory processing system as claimed in claim 9, characterized in that: the above-mentioned memory and the above-mentioned microprocessor are placed in different independent chips. 15.一种防治局部弱化内存处理方法,适用于已载负一原始程序代码的一内存,其特征是:其包括下列步骤:15. A method for preventing and treating local weakened memory, suitable for a memory loaded with an original program code, characterized in that it comprises the following steps: 检查上述内存,用以找出上述内存中功能弱化的缺陷存储单元;Examining the above-mentioned memory to find defective storage units with weakened functions in the above-mentioned memory; 当上述内存中包含至少一功能弱化的存储单元,则执行下列步骤:When the above-mentioned memory contains at least one storage unit with weakened function, the following steps are performed: 扫描上述原始程序代码,在上述缺陷存储单元对应于上述原始程序代码的一缺陷地址前后,决定第一分断点和第二分断点;Scanning the original program code, determining a first breakpoint and a second breakpoint before and after a defect address of the defective storage unit corresponding to the original program code; 移动上述第一分断点和上述第二分断点之间的区段程序代码,至上述内存中的第一存储单元和第二存储单元之间,上述第一存储单元和上述第二存储单元之间不包含上述缺陷存储单元;以及Move the section program code between the above-mentioned first breakpoint and the above-mentioned second breakpoint to between the first storage unit and the second storage unit in the above-mentioned internal memory, between the above-mentioned first storage unit and the above-mentioned second storage unit does not contain the defective memory cells described above; and 当上述区段程序代码包含至少一可执行的指令时,连接移动后的上述区段程序代码与上述原始程序代码中未移动部分的执行顺序。When the segment program code includes at least one executable instruction, link the execution sequence of the moved segment program code and the unmoved portion of the original program code. 16.如权利要求15所述的防治局部弱化内存处理方法,其特征是:上述第二分断点是在上述原始程序代码的最后一个字节之后。16. The memory processing method for preventing local weakening as claimed in claim 15, characterized in that: the second breaking point is after the last byte of the original program code. 17.如权利要求15所述的防治局部弱化内存处理方法,其特征是:还包括一步骤:17. The method for preventing and treating local weakened memory as claimed in claim 15, characterized in that: it also includes a step: 修正移动后的上述区段程序代码与上述原始程序代码中未移动部分之间的参考地址。Correct the reference address between the above-mentioned section program code after moving and the unmoved part of the above-mentioned original program code. 18.如权利要求17所述的防治局部弱化内存处理方法,其特征是:上述修正步骤是用以修正移动后的上述区段程序代码对于上述原始程序代码中未移动部分的相对寻址模式参考地址,以及修正上述原始程序代码中未移动部分对于移动后的上述区段程序代码的相对寻址模式参考地址以及绝对寻址模式参考地址。18. The memory processing method for preventing local weakening as claimed in claim 17, characterized in that: the above-mentioned correction step is used to correct the relative addressing mode reference of the moved portion of the program code to the unmoved part of the above-mentioned original program code The address, and the relative addressing mode reference address and the absolute addressing mode reference address of the unmoved portion of the above original program code relative to the moved above segment program code are corrected. 19.如权利要求18所述的防治局部弱化内存处理方法,其特征是:还包括一步骤:19. The method for preventing and treating local weakened memory as claimed in claim 18, characterized in that: it also includes a step: 修正移动后的上述区段程序代码内的绝对寻址模式参考地址。Correct the absolute addressing mode reference address in the program code of the above segment after moving. 20.如权利要求15所述的防治局部弱化内存处理方法,其特征是:扫描上述原始程序代码的步骤中还包括下列步骤:20. The memory processing method for preventing local weakening as claimed in claim 15, characterized in that: the step of scanning the above-mentioned original program code also includes the following steps: 依序读取上述原始程序代码;Read the above original program code in sequence; 依据上述原始程序代码中各指令组成,输出多个可分断点;以及According to the composition of each instruction in the above original program code, output a plurality of separable breakpoints; and 根据上述缺陷地址和插入的上述连接指令,决定上述第一分断点和上述第二分断点。The first breaking point and the second breaking point are determined based on the defect address and the inserted connection command. 21.如权利要求20所述的防治局部弱化内存处理方法,其特征是:依序读取上述原始程序代码的步骤中还包括下列步骤:21. The memory processing method for preventing local weakening as claimed in claim 20, characterized in that: the step of reading the above-mentioned original program code in order also includes the following steps: 提供一第一数据表和一第二数据表,上述第一数据表用以记录上述原始程序代码中条件分支指令的分支目的地址,上述第二数据表用以记录已读取的地址范围;Provide a first data table and a second data table, the above-mentioned first data table is used to record the branch destination address of the conditional branch instruction in the above-mentioned original program code, and the above-mentioned second data table is used to record the read address range; 当所读取的指令为一条件分支指令时,记录上述条件分支指令的分支目的地址于上述第一数据表;When the read instruction is a conditional branch instruction, recording the branch destination address of the conditional branch instruction in the first data table; 当完成读取一指令时,更新上述第二数据表的地址范围;以及When finishing reading an instruction, update the address range of the above-mentioned second data table; and 当所读取的指令为一结束指令或其地址在上述第二数据表的地址范围内时,并且当上述第一数据表的分支目的地址不属于上述第二数据表的地址范围时,则根据上述第一数据表的分支目的地址继续读取。When the read instruction is an end instruction or its address is within the address range of the above-mentioned second data table, and when the branch destination address of the above-mentioned first data table does not belong to the address range of the above-mentioned second data table, then according to the above The branch destination address of the first data table continues to be read. 22.如权利要求15所述的防治局部弱化内存处理方法,其特征是:上述连接步骤中,是插入第一无条件分支指令于上述第一分断点的地址上,上述第一无条件分支指令的目的地址为上述区段程序代码移动后的第一存储单元,并且插入第二无条件分支指令于上述区段程序代码移动后的第二存储单元之后,上述第二无条件分支指令的目的地址为上述第二分断点。22. The memory processing method for preventing local weakening as claimed in claim 15, characterized in that: in the above-mentioned connecting step, the first unconditional branch instruction is inserted at the address of the first breakpoint, and the purpose of the first unconditional branch instruction The address is the first storage unit after the section program code is moved, and a second unconditional branch instruction is inserted after the second storage unit after the section program code is moved, and the destination address of the second unconditional branch instruction is the second breaking point. 23.一种内存处理系统,用以处理一包含多个存储单元并且已储存一原始程序代码的内存,其特征是:其包括:23. A memory processing system for processing a memory comprising a plurality of storage units and having stored an original program code, characterized in that it comprises: 一微处理器,耦接于上述内存,用以检查上述内存的存储单元是否有功能弱化的存储单元,当上述弱化的存储单元存在并且已储存上述原始程序代码时,则扫描上述原始程序代码,在上述弱化的存储单元对应于上述原始程序代码的一弱化地址前后,决定第一分断点和第二分断点,并且移动上述第一分断点和上述第二分断点之间的区段程序代码至上述内存中的第一存储单元和第二存储单元之间,并且当上述区段程序代码包含至少一可执行的指令时,连接移动后的上述区段程序代码与上述原始程序代码中未移动部分的执行顺序,其中上述第一存储单元和上述第二存储单元之间不包含上述缺陷存储单元。A microprocessor, coupled to the above-mentioned memory, is used to check whether the storage unit of the above-mentioned memory has a weakened storage unit, and when the weakened storage unit exists and has stored the above-mentioned original program code, then scan the above-mentioned original program code, Before and after the weakened storage unit corresponds to a weakened address of the original program code, determine a first breakpoint and a second breakpoint, and move the section program code between the first breakpoint and the second breakpoint to Between the first storage unit and the second storage unit in the above-mentioned internal memory, and when the above-mentioned section program code contains at least one executable instruction, connect the moved section of the above-mentioned program code and the unmoved part of the above-mentioned original program code The execution sequence of , wherein the defective storage unit is not included between the first storage unit and the second storage unit. 24.如权利要求23所述的内存处理系统,其特征是:上述第二分断点是在上述原始程序代码的最后一个字节之后。24. The memory processing system as claimed in claim 23, wherein the second breaking point is after the last byte of the original program code. 25.如权利要求23所述的内存处理系统,其特征是:上述微处理器是直接耦接于上述内存。25. The memory processing system as claimed in claim 23, wherein the microprocessor is directly coupled to the memory. 26.如权利要求23所述的内存处理系统,其特征是:上述微处理器还修正移动后的上述区段程序代码与上述原始程序代码中未移动部分之间的参考地址,以及移动后的上述区段程序代码内的参考地址。26. The memory processing system as claimed in claim 23, characterized in that: said microprocessor also revises the reference address between the moved portion of the program code and the unmoved portion of the original program code, and the moved The reference address within the program code of the above section. 27.如权利要求23所述的内存处理系统,其特征是:上述微处理器的连接动作中,是插入第一无条件分支指令于上述第一分断点的地址上,上述第一无条件分支指令的目的地址为上述区段程序代码移动后的第一存储单元,并且插入第二无条件分支指令于上述区段程序代码移动后的第二存储单元,上述第二无条件分支指令的目的地址为上述第二分断点。27. The memory processing system as claimed in claim 23, characterized in that: in the connection action of the above-mentioned microprocessor, the first unconditional branch instruction is inserted on the address of the first breakpoint, and the first unconditional branch instruction The destination address is the first storage unit after the section program code is moved, and a second unconditional branch instruction is inserted into the second storage unit after the section program code is moved, and the destination address of the second unconditional branch instruction is the above-mentioned second breaking point. 28.如权利要求23所述的内存处理系统,其特征是:上述内存和上述微处理器是置于是置于同一芯片内。28. The memory processing system as claimed in claim 23, wherein the memory and the microprocessor are placed in the same chip. 29.如权利要求23所述的内存处理系统,其特征是:上述内存和上述微处理器是置于是置于独立的不同芯片内。29. The memory processing system as claimed in claim 23, characterized in that: said memory and said microprocessor are placed in different independent chips. 30.一种内存处理方法,适用于包含多个存储单元的一内存和待加载于上述内存的一原始程序代码,其特征是:其包括下列步骤:30. A memory processing method, applicable to a memory comprising a plurality of storage units and an original program code to be loaded into the memory, characterized in that it comprises the following steps: 决定上述内存是否包含缺陷存储单元;determining whether said memory contains defective memory cells; 当上述内存不包含缺陷存储单元或上述原始程序代码不被加载于上述内存中缺陷存储单元所对应的缺陷地址时,则加载上述原始程序代码至上述内存;When the above-mentioned memory does not contain a defective storage unit or the above-mentioned original program code is not loaded in the defective address corresponding to the defective storage unit in the above-mentioned memory, then load the above-mentioned original program code into the above-mentioned memory; 当上述原始程序代码被加载上述内存内至少一缺陷存储单元所对应的缺陷地址时,则执行下列步骤:When the above-mentioned original program code is loaded into the defective address corresponding to at least one defective storage unit in the above-mentioned memory, the following steps are performed: 扫描上述原始程序代码,在上述缺陷存储单元所对应于上述原始程序代码的一缺陷地址前后,决定第一分断点和第二分断点;Scanning the above-mentioned original program code, before and after a defect address corresponding to the above-mentioned original program code in the above-mentioned defective storage unit, determine a first breaking point and a second breaking point; 加载上述原始程序代码至上述内存中;loading the above original program code into the above memory; 加载上述第一分断点和上述第二分断点之间的区段程序代码,至第一存储单元和第二存储单元之间,上述第一存储单元和上述第二存储单元之间不包含上述缺陷存储单元;以及Load the section program code between the above-mentioned first breakpoint and the above-mentioned second breakpoint to between the first storage unit and the second storage unit, and the above-mentioned defect is not included between the above-mentioned first storage unit and the above-mentioned second storage unit storage unit; and 当上述区段程序代码包含至少一可执行的指令时,连接位于上述第一存储单元和第二存储单元之间的上述区段程序代码与上述原始程序代码中其它部分的执行顺序。When the segment program code includes at least one executable instruction, link the execution sequence of the segment program code located between the first storage unit and the second storage unit with other parts of the original program code. 31.如权利要求30所述的内存处理方法,其特征是:还包括一步骤:31. The memory processing method according to claim 30, further comprising a step of: 修正位于上述第一存储单元和第二存储单元之间的上述区段程序代码与上述原始程序代码中其它部分之间的参考地址。Correcting the reference address between the section program code located between the first storage unit and the second storage unit and other parts of the original program code. 32.如权利要求31所述的内存处理方法,其特征是:上述修正步骤是用以修正位于上述第一存储单元和第二存储单元之间的上述区段程序代码对于上述原始程序代码中其它部分的相对寻址模式参考地址,以及修正上述原始程序代码中其它部分对于位于上述第一存储单元和第二存储单元之间的上述区段程序代码的相对寻址模式参考地址以及绝对寻址模式参考地址。32. The memory processing method as claimed in claim 31, characterized in that: said modifying step is used to correct the above-mentioned section program code between the above-mentioned first storage unit and the second storage unit for other parts of the above-mentioned original program code. Part of the relative addressing mode reference address, and modify the relative addressing mode reference address and absolute addressing mode of other parts of the above original program code for the above-mentioned segment program code located between the above-mentioned first storage unit and the second storage unit Reference address. 33.如权利要求32所述的内存处理方法,其特征是:还包括一步骤:33. The memory processing method according to claim 32, further comprising a step of: 修正位于上述第一存储单元和第二存储单元之间的上述区段程序代码内的绝对寻址模式参考地址。Modifying the absolute addressing mode reference address in the segment program code located between the first storage unit and the second storage unit. 34.如权利要求30所述的内存处理方法,其特征是:扫描上述原始程序代码的步骤中还包括下列步骤:34. The memory processing method as claimed in claim 30, characterized in that: the step of scanning the above-mentioned original program code also includes the following steps: 依序读取上述原始程序代码;Read the above original program code in sequence; 依据上述原始程序代码中各指令组成,输出多个可分断点;以及According to the composition of each instruction in the above original program code, output a plurality of separable breakpoints; and 根据上述缺陷地址和插入的上述连接指令,决定上述第一分断点和上述第二分断点。The first breaking point and the second breaking point are determined based on the defect address and the inserted connection command. 35.如权利要求34所述的内存处理方法,其特征是:依序读取上述原始程序代码的步骤中还包括下列步骤:35. The memory processing method as claimed in claim 34, characterized in that: the step of reading the above-mentioned original program code in order also includes the following steps: 提供一第一数据表和一第二数据表,上述第一数据表用以记录上述原始程序代码中条件分支指令的分支目的地址,上述第二数据表用以记录已读取的地址范围;Provide a first data table and a second data table, the above-mentioned first data table is used to record the branch destination address of the conditional branch instruction in the above-mentioned original program code, and the above-mentioned second data table is used to record the read address range; 当所读取的指令为一条件分支指令时,记录上述条件分支指令的分支目的地址于上述第一数据表;When the read instruction is a conditional branch instruction, recording the branch destination address of the conditional branch instruction in the first data table; 当完成读取一指令时,更新上述第二数据表的地址范围;以及When finishing reading an instruction, update the address range of the above-mentioned second data table; and 当所读取的指令为一结束指令或其地址在上述第二数据表的地址范围内时,并且当上述第一数据表的分支目的地址不属于上述第二数据表的地址范围时,则根据上述第一数据表的分支目的地址继续读取。When the read instruction is an end instruction or its address is within the address range of the above-mentioned second data table, and when the branch destination address of the above-mentioned first data table does not belong to the address range of the above-mentioned second data table, then according to the above The branch destination address of the first data table continues to be read. 36.如权利要求30所述的内存处理方法,其特征是:上述连接步骤中,是插入第一无条件分支指令于上述第一分断点的地址上,上述第一无条件分支指令的目的地址为上述区段程序代码的第一存储单元,并且插入第二无条件分支指令于上述区段程序代码的第二存储单元,上述第二无条件分支指令的目的地址为上述第二分断点。36. The memory processing method according to claim 30, characterized in that: in the connecting step, the first unconditional branch instruction is inserted at the address of the first breaking point, and the destination address of the first unconditional branch instruction is the above-mentioned The first storage unit of the segment program code, and inserting a second unconditional branch instruction into the second storage unit of the segment program code, the destination address of the second unconditional branch instruction is the second breakpoint. 37.一种内存处理系统,用以处理一包含多个存储单元的内存,其特征是:其包括:37. A memory processing system for processing a memory comprising a plurality of storage units, characterized in that it comprises: 一微处理器,耦接于上述内存,用以加载一原始程序代码,当上述原始程序代码被加载的存储单元包含至少一缺陷存储单元时,则该系统能扫描上述原始程序代码,且在上述缺陷存储单元所对应于上述原始程序代码的一缺陷地址前后,决定第一分断点和第二分断点,并且加载上述原始程序代码至上述内存中以及加载上述第一分断点和上述第二分断点之间的区段程序代码至第一存储单元和第二存储单元之间,并且当上述区段程序代码包含至少一可执行的指令时,连接位于上述第一存储单元和第二存储单元之间的上述区段程序代码与上述原始程序代码中其它部分的执行顺序,其中上述第一存储单元和上述第二存储单元之间不包含上述缺陷存储单元。A microprocessor, coupled to the above-mentioned memory, is used to load an original program code. When the storage unit where the above-mentioned original program code is loaded contains at least one defective storage unit, the system can scan the above-mentioned original program code, and in the above-mentioned Determining a first breakpoint and a second breakpoint before and after a defective address corresponding to the original program code in the defective storage unit, and loading the original program code into the memory and loading the first breakpoint and the second breakpoint The segment program code between the first storage unit and the second storage unit, and when the segment program code contains at least one executable instruction, the connection is between the first storage unit and the second storage unit The execution order of the above segment program code and other parts of the above original program code, wherein the defective storage unit is not included between the first storage unit and the second storage unit. 38.如权利要求37所述的内存处理系统,其特征是:上述第二分断点是在上述原始程序代码的最后一个字节之后。38. The memory processing system as claimed in claim 37, wherein the second breaking point is after the last byte of the original program code. 39.如权利要求37所述的内存处理系统,其特征是:上述微处理器还修正位于上述第一存储单元和第二存储单元之间的上述区段程序代码与上述原始程序代码中其它部分之间的参考地址,以及位于上述第一存储单元和第二存储单元之间的上述区段程序代码内的参考地址。39. The memory processing system as claimed in claim 37, characterized in that: said microprocessor also revises said section program code and other parts in said original program code between said first storage unit and second storage unit The reference address between, and the reference address in the section program code located between the first storage unit and the second storage unit. 40.如权利要求37所述的内存处理系统,其特征是:上述微处理器的上述连接动作中,是插入第一无条件分支指令于上述第一分断点的地址上,上述第一无条件分支指令的目的地址为上述区段程序代码的第一存储单元,并且插入第二无条件分支指令于上述区段程序代码的第二存储单元,上述第二无条件分支指令的目的地址为上述第二分断点。40. The memory processing system as claimed in claim 37, characterized in that: in the above-mentioned connection operation of the above-mentioned microprocessor, a first unconditional branch instruction is inserted on the address of the first breakpoint, and the first unconditional branch instruction The destination address of the above-mentioned segment program code is the first storage unit, and a second unconditional branch instruction is inserted into the second storage unit of the above-mentioned segment program code. The destination address of the second unconditional branch instruction is the second break point. 41.如权利要求37所述的内存处理系统,其特征是:上述内存和上述微处理器是置于是置于同一芯片内。41. The memory processing system according to claim 37, characterized in that: said memory and said microprocessor are placed in the same chip. 42.如权利要求37所述的内存处理系统,其特征是:上述内存和上述微处理器是置于是置于独立的不同芯片内。42. The memory processing system as claimed in claim 37, characterized in that: said memory and said microprocessor are placed in different independent chips. 43.一种程序代码扫描处理方法,用以决定一原始程序代码的可分断点,其特征是:上述程序代码扫描处理方法包括下列步骤:43. A program code scanning processing method for determining a separable breaking point of an original program code, characterized in that: the above program code scanning processing method includes the following steps: 提供一第一数据表和一第二数据表,上述第一数据表用以记录上述原始程序代码中的条件分支指令相关的待扫描地址,上述第二数据表用以记录已读取的地址范围;Provide a first data table and a second data table, the first data table is used to record the address to be scanned related to the conditional branch instruction in the original program code, and the second data table is used to record the read address range ; 依序读取上述原始程序代码;Read the above original program code in sequence; 当所读取的指令为一条件分支指令时,记录上述条件分支指令相关的待扫描地址于上述第一数据表,并且依上述条件分支指令的下一地址或分支目的地址继续扫描;When the read instruction is a conditional branch instruction, record the address to be scanned related to the conditional branch instruction in the above-mentioned first data table, and continue scanning according to the next address or branch destination address of the above-mentioned conditional branch instruction; 随指令的读取,更新上述第二数据表的地址范围,并且当完成读取至少一完整指令时,输出可分断点;以及updating the address range of the second data table as the instruction is read, and outputting a detachable breakpoint when at least one complete instruction is read; and 当所读取的指令为一结束指令或其地址在上述第二数据表的地址范围内时,则根据上述第一数据表的一待扫描地址继续读取,并将该待扫描地址从上述第一数据表中除去。When the read command is an end command or its address is within the address range of the second data table, continue reading according to an address to be scanned in the first data table, and transfer the address to be scanned from the first Datasheet removed. 44.如权利要求43所述的程序代码扫描处理方法,其特征是:上述程序代码扫描处理方法是在一原始程序代码加载一内存时,决定可移动的区段程序代码。44. The program code scanning processing method according to claim 43, characterized in that: the program code scanning processing method is to determine the movable segment program code when an original program code is loaded into a memory. 45.如权利要求44所述的程序代码扫描处理方法,其特征是:上述内存包含至少一缺陷存储单元。45. The program code scanning processing method according to claim 44, wherein the memory includes at least one defective storage unit. 46.如权利要求43所述的程序代码扫描处理方法,其特征是:上述条件分支指令相关的待扫描地址为上述条件分支指令的分支目的地址。46. The program code scanning processing method according to claim 43, wherein the address to be scanned related to the conditional branch instruction is the branch destination address of the conditional branch instruction. 47.如权利要求43所述的程序代码扫描处理方法,其特征是:上述条件分支指令相关的待扫描地址为上述条件分支指令的下一地址。47. The program code scanning processing method according to claim 43, wherein the address to be scanned related to the conditional branch instruction is the next address of the conditional branch instruction. 48.如权利要求43所述的程序代码扫描处理方法,其特征是:还包括一步骤:48. The program code scanning processing method as claimed in claim 43, further comprising a step of: 当所读取的指令为一无条件分支指令时,则由上述无条件分支指令的分支目的地址继续扫描。When the read instruction is an unconditional branch instruction, continue scanning from the branch destination address of the above unconditional branch instruction. 49.如权利要求43所述的程序代码扫描处理方法,其特征是:当上述所读取的指令为一结束指令或其地址在上述第二数据表的地址范围内,且上述第一数据表中无待扫描地址时,则结束扫描。49. The program code scanning processing method according to claim 43, characterized in that: when the read command is an end command or its address is within the address range of the second data table, and the first data table When there is no address to be scanned, the scan ends. 50.如权利要求43所述的程序代码扫描处理方法,其特征是:当扫描结束时,将仍未被扫描到的一连续程序代码地址判定为一数据程序代码区段。50. The program code scanning processing method according to claim 43, characterized in that: when the scanning ends, a continuous program code address that has not been scanned is determined as a data program code segment. 51.如权利要求43所述的程序代码扫描处理方法,其特征是:当扫描结束时,将仍未被扫描到的一连续程序代码地址判定为一数据或堆栈程序代码区段。51. The program code scanning processing method according to claim 43, characterized in that: when the scanning ends, a continuous program code address that has not been scanned is determined as a data or stack program code segment. 52.如权利要求43所述的程序代码扫描处理方法,其特征是:当扫描结束时,将仍未被扫描到的一连续程序代码地址判定为一非指令区段。52. The program code scanning processing method according to claim 43, characterized in that: when the scanning ends, a continuous program code address that has not been scanned is determined as a non-command segment.
CNB011104082A 2001-04-02 2001-04-02 Method and system for processing local defect memory Expired - Fee Related CN1168005C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB011104082A CN1168005C (en) 2001-04-02 2001-04-02 Method and system for processing local defect memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB011104082A CN1168005C (en) 2001-04-02 2001-04-02 Method and system for processing local defect memory

Publications (2)

Publication Number Publication Date
CN1378139A CN1378139A (en) 2002-11-06
CN1168005C true CN1168005C (en) 2004-09-22

Family

ID=4658575

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB011104082A Expired - Fee Related CN1168005C (en) 2001-04-02 2001-04-02 Method and system for processing local defect memory

Country Status (1)

Country Link
CN (1) CN1168005C (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6901498B2 (en) * 2002-12-09 2005-05-31 Sandisk Corporation Zone boundary adjustment for defects in non-volatile memories

Also Published As

Publication number Publication date
CN1378139A (en) 2002-11-06

Similar Documents

Publication Publication Date Title
CN1232912C (en) Non volatile memory control method
CN1265396C (en) Mixed packing semiconductor integrate circuit device of controller mass storage and measuring method
CN1229724C (en) External storage device and data processing method
CN1145972C (en) Automatic detection method and detection circuit of random access memory
CN1409323A (en) Method and device for detecting information of memory
US9086961B2 (en) Repair method and device for abnormal-erase memory block of non-volatile flash memory
CN1596401A (en) Control method of non-volatile memory device
CN101042938A (en) Redundancy-function-equipped semiconductor memory device made from ecc memory
CN101075213B (en) ROM data patch circuit, embedded system including the same and method of patching ROM data
EP3392885B1 (en) Non-volatile memory repair circuit
JP2003338197A (en) Self-repair method for nonvolatile memory device with erasing/programming failure, and relative nonvolatile memory device
US20010032327A1 (en) System and method of processing memory
CN1691202A (en) Semiconductor memory device having code bit cell array
CN1435758A (en) Memory, data processing method and data processing program
CN1307534C (en) Branch control system of microcomputer device and related method
TWI587302B (en) Memory programming methods and memory devices
CN1168005C (en) Method and system for processing local defect memory
CN1489766A (en) Method and device for analyzing and repairing memory
CN1209707C (en) Memory processing method and processing system
TW449685B (en) Handling method and system for partial defective memory
JP2008251154A (en) Nonvolatile semiconductor memory device
JP5815212B2 (en) Data writing method and system
US6370655B1 (en) Method and system for reversed-sequence code loading into partially defective memory
US7203867B2 (en) Processor system, processor and arithmetic processing method
JP2010079686A (en) Data processor, memory control circuit, and memory control method

Legal Events

Date Code Title Description
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C06 Publication
PB01 Publication
C14 Grant of patent or utility model
GR01 Patent grant
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20040922