What's the mechanism or structure responsible for new species genetic code generation?
I strongly advice to have a look at an introductory source of information on evolutionary biology (such as Understanding Evolution by UC Berkeley). It will give you much more information.

Locus and Allele

Here are two definitions to start with:


A locus is a location on a chromosome. This location can be of any size. It can be a single nucleotide, a codon, a whole gene or even longer.
An allele is one variant at a given locus. When considering relatively short loci (say 1 nucleotide or 1 base pair (bp)), then the majority of loci have only one allele.


What is evolution?

Evolution is defined as any change in allele frequency in a population over time.

There are a number of "forces" that affect evolutionary processes. I picked the 3 most commonly considered: Mutations, Natural Selection and genetic drift

Natural Selection

Natural Selection is the process by which variants of genes called alleles are selected and therefore increase in frequency. This selection result from a differential reproductive success.

Natural selection occurs whenever the three following conditions are respected


Individuals in a population varies in terms of a given trait
This trait has some (additive) heritability. Here is one of the several posts that explain the concept of heritability. It might be slightly a post that is a bit advanced for you though but shortly speaking it means that offspring are more similar to their parents more than they are to other non-kin individuals in the population.
The fitness varies (not necessarily linearly) as the trait varies.


Simple example:


In a population, there are blue pens and red pens
Reproduction is asexual and blue pens create other blue pens while red pens create other red pens.
blue pens make more offspring than red pens.


In such situation natural selection occurs yielding the frequency of the blue pens to increase in the population while the frequency of red pens will decrease.

You may want to have a look at this post (although it might be too advanced) to understand the concept of heritability.

Mutations

In the broad sense mutation is any change in the DNA sequence. Some changes are more likely to happen that other but in any case the likeliness of these changes to happen is not dependent on the consequence they will have on the phenotype (shortly speaking, phenotype is how an individual looks like) and on the reproductive success. So mutations occur randomly and the specific mutation that would be needed in the population may not occur. Therefore saying, if a trait is needed (in the sense of "if a trait would be beneficial"), then a mutation will occur to make this trait existing is wrong. Note that most mutations are deleterious (decrease the reproductive success) while few of them are beneficial (increase the reproductive success) and those that are beneficial are more likely to raise in frequency in the population.

Mutations can be a simple a "small change" such as nucleotide substitution, an nucleotide insertion and deletion or can be a "bigger change" such as a chromosomal duplication/deletion, a whole genome duplication and the duplication/deletion of a long sequence.

Mutations create the genetic variance on which natural selection selects the best variants. As a consequence natural selection decreases the genetic variance while mutations increases genetic variance.

Genetic drift

If the change in frequency of mutations would depend exclusively on natural selection, then I would not have said before that a beneficial mutation is more likely to raise in frequency but I would have said that a beneficial mutation will raise in frequency deterministically. An intuitive explanation of what is genetic drift can be found on this post. It will also allow you to understand why small population undergo more random change in frequency of their genes than are big population.