Many-Objective Cooperative Coevolutionary Linear Genetic Programming applied to the Automatic Microcontroller Program Generation

In this article, a methodology for the generation of programs in assembly language for microcontroller-based systems is proposed, applying a many-objective cooperative coevolutionary linear genetic programming based on the decomposition of a program into segments, which evolve simultaneously, collaborating with each other in the process. The starting point for the program generation is a table of input/output examples. Two methods of fitness evaluation are also proposed. When the objective is to find a binary combination, the authors propose fitness evaluation with an exhaustive search for the output of each bit of the binary combination in the genetic program. On the other hand, when the objective is to generate specific variations of the logical values in the pins of the microcontroller’s port, the authors propose calculating the fitness, comparing the timing diagrams generated by the genetic program with the desired timing diagrams. The methodology was tested in the generation of drivers for the 4x4 matrix keyboard and character LCD module devices. The experimental results demonstrate that for certain tasks, the use of the proposed method allows for the generation of programs capable of competing with programs written by human programmers. Keywords—Many-objective optimization; cooperative coevolution; linear genetic programming; program synthesis; microcontroller-based systems


I. INTRODUCTION
A microcontroller is an integrated circuit with the basic characteristics of a computer.Microcontrollers perform specific tasks in various types of hardware, from generalconsumption electronic hardware to industrial electronic hardware.There are microcontrollers of different architectures currently on the market: Intel 8051, Microchip PIC, Atmel AVR, ARM Holdings ARM, etc.In the current research project, an 8-bit 8051 architecture is employed, which is frequently used in embedded systems.For the tests, an AT89S52 microcontroller, belonging to this architecture, was utilized.
The electronic circuit within which the microcontroller functions is called a ‗microcontroller-based system' (MBS) or an ‗embedded system'.Depending on the function that it performs, the MBS includes other peripheral devices such as matrix keyboard, LCD screen, physical-magnitude sensors, switches, etc.During the functioning of a MBS, the microcontroller's central processing unit (CPU) executes the programs stored in machine language in the program memory.
The development process of a MBS includes the design of the hardware (the electronic circuitry of the MBS) and the software (the program that will execute the CPU of the microcontroller).Very frequently, the time invested in the elaboration of the software is an important fraction of the total development time of the system [1].As mentioned in [2], when the developed software becomes more and more complex and its management becomes more difficult, the necessity arises to possess tools, which permit the generation of programs.
Program synthesis is a topic that has attracted the attention of many researchers.According to [3], the most common techniques that are currently used in program synthesis are: stochastic search, enumerative search, constraint solving, and programming based on deduction through examples.In the present project, a methodology is developed that permits one to generate automatically programs for the microcontroller in certain frequent tasks in MBSs, such as the scanning of matrix keyboard and the character display on the LCD module.
For the solution of complex problems, multiobjective optimization algorithms or cooperative co-evolutionary algorithms can be used.The former seek to minimize or maximize several objectives at the same time, such as the recent algorithm called Multi-Objective Grasshopper Optimization Algorithm (MOGOA), which is described in [4].The latter divide the problem into subcomponents that evolve in parallel collaborating with each other, for instance the algorithm named Multi-Modal Optimization Enhanced Cooperative Coevolution (MMO-CC) explained in [5].For the synthesis of programs for the MBSs we propose to establish several objectives, each of which corresponds to a bit of the result, and we also divide the program into segments that evolve in parallel.The proposed methodology is based on the application of the many-objective cooperative co-evolutionary linear genetic programming (MaOCCLGP), which is classified as a stochastic-synthesis technique.
Linear genetic programming (LGP) has been widely used in computer program generation for the solution of different problems, for example, symbolic regression problems [6], [7], robotic problems [8], [9], control problems [10], [11], etc.In the literature, research projects having to do with the www.ijacsa.thesai.orgapplication of LGP in program generation for microcontrollers are scant.In [12] LGP is applied in the automatic synthesis of programs in assembly language for the Microchip PIC18F452 microcontroller in optimal-time control problems.In [13] the authors describe the generation of the 4x3 matrix keyboard scanning program, the initialization program of the LCD screen and the character display program on LCD screen using classical multiobjective LGP following the EMOEA and NSGA II algorithms.It is concluded that the application of the NSGA II algorithm in the generation of the LCD screen drivers is not satisfactory.
The novel contribution of the present project is the application of the MaOCCLGP in the generation of microcontroller programs for specific tasks of peripheral device management: 4x4 matrix keyboard scanning and display of the two-digit decimal number on the LCD module.These problems are considered more complex than those solved in the paper [13].The performance of the proposed methodology has been evaluated by comparing the results produced by MaOCCLGP with the results of the application of EMOEA in the generation of the mentioned programs.Also, the programs generated by MaOCCLGP have been compared with those written by a human programmer.
The subsequent sections are organized in the following way: In Section II, the theoretical fundamentals necessary to be able to understand the proposed methodology are summarized.In Section III, the problem is laid out.In Section IV, the methodology for the automatic synthesis of programs for microcontrollers is formulated.In Section V, the experimental results and validation are analyzed.In Section VI conclusions regarding the research conducted, as well as recommendations for future research are given.

A. Linear Genetic Programming
Genetic programming, introduced by John Koza [14], is a technique that uses the principles of Charles Darwin's theory of evolution in order to produce automatically programs that perform a defined task.Linear genetic programming is a variant of genetic programming, which evolves sequences of instructions in an imperative-programming language or machine language.
The control parameters for the synthesis of a program with LGP are: register quantity, initial values of the registers, program size, and population size.In [15] some important conclusions relative to the control parameters are established: a small number of working registers can produce lack of fluency in the genetic program, while a very large number of working registers can unnecessarily increase the search space.It is recommended to start the registers with the input values instead of putting in constant values.Evolving programs of a fixed length is not recommended because this would not permit one to optimize the program size.For the population size, there is no special recommendation.In the current research project, the premise that large populations permit a greater diversity but require more processing time has been considered.For this reason, the authors tried to take large populations, taking precaution that the evolution time was not too great.

B. Many-Objective Evolutionary Optimization
In this work, in the generation of programs for microcontrollers, many-objective genetic programming is used.Toward this end, first, a general proposal of the multi-objective optimization problem and its relationship with the programgeneration problem will be explained.
In multi-objective optimization, two or more objectives, which in some cases could be in conflict, are optimized simultaneously [16], [17].In the K-objective optimization problem, the vector ( ) is searched for, which satisfies the inequality restrictions ( ) ( ) and the equality restrictions ( ) ( ) , and minimizes or maximizes the objective function ( ) ( ( ) ( ) ( ) ) , where ( ) is the decision vector of n variables, and each one of the objective functions f performs the mapping .
For the problem of the automatic synthesis of programs for microcontrollers, ( ) represents a program in machine language (instruction sequence).Given that the problem is confronted with the use of genetic programming, the objective function ( ) is the fitness function of the genetic program that indicates the degree of similarity between the input/output table that is generated after running the genetic program and the desired table of input/output examples.The multi-objective genetic programming algorithm looks to make the table generated equal to the one desired.When this occurs, the fitness function will have the highest value.Consequently, the multi-objective optimization will look to maximize the fitness function.
For the comparison of objective vectors, Pareto's dominance concept is used, and in the search for the solution, Pareto's optimality concept is employed.Given two solutions , , it is said that dominates in accordance with Pareto's dominance ( ) if the following conditions are met: On the contrary, it is said that is a non-dominated solution with respect to .A decision vector is Paretooptimal if there is not another vector , such that dominates .The set of Pareto's optimal vectors is also named Pareto front.
The method of solving multi-objective optimization problems using evolutionary algorithms is known by the name of ‗multi-objective evolutionary optimization'.
Multi-objective evolutionary algorithms are oriented for working toward a maximum of three objectives [18].When the quantity of objectives is greater than three, it is recommended to apply algorithms that go by the name of ‗many-objective evolutionary algorithms', better known by the abbreviation MaOEA.In the two problems studied in the present work, the number of objectives is seven.
In order to overcome the problems presented by an increase in objectives, there are different methods available [19].One of www.ijacsa.thesai.orgthese methods is based on the use of aggregation functions in order to differentiate solutions for many objectives.In the present work, the ‗individual information aggregation' method is used.In the fitness function, the degree of similarity between the input/output table generated and the one desired will be diminished by a value proportional to the program size.In this way, the objective function will permit the differentiation of solutions.At the same time, its maximization will help to reduce the program size.

C. Cooperative Coevolution
Another way to solve complex problems by way of evolutionary algorithms is to use ‗cooperative coevolution'.The cooperative coevolution algorithm (CCEA), which was formulated by Potter [20], is based on the -divide and conquer‖ strategy, and it consists of decomposing the initial problem into subcomponents, also called species, which evolve in parallel while collaborating amongst each other in the process.In a CCEA in order to calculate the fitness of an individual of a species, a complete solution is formed, combining the individual with the representatives selected from other species.
In the present work, the authors apply cooperative coevolution in the synthesis of programs for microcontrollers, for which several species are formed.Each species corresponds to a program segment.In order to form a complete solution, individuals taken from each species are concatenated (one individual per species, as is shown in Fig. 1).

D. Microcontroller based Systems (MBS)
The electronic circuitry of a MBS, depending on its application, includes other peripheral devices apart from the microcontroller that are connected to it through input/output lines.Each device possesses a way of managing and in some cases a complex protocol for communication with the microcontroller.
In the present work, in order to put the proposed methodology to the test, the MBS is composed of the microcontroller, a matrix keyboard connected to port P2 (Fig. 2), and a text LCD module connected to port P1 (Fig. 3).If one desires to connect the matrix keyboard to another port, it is necessary to verify that the port lines possess ‗pull-up' resistors.

III. FORMULATION OF THE PROBLEM
As the technique used in the proposed methodology is inductive programming, the starting point for the synthesis of a program is a table of input/output examples.The problem can be laid out, modifying the formulation given in [21], in the following manner: given a set of M input/output examples: The objective is to find a program P that correctly transforms all the examples: In this section, the problem is laid out regarding the generation of the matrix-keyboard scanning program and also that of the text-LCD-module display program.

A. Problem of Generation of 4x4 Matrix-Keyboard Scanning Program
In the 4x4 matrix keyboard of Fig. 2, the keys, represented as switches, have been numbered in hexadecimal code.In this system, when the user presses down on a key, the matrixkeyboard scanning program must identify the key, placing into the accumulator register (A) a binary combination which corresponds to the key pressed.The correspondence between the key number and the identifier is established in an input/output table.As an example, in Table 1, the identifiers of a 7-bit ASCII telephone keypad are shown.When there is not a key pressed, the identifier is 00h.It is assumed that only one key is pressed at a time or none.www.ijacsa.thesai.org No pressed key 00 0 0 0 0 0 0 0 Therefore, the problem is laid out in the following way: using the proposed methodology, a 4x4 matrix-keyboard scanning program is generated, which complies with the input/output table given in Table 1.
The generated program is compared to a human-written program whose algorithm obeys the following reasoning: the pins that control the rows are configured as inputs, while the pins that control the columns as outputs.Only one column is activated, putting -0‖ in the corresponding pin, while all the other columns are deactivated with -1‖.The activation of a column allows one to verify if some key of this column is pressed through the reading of the pin of each row.If the read value is -1‖, this means that the key is not pressed, and if the value is -0‖, the key is pressed.This process is repeated for each column.

B. Problem of Generation of Two-Digit BCD Number Display Program in the Text LCD Screen
The text liquid-crystal screen (LCD) is a device that permits the visualization of text messages, where each character is shown in a dot matrix with a standard size of 5x7 dots [22].Generally, the dots of the matrix darken in order to form the symbols.The control of the dot state of all screen matrices is carried out by a controller, which receives from the microcontroller the ASCII code of a character and displays it on the screen in the current position of the cursor.In this work, an LM016L text LCD screen is used, which has 2 lines of 16 characters per line, connected to port P1.
The LCD screen's signals, which are utilized for its connection with the microcontroller, are: the D7, D6, … , D0 data bus; and control signals E, RS, and R/W.Through the RS signal, the microcontroller indicates to the LCD screen if an instruction (RS=0) or a character (RS=1) is sent.With the R/W signal, the microcontroller determines the operation to run: reading (R/W=1) or writing (R/W=0).The E signal, called ‗data enabling', initiates the operation with a falling edge.
The LCD screen's connection with the microcontroller can be performed by way of an 8-bit or 4-bit data interface.In the present work, authors use the 4-bit interface in which only the D7, D6, D5, and D4 lines are employed.Through these lines, the 8-bit commands and characters are sent.First, the high nibble is sent and later the low nibble.For each nibble, a falling edge is generated in E signal.
The problem can be formulated in the following way: using the proposed methodology, a program is generated, which permits one to visualize in the text LCD screen the two-digit decimal number that is found in the accumulator in packed BCD code.In this case, the input/output table has 100 rows.The input values are the BCD numbers from 00h to 99h.The output values are the timing diagrams that must be generated in the port pins for the visualization of the two-digit decimal number.In the input/output table, the timing diagrams are represented as a decimal or hexadecimal number chain.
One characteristic of the problems laid out is that the generated program must precisely comply with 100% of the input/output table.This is a difference between the application of the LGP to device driver generation and the application of the LGP to symbolic regression problems, where the result generated by the synthesized program can be approximated.

IV. PROPOSED METHODOLOGY
The methodology is based on the application of the manyobjective cooperative co-evolutionary linear genetic programming, whose realization will be described in detail in this section.

A. Instruction Subset and Working Registers
The instruction set of the 8051-architecture-microcontroller CPU possesses 256 instructions, explained in the technical documentation of the microcontroller [24] [25], of which the instructions figuring in Table 2 will be used in the evolutionary process.In Table 2, it is observed that the used registers are: A (ACC o accumulator), B, R0, R7, and PX.PX is the register of input/output port P0, P1, P2, or P3, used in the peripheral device's connection.The registers A, B, and R0 function as working registers.The R7 register in genetic programs serves to store the input value with the objective that it can be retrieved by the working register.The operand #data is a number in a range from 0 to 255 called ‗immediate value'.The operand ‗bit address' is the address of a bit.In the evolutionary process, through bit addresses, the bits of the register A, B, and PX can be accessed.In the program's completion stage, the state register (PSW) is initialized.

B. Chromosome and Population Representation
Chromosome representation is very important in evolutionary algorithms.In LGP, the programs are represented by a linear sequence of instructions of an imperative programming language.For this work, an LGP chromosome representation with a dynamic size was adopted.www.ijacsa.thesai.orgAccording to [23], program synthesis using genetic programming presents two problems: epistasis and deceptiveness.Epistasis consists in the effects of the action of the instructions in a program being strongly interrelated.The deceptiveness pathology consists in the following: if the fitness is a scalar value, and there are two solutions with different fitness values, the solution with greater fitness is not necessarily the one that is closer to the correct solution.Selecting solutions only by the scalar fitness value can trap the search in a local optimum.In order to avoid the deceptiveness pathology, the authors use many-objective optimization, in which the fitness of an individual is a vector that will be used in the insertion of new individuals into the populations.What is more, in each species there will be two Pareto fronts, P1t and P2t, of variable size N1t and N2t, respectively.

C. Variation Operator
In each generation, each Pareto front will be kept sorted according to the sum value of fitness vector elements.In the selection of parents, (0.75•N1t + 0.25•N2t)•0.4parent couples are selected.Upon selecting a parent, its index in the list is found with the following formula: ) where N is the length of the list, the function trunc returns the integer smaller value of a real number, and a is a real random number uniformly distributed in the interval .Therefore, the result i has a greater probability of finding itself among the lower indices, where individuals of greater fitness are found.
Once the parent couples are selected, to each couple the variation operator is applied, which consists of: crossover (with 0.3 probability) or mutation (with 0.7 probability).The crossover operator consists of the exchange of tails (with 0.3 probability) or the exchange of instructions (with 0.7 probability).
In the crossover operation, the exchange of instructions is performed in randomly-selected positions of the parent sequences, and for the exchange of tails, the same position in the parent sequences is randomly selected.
In a sequence, the mutation is performed, with the same probability, in one of the following ways: 1) Removing a randomly-selected instruction.
3) Exchanging two consecutive instructions.4) Adding to the end of the sequence a randomlygenerated instruction.
5) Changing a randomly-selected instruction with a randomly-generated instruction.

D. Fitness Evaluation
From now on, , represents a genetic program.

1) Exhaustive fitness: When, in the table of input/output
examples, the output is a binary combination, the authors propose calculating the fitness through a search of the output of each bit of the binary combination after the execution of each instruction of the genetic program and in each bit of the working registers.This way of calculating the fitness has called ‗exhaustive fitness'.
In order to describe the exhaustive fitness evaluation, the authors use the representation of the input/output table of Fig. 4, where each column of the target output in binary representation is a combinational function, corresponding to a bit of the output combination.
In [26] a way of executing a genetic program in order to improve the output quality is proposed.The approach is oriented toward the genetic program based on trees.The authors apply part of this approach, taking into consideration that, in place of trees, there is a sequence of instructions P. The approach consists of forming a table in which each row corresponds to an instruction of the genetic program, and each column corresponds to a row of the input/output table.To this table, the name ‗register value matrix' (RVM) is given.

Target output (decimal or hexadecimal)
Target output in the binary representation  Inserting a MOV instruction after each instruction pointed by the BLM matrix in order to store the register that contains the result bit in the memory temporarily.
 Adding -MOV C, bit-address‖, -MOV bit-address, C‖ instructions in order to put the result bits together in the accumulator register.
 Adding instructions, before the synthesized sequence, in order to establish the initial values in registers A, B, R0, R7, PX, and PSW.

2) Fitness when the program generates timing diagrams according to input values:
In this case, the genetic program must generate determined timing diagrams in the pins of the microcontroller's port, depending on the accumulator-register value.For this purpose, it is necessary to evaluate the degree of similarity between the two timing diagrams.In Fig. 6, the comparison of the timing diagrams is illustrated, where the quantity of intervals along the timing diagrams is L=6.
In Fig. 7 the input/output table is represented, which determines the timing diagrams that must be generated depending on the input value that is in the accumulator.In this table, S j, d represents the timing diagrams in all pins of the port in interval d when the input is E j .If the number of pins where the timing diagrams are generated is K, then each value of the target timing diagram and each value of the generated timing diagram is expressed in the binary representation, where each bit corresponds to a port pin:

Input Target timing diagrams (decimal or hexadecimal)
In order to find the fitness vector of the timing diagrams generated by the genetic program, first the fitness vector is calculated for each input and each pin, determining the degree of similarity of the timing diagrams with the following formula: Where ( ) is the weight of the interval d.
Then the fitness for all inputs is calculated: Thus, for the fitness vector ( ) one also calculates the sum: For each input, there is a vector [ ] with the indices of instructions which produce the changes in the timing diagrams.For the input , the scalar ([ ]) is calculated, which is the index of the instruction that produced the last value in the timing diagram.Also, the effective size of the program is found: Based on all the vectors, the authors form the VDIF vector of size L, in which each element is equal to the difference between the maximum and minimum values of all the values in each vector position: Using and ( ) the fitness ( ) and its sum are calculated by the following equations: Algorithm 2 shows the fitness evaluation when timing diagrams are generated according to input values.
The evolutionary process upon maximizing minimizes NE and DIFmax.This means that program size is optimized.www.ijacsa.thesai.orgAt the end of the process, DIFmax must be zero, which ensures that the vectors of the instruction indices that produce the changes in the timing diagrams are equal for all inputs.
The structure of a generator with fitness evaluation when timing diagrams are generated is shown in Fig. 8.

Algorithm 2.
Fitness evaluation of the program that generates timing diagrams according to input values.S contains the target timing diagrams.for i = 0 to N-1 do 6.
end for 9.
For the input E j , f j is calculated with equation ( 7) 10.

E. Many-Objective Cooperative Co-evolutionary Linear Genetic Programming (MaOCCLGP)
In the MaOCCLGP algorithm, each program segment evolves like a species.In each species, there are two populations, P1t and P2t, which are non-dominated Pareto fronts and two auxiliary lists Qt and Dt.The algorithm begins by randomly generating populations P1t and P2t in each species (see Algorithm 3).Next, a determined quantity of representatives of each species is selected.The representatives are the best individuals on the P1t list, starting from the individual with index 0. Using the representatives, the fitness of individuals of each species is calculated.Each P1t and P2t list is sorted using the fopsuma value of each individual.
While the stop condition is not fulfilled, the following operations are performed: in each species, the representatives are selected; next, the parent individuals are selected, to which the variation operator is applied in order to obtain the descendants in list Qt; then, in each species the fitness of each individual of P1t, P2t, and Qt is evaluated; subsequently, in each species the best individuals of Qt in P1t are inserted, putting individuals cast aside in Dt; the best individuals of Dt in P2t are inserted; finally, P1t and P2t are sorted.
In the insertion operations, the algorithm described in [27] is followed, using the fop fitness of each individual in such a way that P1t and P2t are Pareto fronts.To maintain diversity a parent is taken from P1t with a probability of 0.75 or from P2t with a probability of 0.25.

Algorithm 3.
Many-Objective cooperative co-evolutionary linear genetic programming.The fitness evaluation is performed in the following manner: for example, if the quantity of species is 4 and the quantity of representatives in each species is 2, the representatives are denoted R00 and R01 of species 0, R10 and R11 of species 1, R20 and R21 of species 2, and R30 and R31 of species 3. Therefore, in order to evaluate the fitness of individual Ix of species 2, the fitness of each of the two programs is calculated, the first consisting of the concatenation of R00, R10, Ix, and R30, and the second of R01, R11, Ix, and R31.The fitness of Ix is the fop fitness of the program with greater fopsuma value.It is necessary to indicate that, in the given example, a total of eight different programs could be formed with representatives and the Ix individual.Nevertheless, due to processing time constraints, only two programs were formed.

V. RESULTS AND VALIDATION
To evaluate the performance of the methodology each generator was executed ten times with a limit number of evaluations (LNE).It is possible that in the evolutionary process, a program satisfies the input/output table before reaching the LNE limit.If this is the case, the generator continues running and optimizing the size of the synthesized program until reaching the LNE limit.
In order to analyze the results, the following criteria are used: hit rate (HR), minimum number of instructions (MNI), minimum code size after the compilation (number of bytes) (MCS), and minimum number of clock cycles (MNCC).
In [13], the EMOEA algorithm has been applied in the generation of the following programs: 1) 4x3 matrix keyboard scanning program, 2) initialization program of the LCD screen, and 3) character display on LCD module program.In the present work MaOCCLGP is applied in the generation of the programs: 1) 4x4 matrix keyboard scanning program, and 2) two-digit decimal number display on LCD module program.
The evaluation of the performance of the methodology proposed in this article has been carried out in two ways: 1) The EMOEA algorithm that was used in [13] has been applied to the two cases studied in the present work and has been compared with the application of MaOCCLGP.The results are shown in Table 3.
2) The programs generated by MaOCCLGP have been compared with programs written by human as shown in Table 4.In this case, the test parameters given in Table 5 were used.Human-written programs taken as a reference were elaborated following the algorithms described in microcontroller assembly language programming courses.
In Table 3, it can be seen that in the generation of the 4x4 matrix keyboard scanning program, the MaOCCLGP algorithm has a hit rate much higher than that of EMOEA.In the generation of the program for BCD number display on the LCD screen, the MaOCCLGP algorithm produced a smaller program.
In Table 4, it is observed that in the two analyzed cases, the hit rate is high (80%).Comparing the best generated keyboardscan program with the written by human program, it is observed that regarding minimum length, the generated program is 13% bigger than the human-written program.Regarding code size, the generated program is 3% bigger, and with regard to clock cycles, it is 71% more spread out.The difference between the minimum-length and code-size percentages is due to the fact that the human-written program makes use of conditional jump instructions, which possess 3 bytes.The significant difference between the minimum-length and clock-cycle-number percentages is due to the fact, that in the generated program all the instructions are executed.On the other hand, in the human-written program, due to the jump instructions, not all instructions are run.Upon comparing the generated program and the written by human program for BCD-number-display on LCD screen, it is observed that the human-written program has slightly-higher percentages in the three criteria of MNI 22%, MCS 2%, and MNCC 10%, which demonstrates the advantage of the generated program in the solution of this problem.In Table 6, examples of generated (P1, P3) and humanwritten programs (P2, P4) are shown.In the generated programs, the instructions in boldface were obtained as a result of the evolutionary process, while those in normal font were put into the program during the completion stage.All programs have been tested in the Proteus software from Labcenter Electronics.The programs that manage the LCD screen have been tested when the clock frequency of the microcontroller is 100 kHz.

VI. CONCLUSIONS AND SUGGESTIONS
In this work, a new method of generating programs in assembly language for microcontroller-based systems was described.The method uses many-objective cooperative coevolutionary linear genetic programming.
When the objective is to find a binary combination, for the fitness evaluation exhaustive fitness was proposed, which, for each bit of the binary combination, searches for an output in the genetic program at the bit level, permitting a faster convergence of the evolutionary algorithm.On the other hand, when the objective is to generate variations in the logical values in the pins of the microcontroller's input/output port, the fitness evaluation was proposed, which is based on the comparison of the generated timing diagrams with the target timing diagrams.
The methodology was tested for the 8051 architecture in two examples that are frequently found in microcontrollerbased systems: 4x4 matrix-keyboard scanning program and two-digit BCD-number display program on the text LCD screen.
The comparison of the generated and human-written programs for the case of BCD-number display on LCD screen shows an advantage of the generated program in the three analyzed criteria.This procedure possesses the following particularity: when it is human-written, it is developed in two stages.First, the BCD-code number is converted into ASCII code, and later the ASCII characters are displayed on the LCD screen.On the other hand, when the program is generated, the generator can carry out the task in a direct manner, without their explicitly being a conversion of the BCD code into ASCII code.
One disadvantage of the proposed methodology is that for certain cases the input/output table can be too big.In those cases, making use of the counterexamples-driven genetic programming, described in [28], is suggested for future research.
Based on the results shown in Table 4, it can be concluded that the microcontroller programs in assembly language, generated following the proposed methodology, are capable of competing with programs written by a human programmer in the solution of the specific tasks.However, it is necessary to point out that currently limitations exist, meaning that there are tasks for which the generator did not manage to produce a program that complies with 100% of the input/output table, for example, natural binary number display on LCD screen, which would be interesting area for future research to help improve the methodology.

Fig. 3 .
Fig. 3. LCD Module Connection with the Microcontroller with a 4-Bit Interface.

Fig. 7 .
Fig. 7. Representation of the Input/OutputTable when Timing Diagrams are Generated Depending on the Input Value.
value that can have fsum., is the program to evaluate.Pbest is the best program found until the moment with size NEbest and with fitness fbest 1. Delete(f) 2. for each input E j do 3. (A, B, R0, R7) ← Initial values; Ports ← Initial values; PSW ← 00H 4. Delete(Gj); Delete(VNIj) 5.

1. for each species do 2 .Fitness_evaluation 10 .
Random generation of P1t y P2t; 3. end for 4. Selection of representatives of each species 5. for each species do 6.while the stop condition is not reached do 11.best from Qt in P1t and those cast aside in Dt; 23.Insertion of the best from Dt in P2t 24.Sorting(P1t), Sorting(P2t) 25. end for 26.end while www.ijacsa.thesai.org

TABLE I .
INPUT/OUTPUT TABLE FOR THE 4X4 KEYBOARD

TABLE III .
COMPARISON OF THE PERFORMANCE OF THE EMOEA AND MAOCCLGP ALGORITHMS