Subject Computer Science Assembly Language Programming

Question

Genetic Algorithm Crossover Using MIPs
Biological processes are often used as a basis for computer science algorithms. In computer science a “Genetic Algorithm” is a group of algorithms used to search large spaces to optimize a problem. There are a wide variety of variations in the implementations, all of which depend on the problem you're trying to solve. For this assignment, you will implement a very small element of a Genetic Algorithm, recombination. Recombination is the process of constructing new chromosomes from specific segments of two selected parent chromosomes.
The most common type of recombination involves making two new chromosomes from the sequences of two selected parents. This is done by choosing a point in the two parent sequences, copying each gene up to the point, then swapping all the remaining genes. For instance, if the chosen point splits the parents in half, then the first half of Parent A is joined to the latter half of Parent B, while the first half of Parent B is joined to the latter half of Parent A. This creates two new offspring with the varying features of both parents.

Description:
In this assignment you will prompt the user to input from the keyboard two strings of characters, each of length 16, and an integer value representing the cross-over point (ranging from 0 thru 15). You will write code that performs the cross-over operation and then subsequently writes the output to the terminal. Use of at least 2 functions is required.

{SYSCALL}
A number of system services, mainly for input and output, are available for use by your MIPS program.
They are described in the table found under the syscalls tab of the MARS help page. MIPS register contents are not affected by a system call, except for result registers as specified in the help page.
How to use SYSCALL system services:
 Load the service number in register $v0.
 Load argument values, if any, in $a0, $a1, $a2, or $f12 as specified.
 Issue the SYSCALL instruction.
 Retrieve return values, if any, from result registers as specified.
Example: display the value stored in $t0 on the console li $v0, 1 # service 1 is print integer add $a0, $t0, $zero # load desired value into argument register $a0 syscall

Sample run of code:
Enter your first string with no spaces (16 total): aaaabbbbccccdddd
Enter your second string with no spaces (16 total): 0000111100001111
Enter an integer between 0 & 15 (to be later used as an upper limit for splitting the arrays): 6
You entered the following:
aaaabbbbccccdddd
0000111100001111
6
Creating newly evolved candidates from your specified inputs...
Child One and Child Two are shown below:
aaaabbb100001111
0000111bccccdddd
-- program is finished running --

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

.data

string1: .asciiz "Enter your first string with no spaces (16 total): "
string2: .asciiz "Enter your second string with no spaces (16 total): "
string3: .asciiz "Enter an integer between 0 & 15 (to be later used as an upper limit for splitting the arrays): "
string4: .asciiz "You entered the following: \n"
string5: .asciiz "Creating newly evolved candidates from your specified inputs...\n"
string6: .asciiz "Child One and Child Two are shown below:\n"
newline: .asciiz "\n"
code1: .space 17
code2: .space 17
childcode1: .space 17
childcode2: .space 17
limit: .byte

.text

main:
# print 1st message
la $a0, string1
jal printstring...

This is only a preview of the solution. Please use the purchase button to see the entire solution

$20.00

or $1 if you
register a new account!

Assisting Tutor

Related Homework Solutions

Get help from a qualified tutor
Live Chats