more projects
@@ -0,0 +1,83 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "C/C++: gcc.exe build and debug active file",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${fileDirname}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\g++.exe",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Set Disassembly Flavor to Intel",
|
||||||
|
"text": "-gdb-set disassembly-flavor intel",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"preLaunchTask": "C/C++: gcc.exe build active file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "C/C++: cpp.exe build and debug active file",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${fileDirname}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Set Disassembly Flavor to Intel",
|
||||||
|
"text": "-gdb-set disassembly-flavor intel",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"preLaunchTask": "C/C++: cpp.exe build active file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "C/C++: g++.exe build and debug active file",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${fileDirname}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Set Disassembly Flavor to Intel",
|
||||||
|
"text": "-gdb-set disassembly-flavor intel",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"preLaunchTask": "C/C++: g++.exe build active file"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": "2.0.0"
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "C/C++: g++ build and debug active file",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${fileDirname}/${fileBasenameNoExtension}",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${fileDirname}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "lldb",
|
||||||
|
"preLaunchTask": "C/C++: g++ build active file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "C/C++: clang build and debug active file",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${fileDirname}/${fileBasenameNoExtension}",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${fileDirname}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "lldb",
|
||||||
|
"preLaunchTask": "C/C++: clang build active file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "C/C++: clang++ build and debug active file",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${fileDirname}/${fileBasenameNoExtension}",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${fileDirname}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "lldb",
|
||||||
|
"preLaunchTask": "C/C++: clang++ build active file"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": "2.0.0"
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"C_Cpp.errorSquiggles": "Disabled"
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
{
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "cppbuild",
|
||||||
|
"label": "C/C++: g++.exe build active file",
|
||||||
|
"command": "C:\\msys64\\mingw64\\bin\\g++.exe",
|
||||||
|
"args": [
|
||||||
|
"-fdiagnostics-color=always",
|
||||||
|
"-g",
|
||||||
|
"${file}",
|
||||||
|
"-o",
|
||||||
|
"${fileDirname}\\${fileBasenameNoExtension}.exe"
|
||||||
|
],
|
||||||
|
"options": {
|
||||||
|
"cwd": "${fileDirname}"
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"detail": "Task generated by Debugger."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "cppbuild",
|
||||||
|
"label": "C/C++: gcc.exe build active file",
|
||||||
|
"command": "C:\\msys64\\mingw64\\bin\\gcc.exe",
|
||||||
|
"args": [
|
||||||
|
"-fdiagnostics-color=always",
|
||||||
|
"-g",
|
||||||
|
"${file}",
|
||||||
|
"-o",
|
||||||
|
"${fileDirname}\\${fileBasenameNoExtension}.exe"
|
||||||
|
],
|
||||||
|
"options": {
|
||||||
|
"cwd": "${fileDirname}"
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
],
|
||||||
|
"group": "build",
|
||||||
|
"detail": "Task generated by Debugger."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "cppbuild",
|
||||||
|
"label": "C/C++: cpp.exe build active file",
|
||||||
|
"command": "C:\\msys64\\mingw64\\bin\\cpp.exe",
|
||||||
|
"args": [
|
||||||
|
"-fdiagnostics-color=always",
|
||||||
|
"-g",
|
||||||
|
"${file}",
|
||||||
|
"-o",
|
||||||
|
"${fileDirname}\\${fileBasenameNoExtension}.exe"
|
||||||
|
],
|
||||||
|
"options": {
|
||||||
|
"cwd": "${fileDirname}"
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
],
|
||||||
|
"group": "build",
|
||||||
|
"detail": "Task generated by Debugger."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": "2.0.0"
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
{
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "cppbuild",
|
||||||
|
"label": "C/C++: clang++ build active file",
|
||||||
|
"command": "/usr/bin/clang++",
|
||||||
|
"args": [
|
||||||
|
"-fcolor-diagnostics",
|
||||||
|
"-fansi-escape-codes",
|
||||||
|
"-g",
|
||||||
|
"${file}",
|
||||||
|
"-o",
|
||||||
|
"${fileDirname}/${fileBasenameNoExtension}"
|
||||||
|
],
|
||||||
|
"options": {
|
||||||
|
"cwd": "${fileDirname}"
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"detail": "Task generated by Debugger."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "cppbuild",
|
||||||
|
"label": "C/C++: g++ build active file",
|
||||||
|
"command": "/usr/bin/g++",
|
||||||
|
"args": [
|
||||||
|
"-fdiagnostics-color=always",
|
||||||
|
"-g",
|
||||||
|
"${file}",
|
||||||
|
"-o",
|
||||||
|
"${fileDirname}/${fileBasenameNoExtension}"
|
||||||
|
],
|
||||||
|
"options": {
|
||||||
|
"cwd": "${fileDirname}"
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
],
|
||||||
|
"group": "build",
|
||||||
|
"detail": "Task generated by Debugger."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "cppbuild",
|
||||||
|
"label": "C/C++: clang build active file",
|
||||||
|
"command": "/usr/bin/clang",
|
||||||
|
"args": [
|
||||||
|
"-fcolor-diagnostics",
|
||||||
|
"-fansi-escape-codes",
|
||||||
|
"-g",
|
||||||
|
"${file}",
|
||||||
|
"-o",
|
||||||
|
"${fileDirname}/${fileBasenameNoExtension}"
|
||||||
|
],
|
||||||
|
"options": {
|
||||||
|
"cwd": "${fileDirname}"
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
],
|
||||||
|
"group": "build",
|
||||||
|
"detail": "Task generated by Debugger."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": "2.0.0"
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 186 KiB |
|
After Width: | Height: | Size: 186 KiB |
@@ -0,0 +1,97 @@
|
|||||||
|
//
|
||||||
|
// main.cpp
|
||||||
|
// Assignment 1
|
||||||
|
//
|
||||||
|
// Created by Austin Bennett on 9/11/22.
|
||||||
|
//
|
||||||
|
|
||||||
|
// #1 - 128 times larger (128 in x 128 in)
|
||||||
|
// #2 - 26 jumps
|
||||||
|
|
||||||
|
// #3 Merge Sort Implementation
|
||||||
|
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void dump(const string test, const vector<int> &myVector)
|
||||||
|
{
|
||||||
|
cout << test << " to sort size: " << myVector.size() << endl;
|
||||||
|
|
||||||
|
copy(myVector.begin(), myVector.end(), ostream_iterator<int>(cout, " "));
|
||||||
|
cout << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void merge(int array[], int const left, int const mid,
|
||||||
|
int const right)
|
||||||
|
{
|
||||||
|
auto const subArrayOne = mid - left + 1;
|
||||||
|
auto const subArrayTwo = right - mid;
|
||||||
|
|
||||||
|
// Create temp arrays
|
||||||
|
auto *leftArray = new int[subArrayOne],
|
||||||
|
*rightArray = new int[subArrayTwo];
|
||||||
|
|
||||||
|
// Copy data to temp arrays leftArray[] and rightArray[]
|
||||||
|
for (auto i = 0; i < subArrayOne; i++)
|
||||||
|
leftArray[i] = array[left + i];
|
||||||
|
for (auto j = 0; j < subArrayTwo; j++)
|
||||||
|
rightArray[j] = array[mid + 1 + j];
|
||||||
|
|
||||||
|
auto indexOfSubArrayOne = 0, // Initial index of first sub-array
|
||||||
|
indexOfSubArrayTwo = 0; // Initial index of second sub-array
|
||||||
|
int indexOfMergedArray = left; // Initial index of merged array
|
||||||
|
|
||||||
|
// Merge the temp arrays back into array[left..right]
|
||||||
|
while (indexOfSubArrayOne < subArrayOne && indexOfSubArrayTwo < subArrayTwo)
|
||||||
|
{
|
||||||
|
if (leftArray[indexOfSubArrayOne] <= rightArray[indexOfSubArrayTwo])
|
||||||
|
{
|
||||||
|
array[indexOfMergedArray] = leftArray[indexOfSubArrayOne];
|
||||||
|
indexOfSubArrayOne++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
array[indexOfMergedArray] = rightArray[indexOfSubArrayTwo];
|
||||||
|
indexOfSubArrayTwo++;
|
||||||
|
}
|
||||||
|
indexOfMergedArray++;
|
||||||
|
}
|
||||||
|
// Copy the remaining elements of
|
||||||
|
// left[], if there are any
|
||||||
|
while (indexOfSubArrayOne < subArrayOne)
|
||||||
|
{
|
||||||
|
array[indexOfMergedArray] = leftArray[indexOfSubArrayOne];
|
||||||
|
indexOfSubArrayOne++;
|
||||||
|
indexOfMergedArray++;
|
||||||
|
}
|
||||||
|
// Copy the remaining elements of
|
||||||
|
// right[], if there are any
|
||||||
|
while (indexOfSubArrayTwo < subArrayTwo)
|
||||||
|
{
|
||||||
|
array[indexOfMergedArray] = rightArray[indexOfSubArrayTwo];
|
||||||
|
indexOfSubArrayTwo++;
|
||||||
|
indexOfMergedArray++;
|
||||||
|
}
|
||||||
|
delete[] leftArray;
|
||||||
|
delete[] rightArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// test 1
|
||||||
|
vector<int> myVector1{2};
|
||||||
|
mergeSort(myVector1);
|
||||||
|
dump("test1", myVector1);
|
||||||
|
|
||||||
|
// test 2
|
||||||
|
vector<int> myVector2{2, 4, 6, 7, 1, 2, 3, 5};
|
||||||
|
myMergeSort(myVector2);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void dump(const string test, const vector<int> &myVector)
|
||||||
|
{
|
||||||
|
cout << test << " to sort size: " << myVector.size() << endl;
|
||||||
|
|
||||||
|
copy(myVector.begin(), myVector.end(), ostream_iterator<int>(cout, " "));
|
||||||
|
cout << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<int> merge(vector<int> left, vector<int> right)
|
||||||
|
{
|
||||||
|
size_t ileft = 0, iright = 0;
|
||||||
|
vector<int> results;
|
||||||
|
while (ileft < left.size() && iright < right.size())
|
||||||
|
if (left[ileft] < right[iright])
|
||||||
|
results.push_back(left[ileft++]);
|
||||||
|
else
|
||||||
|
results.push_back(right[iright++]);
|
||||||
|
while (ileft < left.size())
|
||||||
|
results.push_back(left[ileft++]);
|
||||||
|
while (iright < right.size())
|
||||||
|
results.push_back(right[iright++]);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<int> myMergeSort(vector<int> &myVector)
|
||||||
|
{
|
||||||
|
if (myVector.size() <= 1)
|
||||||
|
return myVector;
|
||||||
|
int len = myVector.size() / 2;
|
||||||
|
vector<int> left(myVector.begin(), myVector.begin() + len);
|
||||||
|
vector<int> right(myVector.begin() + len, myVector.end());
|
||||||
|
return merge(myMergeSort(left), myMergeSort(right));
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// test 1
|
||||||
|
vector<int> myVector1{2, 1};
|
||||||
|
dump("test1", myMergeSort(myVector1));
|
||||||
|
|
||||||
|
// test 2
|
||||||
|
vector<int> myVector2{2, 4, 6, 7, 1, 2, 3, 5};
|
||||||
|
dump("test2", myMergeSort(myVector2));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>English</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.apple.xcode.dsym.main</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>dSYM</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>fa</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>69.0</x>
|
||||||
|
<y>61.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>198.0</x>
|
||||||
|
<y>-13.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>352.0</x>
|
||||||
|
<y>59.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>fa</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>111.0</x>
|
||||||
|
<y>130.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>223.0</x>
|
||||||
|
<y>127.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>372.0</x>
|
||||||
|
<y>137.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>fa</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>233.0</x>
|
||||||
|
<y>267.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>489.0</x>
|
||||||
|
<y>273.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>355.0</x>
|
||||||
|
<y>376.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="3" name="q3">
|
||||||
|
<x>389.0</x>
|
||||||
|
<y>197.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<state id="5" name="q5">
|
||||||
|
<x>595.0</x>
|
||||||
|
<y>49.0</y>
|
||||||
|
<label>L = {0m 1n | m≥1, n≥0} </label>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
|
After Width: | Height: | Size: 137 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 50 KiB |
@@ -0,0 +1,77 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>fa</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>74.0</x>
|
||||||
|
<y>144.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>178.0</x>
|
||||||
|
<y>147.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>357.0</x>
|
||||||
|
<y>154.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="3" name="q3">
|
||||||
|
<x>256.0</x>
|
||||||
|
<y>150.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="4" name="q4">
|
||||||
|
<x>458.0</x>
|
||||||
|
<y>157.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="5" name="q5">
|
||||||
|
<x>568.0</x>
|
||||||
|
<y>160.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<state id="6" name="q6">
|
||||||
|
<x>501.0</x>
|
||||||
|
<y>242.0</y>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>5</from>
|
||||||
|
<to>6</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>4</from>
|
||||||
|
<to>5</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>4</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>6</from>
|
||||||
|
<to>4</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>fa</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>136.0</x>
|
||||||
|
<y>147.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>249.0</x>
|
||||||
|
<y>152.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>390.0</x>
|
||||||
|
<y>153.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="3" name="q3">
|
||||||
|
<x>506.0</x>
|
||||||
|
<y>155.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>fa</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>107.0</x>
|
||||||
|
<y>225.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>194.0</x>
|
||||||
|
<y>226.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>288.0</x>
|
||||||
|
<y>161.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="3" name="q3">
|
||||||
|
<x>283.0</x>
|
||||||
|
<y>289.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="4" name="q4">
|
||||||
|
<x>371.0</x>
|
||||||
|
<y>229.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="5" name="q5">
|
||||||
|
<x>519.0</x>
|
||||||
|
<y>230.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>5</from>
|
||||||
|
<to>5</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>5</from>
|
||||||
|
<to>5</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>4</from>
|
||||||
|
<to>5</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>4</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>4</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>pda</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>107.0</x>
|
||||||
|
<y>107.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>246.0</x>
|
||||||
|
<y>103.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="3" name="q3">
|
||||||
|
<x>382.0</x>
|
||||||
|
<y>104.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>b</read>
|
||||||
|
<pop>Z</pop>
|
||||||
|
<push>Z</push>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read/>
|
||||||
|
<pop>Z</pop>
|
||||||
|
<push>Z</push>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>a</read>
|
||||||
|
<pop>Z</pop>
|
||||||
|
<push>Z</push>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>turing</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>85.0</x>
|
||||||
|
<y>117.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>186.0</x>
|
||||||
|
<y>117.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>298.0</x>
|
||||||
|
<y>114.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="3" name="q3">
|
||||||
|
<x>429.0</x>
|
||||||
|
<y>113.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>1</read>
|
||||||
|
<write>1</write>
|
||||||
|
<move>R</move>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>1</read>
|
||||||
|
<write>1</write>
|
||||||
|
<move>R</move>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>0</read>
|
||||||
|
<write>0</write>
|
||||||
|
<move>R</move>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>1</read>
|
||||||
|
<write>1</write>
|
||||||
|
<move>R</move>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>0</read>
|
||||||
|
<write>0</write>
|
||||||
|
<move>R</move>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>0</read>
|
||||||
|
<write>0</write>
|
||||||
|
<move>R</move>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>1</read>
|
||||||
|
<write>1</write>
|
||||||
|
<move>R</move>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>fa</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>71.0</x>
|
||||||
|
<y>83.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>174.0</x>
|
||||||
|
<y>85.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>267.0</x>
|
||||||
|
<y>85.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="3" name="q3">
|
||||||
|
<x>174.0</x>
|
||||||
|
<y>195.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
|
After Width: | Height: | Size: 42 KiB |
@@ -0,0 +1,78 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>fa</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>48.0</x>
|
||||||
|
<y>75.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>150.0</x>
|
||||||
|
<y>75.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>287.0</x>
|
||||||
|
<y>77.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="3" name="q3">
|
||||||
|
<x>397.0</x>
|
||||||
|
<y>76.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="4" name="q4">
|
||||||
|
<x>493.0</x>
|
||||||
|
<y>73.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>4</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>4</from>
|
||||||
|
<to>2</to>
|
||||||
|
<controlx>406</controlx>
|
||||||
|
<controly>-32</controly>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>1</to>
|
||||||
|
<controlx>297</controlx>
|
||||||
|
<controly>163</controly>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
|
After Width: | Height: | Size: 43 KiB |
@@ -0,0 +1,79 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>fa</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>132.0</x>
|
||||||
|
<y>134.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>214.0</x>
|
||||||
|
<y>84.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>357.0</x>
|
||||||
|
<y>84.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<state id="3" name="q3">
|
||||||
|
<x>392.0</x>
|
||||||
|
<y>286.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="4" name="q4">
|
||||||
|
<x>304.0</x>
|
||||||
|
<y>175.0</y>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>4</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>4</from>
|
||||||
|
<to>4</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>4</from>
|
||||||
|
<to>4</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>4</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
|
After Width: | Height: | Size: 60 KiB |
@@ -0,0 +1,109 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>fa</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>91.0</x>
|
||||||
|
<y>214.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>206.0</x>
|
||||||
|
<y>219.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>317.0</x>
|
||||||
|
<y>223.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="3" name="q3">
|
||||||
|
<x>419.0</x>
|
||||||
|
<y>210.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="4" name="q4">
|
||||||
|
<x>514.0</x>
|
||||||
|
<y>213.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="5" name="q5">
|
||||||
|
<x>659.0</x>
|
||||||
|
<y>213.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<state id="6" name="q6">
|
||||||
|
<x>279.0</x>
|
||||||
|
<y>418.0</y>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>4</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>6</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>5</from>
|
||||||
|
<to>6</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>4</from>
|
||||||
|
<to>5</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>6</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>6</from>
|
||||||
|
<to>6</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>6</from>
|
||||||
|
<to>6</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>4</from>
|
||||||
|
<to>6</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>5</from>
|
||||||
|
<to>3</to>
|
||||||
|
<controlx>553</controlx>
|
||||||
|
<controly>274</controly>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>6</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
|
After Width: | Height: | Size: 124 KiB |
@@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>fa</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>53.0</x>
|
||||||
|
<y>221.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>145.0</x>
|
||||||
|
<y>223.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 32 KiB |
@@ -0,0 +1,54 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>fa</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>67.0</x>
|
||||||
|
<y>139.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>157.0</x>
|
||||||
|
<y>140.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>244.0</x>
|
||||||
|
<y>140.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="3" name="q3">
|
||||||
|
<x>326.0</x>
|
||||||
|
<y>140.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="4" name="q4">
|
||||||
|
<x>436.0</x>
|
||||||
|
<y>141.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>4</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>4</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>fa</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>61.0</x>
|
||||||
|
<y>90.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>148.0</x>
|
||||||
|
<y>88.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>262.0</x>
|
||||||
|
<y>88.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="3" name="q3">
|
||||||
|
<x>355.0</x>
|
||||||
|
<y>87.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>0</to>
|
||||||
|
<controlx>140</controlx>
|
||||||
|
<controly>208</controly>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>fa</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>92.0</x>
|
||||||
|
<y>151.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>179.0</x>
|
||||||
|
<y>156.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>246.0</x>
|
||||||
|
<y>157.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="3" name="q3">
|
||||||
|
<x>301.0</x>
|
||||||
|
<y>144.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="4" name="q4">
|
||||||
|
<x>363.0</x>
|
||||||
|
<y>144.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="5" name="q5">
|
||||||
|
<x>459.0</x>
|
||||||
|
<y>151.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>4</from>
|
||||||
|
<to>5</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>4</from>
|
||||||
|
<to>5</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>4</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>4</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 45 KiB |
@@ -0,0 +1,55 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>fa</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>67.0</x>
|
||||||
|
<y>125.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>174.0</x>
|
||||||
|
<y>51.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>175.0</x>
|
||||||
|
<y>205.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="3" name="q3">
|
||||||
|
<x>288.0</x>
|
||||||
|
<y>127.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>fa</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>67.0</x>
|
||||||
|
<y>125.0</y>
|
||||||
|
<initial/>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>174.0</x>
|
||||||
|
<y>51.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>175.0</x>
|
||||||
|
<y>205.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<state id="3" name="q3">
|
||||||
|
<x>288.0</x>
|
||||||
|
<y>127.0</y>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>0</read>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>3</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>1</read>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 118 KiB |
@@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>pda</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>97.0</x>
|
||||||
|
<y>199.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>235.0</x>
|
||||||
|
<y>196.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>394.0</x>
|
||||||
|
<y>206.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>0</read>
|
||||||
|
<pop/>
|
||||||
|
<push>0</push>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>0</read>
|
||||||
|
<pop>0</pop>
|
||||||
|
<push>0</push>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>1</read>
|
||||||
|
<pop>0</pop>
|
||||||
|
<push/>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read/>
|
||||||
|
<pop>0</pop>
|
||||||
|
<push>Z</push>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>1</read>
|
||||||
|
<pop>0</pop>
|
||||||
|
<push>0</push>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--Created with JFLAP 7.1.--><structure>
|
||||||
|
<type>pda</type>
|
||||||
|
<automaton>
|
||||||
|
<!--The list of states.-->
|
||||||
|
<state id="0" name="q0">
|
||||||
|
<x>66.0</x>
|
||||||
|
<y>278.0</y>
|
||||||
|
<initial/>
|
||||||
|
</state>
|
||||||
|
<state id="1" name="q1">
|
||||||
|
<x>283.0</x>
|
||||||
|
<y>535.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="2" name="q2">
|
||||||
|
<x>390.0</x>
|
||||||
|
<y>537.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="3" name="q3">
|
||||||
|
<x>490.0</x>
|
||||||
|
<y>540.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<state id="4" name="q4">
|
||||||
|
<x>262.0</x>
|
||||||
|
<y>428.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="5" name="q5">
|
||||||
|
<x>174.0</x>
|
||||||
|
<y>289.0</y>
|
||||||
|
</state>
|
||||||
|
<state id="6" name="q6">
|
||||||
|
<x>260.0</x>
|
||||||
|
<y>299.0</y>
|
||||||
|
<final/>
|
||||||
|
</state>
|
||||||
|
<state id="11" name="q11">
|
||||||
|
<x>233.0</x>
|
||||||
|
<y>59.0</y>
|
||||||
|
<label>L = {am bn cp | m = n or n = p}</label>
|
||||||
|
</state>
|
||||||
|
<!--The list of transitions.-->
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>b</read>
|
||||||
|
<pop>B</pop>
|
||||||
|
<push>BB</push>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>a</read>
|
||||||
|
<pop>A</pop>
|
||||||
|
<push>AA</push>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>c</read>
|
||||||
|
<pop>B</pop>
|
||||||
|
<push/>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>5</from>
|
||||||
|
<to>4</to>
|
||||||
|
<read>c</read>
|
||||||
|
<pop>Z</pop>
|
||||||
|
<push>Z</push>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>0</to>
|
||||||
|
<read>a</read>
|
||||||
|
<pop>Z</pop>
|
||||||
|
<push>AZ</push>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>4</from>
|
||||||
|
<to>4</to>
|
||||||
|
<read>c</read>
|
||||||
|
<pop>Z</pop>
|
||||||
|
<push>Z</push>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>5</from>
|
||||||
|
<to>5</to>
|
||||||
|
<read>b</read>
|
||||||
|
<pop>A</pop>
|
||||||
|
<push/>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>b</read>
|
||||||
|
<pop>Z</pop>
|
||||||
|
<push>BZ</push>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>1</to>
|
||||||
|
<read>b</read>
|
||||||
|
<pop>A</pop>
|
||||||
|
<push>BA</push>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read/>
|
||||||
|
<pop>A</pop>
|
||||||
|
<push>A</push>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>2</from>
|
||||||
|
<to>3</to>
|
||||||
|
<read/>
|
||||||
|
<pop>Z</pop>
|
||||||
|
<push>Z</push>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>4</to>
|
||||||
|
<read>c</read>
|
||||||
|
<pop>Z</pop>
|
||||||
|
<push>Z</push>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>0</from>
|
||||||
|
<to>5</to>
|
||||||
|
<read>b</read>
|
||||||
|
<pop>A</pop>
|
||||||
|
<push/>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>4</from>
|
||||||
|
<to>6</to>
|
||||||
|
<read/>
|
||||||
|
<pop>Z</pop>
|
||||||
|
<push>Z</push>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>5</from>
|
||||||
|
<to>6</to>
|
||||||
|
<read/>
|
||||||
|
<pop>Z</pop>
|
||||||
|
<push>Z</push>
|
||||||
|
</transition>
|
||||||
|
<transition>
|
||||||
|
<from>1</from>
|
||||||
|
<to>2</to>
|
||||||
|
<read>c</read>
|
||||||
|
<pop>B</pop>
|
||||||
|
<push/>
|
||||||
|
</transition>
|
||||||
|
</automaton>
|
||||||
|
</structure>
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
|
||||||
|
|
||||||
|
.data
|
||||||
|
start: .asciiz "---> Start of Bank Program <---\nAuthor information: CS 220 | #324855 | Austin Bennett\n---> Welcome to the Interest Calculator! <--- \n2%: saving years < 7 years\n5%: saving years >= 7 years\n"
|
||||||
|
promptMsg1: .asciiz "==> Enter the principal:$ \n"
|
||||||
|
promptMsg2: .asciiz "==> Enter the years of savings: \n"
|
||||||
|
resultLine: .asciiz "----------------> Result <----------------\n---> Your principal is: "
|
||||||
|
resultLine2: .asciiz "\n---> Your interest rate is: "
|
||||||
|
yrLbl: .asciiz "\nYear "
|
||||||
|
balanceRet: .asciiz ": your balance is $"
|
||||||
|
balLbl: .asciiz "\n---> Your balance after "
|
||||||
|
yearsRet: .asciiz " years: $ "
|
||||||
|
finalLine: .asciiz "\n----------------> End of Interest Calculator <---------------- "
|
||||||
|
newLine: .asciiz "\n"
|
||||||
|
principal: .float 0.0
|
||||||
|
years: .word 0
|
||||||
|
yearsDiv: .word 7
|
||||||
|
rate1: .float 0.02
|
||||||
|
rate2: .float 0.05
|
||||||
|
interestRate: .float 0.0
|
||||||
|
balance: .float 0.0
|
||||||
|
|
||||||
|
.text
|
||||||
|
.globl main #entrance of program
|
||||||
|
.ent main
|
||||||
|
|
||||||
|
main:
|
||||||
|
la $a0, start
|
||||||
|
li $v0, 4
|
||||||
|
syscall
|
||||||
|
|
||||||
|
la $a0, promptMsg1
|
||||||
|
li $v0, 4
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $v0, 6
|
||||||
|
syscall
|
||||||
|
|
||||||
|
s.s $f0, principal
|
||||||
|
la $a0, promptMsg2
|
||||||
|
li $v0, 4
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $v0, 5
|
||||||
|
syscall
|
||||||
|
|
||||||
|
sw $v0, years
|
||||||
|
la $a0, resultLine
|
||||||
|
li $v0, 4
|
||||||
|
syscall
|
||||||
|
|
||||||
|
l.s $f12, principal
|
||||||
|
li $v0, 2
|
||||||
|
syscall
|
||||||
|
|
||||||
|
la $a0, resultLine2
|
||||||
|
li $v0, 4
|
||||||
|
syscall
|
||||||
|
|
||||||
|
lw $t1, years
|
||||||
|
lw $t2, yearsDiv
|
||||||
|
blt $t1, $t2, lessThan
|
||||||
|
l.s $f1, rate2
|
||||||
|
s.s $f1, interestRate
|
||||||
|
l.s $f12, interestRate
|
||||||
|
li $v0, 2
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $t3, 1
|
||||||
|
|
||||||
|
while:
|
||||||
|
bgt $t3, $t1, exit
|
||||||
|
la $a0, yrLbl
|
||||||
|
li $v0, 4
|
||||||
|
syscall
|
||||||
|
|
||||||
|
move $a0, $t3
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
|
||||||
|
la $a0, balanceRet
|
||||||
|
li $v0, 4
|
||||||
|
syscall
|
||||||
|
|
||||||
|
l.s $f3, principal
|
||||||
|
l.s $f4, interestRate
|
||||||
|
mul.s $f2, $f3, $f4
|
||||||
|
add.s $f5, $f3, $f2
|
||||||
|
s.s $f5, principal
|
||||||
|
s.s $f5, balance
|
||||||
|
l.s $f12, balance
|
||||||
|
li $v0, 2
|
||||||
|
syscall
|
||||||
|
|
||||||
|
addi $t3, $t3, 1
|
||||||
|
j while
|
||||||
|
|
||||||
|
exit:
|
||||||
|
la $a0, balLbl
|
||||||
|
li $v0, 4
|
||||||
|
syscall
|
||||||
|
|
||||||
|
lw $a0, years
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
|
||||||
|
la $a0, yearsRet
|
||||||
|
li $v0, 4
|
||||||
|
syscall
|
||||||
|
|
||||||
|
l.s $f12, balance
|
||||||
|
li $v0, 2
|
||||||
|
syscall
|
||||||
|
|
||||||
|
la $a0, finalLine
|
||||||
|
li $v0, 4
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
|
||||||
|
lessThan:
|
||||||
|
l.s $f1, rate1
|
||||||
|
s.s $f1, interestRate
|
||||||
|
|
||||||
|
|
||||||
|
l.s $f12, interestRate
|
||||||
|
li $v0, 2
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $t3, 1
|
||||||
|
|
||||||
|
logic:
|
||||||
|
bgt $t3, $t1, exit
|
||||||
|
la $a0, yrLbl
|
||||||
|
li $v0, 4
|
||||||
|
syscall
|
||||||
|
|
||||||
|
move $a0, $t3
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
|
||||||
|
la $a0, balanceRet
|
||||||
|
li $v0, 4
|
||||||
|
syscall
|
||||||
|
|
||||||
|
l.s $f3, principal
|
||||||
|
l.s $f4, interestRate
|
||||||
|
mul.s $f2, $f3, $f4
|
||||||
|
add.s $f5, $f3, $f2
|
||||||
|
s.s $f5, principal
|
||||||
|
s.s $f5, balance
|
||||||
|
l.s $f12, balance
|
||||||
|
li $v0, 2
|
||||||
|
syscall
|
||||||
|
|
||||||
|
addi $t3, $t3, 1
|
||||||
|
j logic
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
|
||||||
|
|
||||||
|
.data
|
||||||
|
startMsg: .ascii "---> Start of Bank Program <---\n" #System.out.println(""---> Start of Bank Program <---\n")
|
||||||
|
.ascii "Author information: CS 220 | #02 | Corinne Bond\n" #System.out.println("Author information: CS 220 | #02 | Corinne Bond\n")
|
||||||
|
.ascii "---> Welcome to the Interest Calculator! <--- \n" #System.out.println(">>> Welcome to Interest Calculator! <<<<\n
|
||||||
|
.ascii " 1%: saving years < 5 years\n" # cont.. 1%: saving years < 5 years\n
|
||||||
|
.asciiz " 5%: saving years >= 5 years\n" # cont.. 5%: saving years >= 5 years\n
|
||||||
|
promptMsg1: .asciiz "==> Enter the principal:$ \n" #System.out.println(""==> Enter the principal:$ \n")
|
||||||
|
promptMsg2: .asciiz "==> Enter the years of savings: \n" #System.out.println("==> Enter the years of savings: \n")
|
||||||
|
resultLine: .ascii "----------------> Result <----------------" #System.out.println("----------------> Result <----------------")
|
||||||
|
.asciiz "\n---> Your principal is: " #System.out.println("\n---> Your principal is: ")
|
||||||
|
resultLine2: .asciiz "\n---> Your interest rate is: " #System.out.println("\n *** Interest rate is:"
|
||||||
|
hdr: .asciiz "\nYear " #System.out.println("\nYear")
|
||||||
|
hdr1: .asciiz ": your balance is $" #System.out.println(": your balance is $")
|
||||||
|
hdr2: .asciiz "\n---> Your balance after " #System.outprintln("\n---> Your balance after ")
|
||||||
|
hdr3: .asciiz " years: $ " #System.out.println(" years: $ ")
|
||||||
|
finalLine: .asciiz "\n----------------> End of Interest Calculator <---------------- " #System.out.println("\n----------------> End of Interest Calculator <---------------- ")
|
||||||
|
newLine: .asciiz "\n" #System.out.println("\n")
|
||||||
|
principal: .float 0.0 #32bits, intial val of 0 #float principal = 0.0
|
||||||
|
years: .word 0 #32bits, intial val of 0 #int years = 0
|
||||||
|
testVal: .word 5 #int testVal = 0
|
||||||
|
rate1: .float 0.01 #float rate1 = .01
|
||||||
|
rate2: .float 0.05 #float rate2 = .05
|
||||||
|
interestRate: .float 0.0 #float interestRate = 0.0
|
||||||
|
balance: .float 0.0 #float balance = 0.0
|
||||||
|
#------------------------------------
|
||||||
|
#text/code section
|
||||||
|
.text
|
||||||
|
.globl main #entrance of program
|
||||||
|
.ent main
|
||||||
|
|
||||||
|
main:
|
||||||
|
la $a0, startMsg #load address of start msg
|
||||||
|
li $v0, 4 #syscall 4 -> print char from string
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
la $a0, promptMsg1 #load memory address of promptMsg1
|
||||||
|
li $v0, 4 #syscall 4 -> print char from string
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $v0, 6 #syscall 6 -> read floating point from kb -> float principal = sc.nextFloat();
|
||||||
|
syscall #do it
|
||||||
|
s.s $f0, principal #save input into principal variable
|
||||||
|
|
||||||
|
la $a0, promptMsg2 #load memory address of promptMsg2
|
||||||
|
li $v0, 4 #syscall 4 -> print char from string
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
li $v0, 5 #syscall 5 -> read int from kb -> int years = sc.nextInt();
|
||||||
|
syscall #do it
|
||||||
|
sw $v0, years #save input into years variable
|
||||||
|
|
||||||
|
la $a0, resultLine #load memory address of resultLine
|
||||||
|
li $v0, 4 #syscall 4 -> print char from string
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
l.s $f12, principal #load principal val into float register to be printed
|
||||||
|
li $v0, 2 #syscall 2 -> print float from register
|
||||||
|
syscall
|
||||||
|
|
||||||
|
la $a0, resultLine2 #load memory address of resultLine2
|
||||||
|
li $v0, 4 #syscall 4 -> print char from string
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
#choose interest rate based on given variables
|
||||||
|
lw $t1, years #load word from years into register
|
||||||
|
lw $t2, testVal #load word from testVal into register
|
||||||
|
blt $t1, $t2, lessThan #if t1 < t2 -> if (yearsOfSaving < 5) {return 0.01F;}
|
||||||
|
l.s $f1, rate2 #load 5% interest rate into register -> else {return 0.05F;}
|
||||||
|
s.s $f1, interestRate #save floating point to interest rate variable
|
||||||
|
|
||||||
|
#print interest rate
|
||||||
|
l.s $f12, interestRate #load floating point to register to be printed
|
||||||
|
li $v0, 2 #syscall 2 -> print float from register
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
li $t3, 1 #syscall 1 -> print int
|
||||||
|
|
||||||
|
while: #start of 1st while loop (x>=5)
|
||||||
|
bgt $t3, $t1, exit #exit if t3 > t1 -> for (int i = 1; i <= yearsOfSaving; i++)
|
||||||
|
la $a0,hdr #load memory address of hdr0
|
||||||
|
li $v0, 4 #syscall 4 -> print char from string
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
move $a0, $t3 #move from t3 to a0
|
||||||
|
li $v0, 1 #syscall 1 -> print int
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
la $a0, hdr1 #load memory address of hdr1
|
||||||
|
li $v0, 4 #syscall 4 -> print char from string
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
l.s $f3, principal #load floating point to register f3
|
||||||
|
l.s $f4, interestRate #load floating point to register f4
|
||||||
|
mul.s $f2,$f3,$f4 #calculate interest, save into f2
|
||||||
|
add.s $f5,$f3,$f2 #add interest to principa;. save into f5 -> -> balance *= (1 + interest);
|
||||||
|
s.s $f5, principal #update principal with value in f5
|
||||||
|
s.s $f5, balance #update balance with value in f5 -> float balance = principal;
|
||||||
|
l.s $f12, balance #load floating point to register to be printed
|
||||||
|
li $v0, 2 #syscall 2 -> print float from register
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
addi $t3, $t3, 1 #add 1 to value in register t3, update register value -> year++;
|
||||||
|
j while #repeat while
|
||||||
|
|
||||||
|
exit:
|
||||||
|
la $a0, hdr2 #load memory address of hdr2
|
||||||
|
li $v0, 4 #syscall 4 -> print char from string ->
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
lw $a0, years #load years variable into register a0
|
||||||
|
li $v0, 1 #syscall 1 -> print int
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
la $a0, hdr3 #load memory address of hdr3
|
||||||
|
li $v0, 4 #syscall 1 -> print int
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
l.s $f12, balance #load floating point to be printed
|
||||||
|
li $v0, 2 #syscall 2 -> print floating point
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
la $a0, finalLine #load memory address of finalLine
|
||||||
|
li $v0, 4 #syscall 4 -> print char from string
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
li $v0, 10 #syscall 10 -> exit -> System.exit(0);
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
lessThan: #less than branch
|
||||||
|
l.s $f1, rate1 #load storage
|
||||||
|
s.s $f1, interestRate #save variable to interest rate
|
||||||
|
|
||||||
|
#print interest rate
|
||||||
|
l.s $f12, interestRate #load floating point to register to be printed
|
||||||
|
li $v0, 2 #syscall 2 -> print float from register
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
li $t3, 1 #syscall 1 -> print int
|
||||||
|
|
||||||
|
while2: #start of 2nd loop (x < 5)
|
||||||
|
bgt $t3, $t1, exit # if t3 > t4 exit -> -> for (int i = 1; i <= yearsOfSaving; i++)
|
||||||
|
la $a0, hdr #load memory address of hdr
|
||||||
|
li $v0, 4 #syscall 4 -> print char from string
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
move $a0, $t3 #move from t3 to a0
|
||||||
|
li $v0, 1 #syscall 1 -> print int
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
la $a0, hdr1 #load memory address of hdr1
|
||||||
|
li $v0, 4 #syscall 4 -> print char from string
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
l.s $f3, principal #load principal to f3
|
||||||
|
l.s $f4, interestRate #load interestRate to f4
|
||||||
|
mul.s $f2, $f3,$f4 #calculate interest and save to f2
|
||||||
|
add.s $f5, $f3,$f2 #add interest back to principal and store in f5 -> balance *= (1 + interest);
|
||||||
|
s.s $f5, principal #update principal value
|
||||||
|
s.s $f5, balance #update balance
|
||||||
|
l.s $f12, balance #load value of balance to be printed
|
||||||
|
li $v0, 2 #syscall 2 -> print floating point
|
||||||
|
syscall #do it
|
||||||
|
|
||||||
|
addi $t3, $t3, 1 #add 1 to t3, update value in same register
|
||||||
|
j while2
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# Example program to display a string and an integer.
|
||||||
|
# Demonstrates use of QtSpim system service calls.
|
||||||
|
# -----------------------------------------------------
|
||||||
|
# Data Declarations
|
||||||
|
.data
|
||||||
|
start: .asciiz "------ START Program Example 9.2.1 ------\n"
|
||||||
|
end: .asciiz "\n------ END Program Example 9.2.1 ------\n"
|
||||||
|
id: .ascii "Student: Austin Bennett (CS 220, id: 324855)\n"
|
||||||
|
hdr: .ascii "Example\n"
|
||||||
|
.asciiz "The meaning of life is: "
|
||||||
|
number: .word 42
|
||||||
|
# -----------------------------------------------------
|
||||||
|
# text/code section
|
||||||
|
.text
|
||||||
|
.globl main
|
||||||
|
.ent main
|
||||||
|
main:
|
||||||
|
la $a0, start
|
||||||
|
li $v0, 4
|
||||||
|
syscall
|
||||||
|
|
||||||
|
la $a0, id
|
||||||
|
li $v0, 4 # call code, print string
|
||||||
|
syscall # system call
|
||||||
|
|
||||||
|
la $a0, hdr
|
||||||
|
li $v0, 4
|
||||||
|
|
||||||
|
li $v0, 1 # call code, print int
|
||||||
|
lw $a0, number # value for int to print
|
||||||
|
syscall # system call
|
||||||
|
# ----
|
||||||
|
la $a0, end
|
||||||
|
li $v0, 4
|
||||||
|
syscall
|
||||||
|
# Done, terminate program.
|
||||||
|
li $v0, 10 # terminate
|
||||||
|
syscall # system call
|
||||||
|
.end main
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
# Example program to display an array.
|
||||||
|
# Demonstrates use of QtSpim system service calls.
|
||||||
|
# -----------------------------------------------------
|
||||||
|
# Data Declarations
|
||||||
|
.data
|
||||||
|
id: .asciiz "Student: Austin Bennett (CS 220, id: 324855)\n"
|
||||||
|
hdr: .ascii "Squaring Example\n"
|
||||||
|
.asciiz "Enter Value: "
|
||||||
|
ansMsg: .asciiz "Value Squared: "
|
||||||
|
value: .word 0
|
||||||
|
start: .asciiz "------ START Program Example 9.2.3 ------\n"
|
||||||
|
end: .asciiz "\n------ END Program Example 9.2.3 ------\n"
|
||||||
|
|
||||||
|
# -----------------------------------------------------
|
||||||
|
# text/code section
|
||||||
|
.text
|
||||||
|
.globl main
|
||||||
|
.ent main
|
||||||
|
main:
|
||||||
|
li $v0, 4
|
||||||
|
la $a0, start
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $v0, 4
|
||||||
|
la $a0, id
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $v0, 4 # call code for print string
|
||||||
|
la $a0, hdr # addr of NULL terminated str
|
||||||
|
syscall # system call
|
||||||
|
|
||||||
|
li $v0, 5 # call code for read integer
|
||||||
|
syscall # system call (result in $v0)
|
||||||
|
|
||||||
|
mul $t0, $v0, $v0 # square answer
|
||||||
|
sw $t0, value # save to variable
|
||||||
|
li $v0, 4 # call code for print string
|
||||||
|
la $a0, ansMsg # addr of NULL terminated str
|
||||||
|
syscall # system call
|
||||||
|
|
||||||
|
li $v0, 1 # call code for print integer
|
||||||
|
lw $a0, value # value for integer to print
|
||||||
|
syscall # system call
|
||||||
|
|
||||||
|
li $v0, 4
|
||||||
|
la $a0, end
|
||||||
|
syscall
|
||||||
|
# -----
|
||||||
|
# Done, terminate program.
|
||||||
|
li $v0, 10 # terminate
|
||||||
|
syscall # system call
|
||||||
|
.end main
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# Write A MIPS Assembly Program to ADD the Numbers: 4, 6, 8
|
||||||
|
|
||||||
|
.data
|
||||||
|
start: .asciiz "------ START Program Question 2 ------\n"
|
||||||
|
end: .asciiz "\n------ END Program Question 2 ------\n"
|
||||||
|
id: .asciiz "Student: Austin Bennett (CS 220, id: 324855)\n"
|
||||||
|
tag: .ascii "4 + 6 + 8 = "
|
||||||
|
|
||||||
|
.text
|
||||||
|
.globl main
|
||||||
|
.ent main
|
||||||
|
main:
|
||||||
|
li $v0, 4
|
||||||
|
la $a0, start
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $v0, 4
|
||||||
|
la $a0, id
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $v0, 4
|
||||||
|
la $a0, tag
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $t0,4
|
||||||
|
add $t1,$t1,$t0
|
||||||
|
li $t0,6
|
||||||
|
add $t1,$t1,$t0
|
||||||
|
li $t0,8
|
||||||
|
add $t1,$t1,$t0
|
||||||
|
|
||||||
|
li $v0, 1
|
||||||
|
add $a0,$0,$t1
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $v0, 4
|
||||||
|
la $a0, end
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
.end main
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
# Write a program in MIPS that takes two values from the user and perform
|
||||||
|
# subtraction between them and then print the subtraction result.
|
||||||
|
|
||||||
|
.data
|
||||||
|
start: .asciiz "------ START Program Question 3 ------\n"
|
||||||
|
end: .asciiz "\n------ END Program Question 3 ------\n"
|
||||||
|
id: .asciiz "Student: Austin Bennett (CS 220, id: 324855)\n"
|
||||||
|
val1: .asciiz "First Value: "
|
||||||
|
val2: .asciiz "Second Value: "
|
||||||
|
tag: .asciiz "Result: "
|
||||||
|
value: .word 0
|
||||||
|
|
||||||
|
.text
|
||||||
|
.globl main
|
||||||
|
.ent main
|
||||||
|
main:
|
||||||
|
li $v0, 4
|
||||||
|
la $a0, start
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $v0, 4
|
||||||
|
la $a0, id
|
||||||
|
syscall
|
||||||
|
|
||||||
|
# Print 1
|
||||||
|
li $v0,4
|
||||||
|
la $a0,val1
|
||||||
|
syscall
|
||||||
|
|
||||||
|
# Read 1
|
||||||
|
li $v0, 5
|
||||||
|
syscall
|
||||||
|
move $t0,$v0
|
||||||
|
|
||||||
|
# Print 2
|
||||||
|
li $v0,4
|
||||||
|
la $a0,val2
|
||||||
|
syscall
|
||||||
|
|
||||||
|
# Read 2
|
||||||
|
li $v0,5
|
||||||
|
syscall
|
||||||
|
move $t1,$v0
|
||||||
|
|
||||||
|
sub $t0,$t0,$t1
|
||||||
|
sw $t0, value
|
||||||
|
|
||||||
|
li $v0,4
|
||||||
|
la $a0,tag
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $v0,1
|
||||||
|
lw $a0, value
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $v0, 4
|
||||||
|
la $a0, end
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $v0,10
|
||||||
|
syscall
|
||||||
|
.end main
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
.data
|
||||||
|
start: .asciiz "------ START Program Question 3 ------\n"
|
||||||
|
end: .asciiz "\n------ END Program Question 3 ------\n"
|
||||||
|
id: .asciiz "Student: Austin Bennett (CS 220, id: 324855)\n"
|
||||||
|
val: .word 65
|
||||||
|
|
||||||
|
.text
|
||||||
|
.globl main
|
||||||
|
.ent main
|
||||||
|
main:
|
||||||
|
li $v0, 4
|
||||||
|
la $a0, start
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $v0, 4
|
||||||
|
la $a0, id
|
||||||
|
syscall
|
||||||
|
|
||||||
|
lw $t0, val
|
||||||
|
|
||||||
|
|
||||||
|
move $t1, $t0
|
||||||
|
|
||||||
|
|
||||||
|
li $v0, 4
|
||||||
|
la $a0, end
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
.end main
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
.data
|
||||||
|
x: .word 30
|
||||||
|
y: .word 24
|
||||||
|
|
||||||
|
sum: .word 0
|
||||||
|
subt: .word 0
|
||||||
|
|
||||||
|
promptAdd: .asciiz "The sum of X and Y is : "
|
||||||
|
promptSub: .asciiz "\nThe difference of X and Y is : "
|
||||||
|
|
||||||
|
.text
|
||||||
|
.globl main
|
||||||
|
.ent main
|
||||||
|
|
||||||
|
main:
|
||||||
|
|
||||||
|
lw $a0, x
|
||||||
|
lw $a1, y
|
||||||
|
|
||||||
|
jal Addition
|
||||||
|
sw $v0, sum
|
||||||
|
|
||||||
|
jal Subtraction
|
||||||
|
sw $v0, subt
|
||||||
|
|
||||||
|
la $a0, promptAdd
|
||||||
|
li $v0, 4
|
||||||
|
syscall
|
||||||
|
|
||||||
|
lw $a0, sum
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
|
||||||
|
la $a0, promptSub
|
||||||
|
li $v0, 4
|
||||||
|
syscall
|
||||||
|
|
||||||
|
lw $a0, subt
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
|
||||||
|
.end main
|
||||||
|
|
||||||
|
.globl Addition
|
||||||
|
.ent Addition
|
||||||
|
|
||||||
|
Addition:
|
||||||
|
|
||||||
|
li $v0, 0
|
||||||
|
|
||||||
|
add $v0, $a0, $a1
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
|
||||||
|
.end Addition
|
||||||
|
|
||||||
|
.globl Subtraction
|
||||||
|
.ent Subtraction
|
||||||
|
|
||||||
|
Subtraction:
|
||||||
|
|
||||||
|
li $v0, 0
|
||||||
|
|
||||||
|
sub $v0, $a0, $a1
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
|
||||||
|
.end Subtraction
|
||||||
@@ -0,0 +1,286 @@
|
|||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 56;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
262DA11F2AB8CBA20099710A /* jiffies.c in Sources */ = {isa = PBXBuildFile; fileRef = 262DA11E2AB8CBA20099710A /* jiffies.c */; };
|
||||||
|
262DA1212AB8CBBB0099710A /* seconds.c in Sources */ = {isa = PBXBuildFile; fileRef = 262DA1202AB8CBBB0099710A /* seconds.c */; };
|
||||||
|
262DA1242AB93B540099710A /* filecopy.c in Sources */ = {isa = PBXBuildFile; fileRef = 262DA1232AB93B540099710A /* filecopy.c */; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
|
262DA1122AB8AFB50099710A /* CopyFiles */ = {
|
||||||
|
isa = PBXCopyFilesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
dstPath = /usr/share/man/man1/;
|
||||||
|
dstSubfolderSpec = 0;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 1;
|
||||||
|
};
|
||||||
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
262DA1142AB8AFB50099710A /* Homework 1 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "Homework 1"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
262DA11E2AB8CBA20099710A /* jiffies.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = jiffies.c; sourceTree = "<group>"; };
|
||||||
|
262DA1202AB8CBBB0099710A /* seconds.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = seconds.c; sourceTree = "<group>"; };
|
||||||
|
262DA1232AB93B540099710A /* filecopy.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = filecopy.c; sourceTree = "<group>"; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
262DA1112AB8AFB50099710A /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
262DA10B2AB8AFB50099710A = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
262DA1162AB8AFB50099710A /* Homework 1 */,
|
||||||
|
262DA1152AB8AFB50099710A /* Products */,
|
||||||
|
);
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
262DA1152AB8AFB50099710A /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
262DA1142AB8AFB50099710A /* Homework 1 */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
262DA1162AB8AFB50099710A /* Homework 1 */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
262DA11E2AB8CBA20099710A /* jiffies.c */,
|
||||||
|
262DA1202AB8CBBB0099710A /* seconds.c */,
|
||||||
|
262DA1232AB93B540099710A /* filecopy.c */,
|
||||||
|
);
|
||||||
|
path = "Homework 1";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
262DA1132AB8AFB50099710A /* Homework 1 */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = 262DA11B2AB8AFB50099710A /* Build configuration list for PBXNativeTarget "Homework 1" */;
|
||||||
|
buildPhases = (
|
||||||
|
262DA1102AB8AFB50099710A /* Sources */,
|
||||||
|
262DA1112AB8AFB50099710A /* Frameworks */,
|
||||||
|
262DA1122AB8AFB50099710A /* CopyFiles */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
name = "Homework 1";
|
||||||
|
productName = "Homework 1";
|
||||||
|
productReference = 262DA1142AB8AFB50099710A /* Homework 1 */;
|
||||||
|
productType = "com.apple.product-type.tool";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
262DA10C2AB8AFB50099710A /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
BuildIndependentTargetsInParallel = 1;
|
||||||
|
LastUpgradeCheck = 1430;
|
||||||
|
TargetAttributes = {
|
||||||
|
262DA1132AB8AFB50099710A = {
|
||||||
|
CreatedOnToolsVersion = 14.3.1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
buildConfigurationList = 262DA10F2AB8AFB50099710A /* Build configuration list for PBXProject "Homework 1" */;
|
||||||
|
compatibilityVersion = "Xcode 14.0";
|
||||||
|
developmentRegion = en;
|
||||||
|
hasScannedForEncodings = 0;
|
||||||
|
knownRegions = (
|
||||||
|
en,
|
||||||
|
Base,
|
||||||
|
);
|
||||||
|
mainGroup = 262DA10B2AB8AFB50099710A;
|
||||||
|
productRefGroup = 262DA1152AB8AFB50099710A /* Products */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
262DA1132AB8AFB50099710A /* Homework 1 */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
262DA1102AB8AFB50099710A /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
262DA11F2AB8CBA20099710A /* jiffies.c in Sources */,
|
||||||
|
262DA1212AB8CBBB0099710A /* seconds.c in Sources */,
|
||||||
|
262DA1242AB93B540099710A /* filecopy.c in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
262DA1192AB8AFB50099710A /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
ENABLE_TESTABILITY = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
"$(inherited)",
|
||||||
|
);
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = 13.3;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
|
SDKROOT = macosx;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
262DA11A2AB8AFB50099710A /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = 13.3;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
SDKROOT = macosx;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
262DA11C2AB8AFB50099710A /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
262DA11D2AB8AFB50099710A /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
262DA10F2AB8AFB50099710A /* Build configuration list for PBXProject "Homework 1" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
262DA1192AB8AFB50099710A /* Debug */,
|
||||||
|
262DA11A2AB8AFB50099710A /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
262DA11B2AB8AFB50099710A /* Build configuration list for PBXNativeTarget "Homework 1" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
262DA11C2AB8AFB50099710A /* Debug */,
|
||||||
|
262DA11D2AB8AFB50099710A /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
};
|
||||||
|
rootObject = 262DA10C2AB8AFB50099710A /* Project object */;
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "self:">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>IDEDidComputeMac32BitWarning</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>SchemeUserState</key>
|
||||||
|
<dict>
|
||||||
|
<key>Homework 1.xcscheme_^#shared#^_</key>
|
||||||
|
<dict>
|
||||||
|
<key>orderHint</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#define BUFFER_SIZE 4096
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
char sourceFileName[256];
|
||||||
|
char destinationFileName[256];
|
||||||
|
int sourceFile, destinationFile;
|
||||||
|
ssize_t bytes_read, bytes_written;
|
||||||
|
char buffer[BUFFER_SIZE];
|
||||||
|
|
||||||
|
printf("Enter the source file name: ");
|
||||||
|
scanf("%255s", sourceFileName);
|
||||||
|
printf("Enter the destination file name: ");
|
||||||
|
scanf("%255s", destinationFileName);
|
||||||
|
|
||||||
|
sourceFile = open(sourceFileName, O_RDONLY);
|
||||||
|
|
||||||
|
destinationFile = open(destinationFileName, O_WRONLY | O_CREAT | O_EXCL, 0666);
|
||||||
|
|
||||||
|
|
||||||
|
// Copy data from source to destination
|
||||||
|
while ((bytes_read = read(sourceFile, buffer, BUFFER_SIZE)) > 0) {
|
||||||
|
bytes_written = write(destinationFile, buffer, bytes_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close files
|
||||||
|
close(sourceFile);
|
||||||
|
close(destinationFile);
|
||||||
|
|
||||||
|
printf("File copied successfully!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
/**
|
||||||
|
* hello.c
|
||||||
|
*
|
||||||
|
* Kernel module that communicates with /proc file system.
|
||||||
|
*
|
||||||
|
* The makefile must be modified to compile this program.
|
||||||
|
* Change the line "simple.o" to "hello.o"
|
||||||
|
*
|
||||||
|
* Operating System Concepts - 10th Edition
|
||||||
|
* Copyright John Wiley & Sons - 2018
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <linux/init.h>
|
||||||
|
#include <linux/module.h>
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/proc_fs.h>
|
||||||
|
#include <linux/uaccess.h>
|
||||||
|
|
||||||
|
#define BUFFER_SIZE 128
|
||||||
|
|
||||||
|
#define PROC_NAME "jiffies"
|
||||||
|
#define MESSAGE "Hello World\n"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function prototypes
|
||||||
|
*/
|
||||||
|
ssize_t proc_read(struct file *file, char *buf, size_t count, loff_t *pos);
|
||||||
|
|
||||||
|
static struct file_operations proc_ops = {
|
||||||
|
.owner = THIS_MODULE,
|
||||||
|
.read = proc_read,
|
||||||
|
};
|
||||||
|
|
||||||
|
static long start_jiffies;
|
||||||
|
|
||||||
|
/* This function is called when the module is loaded. */
|
||||||
|
int proc_init(void)
|
||||||
|
{
|
||||||
|
start_jiffies = jiffies;
|
||||||
|
// creates the /proc/hello entry
|
||||||
|
// the following function call is a wrapper for
|
||||||
|
// proc_create_data() passing NULL as the last argument
|
||||||
|
proc_create(PROC_NAME, 0, NULL, &proc_ops);
|
||||||
|
|
||||||
|
printk(KERN_INFO "/proc/%s created\n", PROC_NAME);
|
||||||
|
printk(KERN_INFO "Jiffies: %lu\n", jiffies);
|
||||||
|
printk(KERN_INFO "HZ: %lu\n", HZ);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function is called when the module is removed. */
|
||||||
|
void proc_exit(void) {
|
||||||
|
|
||||||
|
// removes the /proc/hello entry
|
||||||
|
remove_proc_entry(PROC_NAME, NULL);
|
||||||
|
|
||||||
|
printk( KERN_INFO "/proc/%s removed\n", PROC_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is called each time the /proc/hello is read.
|
||||||
|
*
|
||||||
|
* This function is called repeatedly until it returns 0, so
|
||||||
|
* there must be logic that ensures it ultimately returns 0
|
||||||
|
* once it has collected the data that is to go into the
|
||||||
|
* corresponding /proc file.
|
||||||
|
*
|
||||||
|
* params:
|
||||||
|
*
|
||||||
|
* file:
|
||||||
|
* buf: buffer in user space
|
||||||
|
* count:
|
||||||
|
* pos:
|
||||||
|
*/
|
||||||
|
ssize_t proc_read(struct file *file, char __user *usr_buf, size_t count, loff_t *pos)
|
||||||
|
{
|
||||||
|
int rv = 0;
|
||||||
|
char buffer[BUFFER_SIZE];
|
||||||
|
static int completed = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if (completed) {
|
||||||
|
completed = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
completed = 1;
|
||||||
|
|
||||||
|
rv = sprintf(buffer, "Jiffies: %lu\n\n", jiffies);
|
||||||
|
|
||||||
|
// copies the contents of buffer to userspace usr_buf
|
||||||
|
copy_to_user(usr_buf, buffer, rv);
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Macros for registering module entry and exit points. */
|
||||||
|
module_init( proc_init );
|
||||||
|
module_exit( proc_exit );
|
||||||
|
|
||||||
|
MODULE_LICENSE("GPL");
|
||||||
|
MODULE_DESCRIPTION("Hello Module");
|
||||||
|
MODULE_AUTHOR("SGG");
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
/**
|
||||||
|
* seconds.c
|
||||||
|
*
|
||||||
|
* Kernel module that communicates with /proc file system.
|
||||||
|
*
|
||||||
|
* The makefile must be modified to compile this program.
|
||||||
|
* Change the line "simple.o" to "hello.o"
|
||||||
|
*
|
||||||
|
* Operating System Concepts - 10th Edition
|
||||||
|
* Copyright John Wiley & Sons - 2018
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <linux/init.h>
|
||||||
|
#include <linux/module.h>
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/proc_fs.h>
|
||||||
|
#include <linux/uaccess.h>
|
||||||
|
|
||||||
|
#define BUFFER_SIZE 128
|
||||||
|
|
||||||
|
#define PROC_NAME "seconds"
|
||||||
|
#define MESSAGE "Hello World\n"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function prototypes
|
||||||
|
*/
|
||||||
|
ssize_t proc_read(struct file *file, char *buf, size_t count, loff_t *pos);
|
||||||
|
|
||||||
|
static struct file_operations proc_ops = {
|
||||||
|
.owner = THIS_MODULE,
|
||||||
|
.read = proc_read,
|
||||||
|
};
|
||||||
|
|
||||||
|
static long start_jiffies;
|
||||||
|
|
||||||
|
/* This function is called when the module is loaded. */
|
||||||
|
int proc_init(void)
|
||||||
|
{
|
||||||
|
start_jiffies = jiffies;
|
||||||
|
// creates the /proc/hello entry
|
||||||
|
// the following function call is a wrapper for
|
||||||
|
// proc_create_data() passing NULL as the last argument
|
||||||
|
proc_create(PROC_NAME, 0, NULL, &proc_ops);
|
||||||
|
|
||||||
|
printk(KERN_INFO "/proc/%s created\n", PROC_NAME);
|
||||||
|
printk(KERN_INFO "Jiffies: %lu\n", jiffies);
|
||||||
|
printk(KERN_INFO "HZ: %lu\n", HZ);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function is called when the module is removed. */
|
||||||
|
void proc_exit(void) {
|
||||||
|
|
||||||
|
// removes the /proc/hello entry
|
||||||
|
remove_proc_entry(PROC_NAME, NULL);
|
||||||
|
|
||||||
|
printk( KERN_INFO "/proc/%s removed\n", PROC_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is called each time the /proc/hello is read.
|
||||||
|
*
|
||||||
|
* This function is called repeatedly until it returns 0, so
|
||||||
|
* there must be logic that ensures it ultimately returns 0
|
||||||
|
* once it has collected the data that is to go into the
|
||||||
|
* corresponding /proc file.
|
||||||
|
*
|
||||||
|
* params:
|
||||||
|
*
|
||||||
|
* file:
|
||||||
|
* buf: buffer in user space
|
||||||
|
* count:
|
||||||
|
* pos:
|
||||||
|
*/
|
||||||
|
ssize_t proc_read(struct file *file, char __user *usr_buf, size_t count, loff_t *pos)
|
||||||
|
{
|
||||||
|
int rv = 0;
|
||||||
|
char buffer[BUFFER_SIZE];
|
||||||
|
static int completed = 0;
|
||||||
|
|
||||||
|
long seconds = (jiffies - start_jiffies) / HZ;
|
||||||
|
|
||||||
|
if (completed) {
|
||||||
|
completed = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
completed = 1;
|
||||||
|
|
||||||
|
rv = sprintf(buffer, "Seconds Elapsed: %lu\n\n", seconds);
|
||||||
|
|
||||||
|
// copies the contents of buffer to userspace usr_buf
|
||||||
|
copy_to_user(usr_buf, buffer, rv);
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Macros for registering module entry and exit points. */
|
||||||
|
module_init( proc_init );
|
||||||
|
module_exit( proc_exit );
|
||||||
|
|
||||||
|
MODULE_LICENSE("GPL");
|
||||||
|
MODULE_DESCRIPTION("Hello Module");
|
||||||
|
MODULE_AUTHOR("SGG");
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
/**
|
||||||
|
* Records the amount of time to run a command.
|
||||||
|
* Uses shared memory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/shm.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
const char *name = "v1";
|
||||||
|
const int SIZE = 24;
|
||||||
|
|
||||||
|
struct timeval start;
|
||||||
|
struct timeval end;
|
||||||
|
pid_t pid;
|
||||||
|
int shm_fd;
|
||||||
|
char *ptr;
|
||||||
|
|
||||||
|
if (argc == 1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
shm_fd = shm_open(name, O_CREAT | O_RDWR, 0666);
|
||||||
|
|
||||||
|
if (shm_fd == -1) {
|
||||||
|
printf("shared memory creation failed\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ftruncate(shm_fd, SIZE);
|
||||||
|
|
||||||
|
ptr = (char *)mmap(0, SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0);
|
||||||
|
|
||||||
|
if (ptr == MAP_FAILED) {
|
||||||
|
printf("memory map failed\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pid = fork();
|
||||||
|
|
||||||
|
if (pid == 0)
|
||||||
|
{
|
||||||
|
// child
|
||||||
|
if (gettimeofday(&start, NULL) != 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Write the starting time to shared memory
|
||||||
|
sprintf(ptr, "%ld %ld", start.tv_sec, start.tv_usec);
|
||||||
|
// Execute the command
|
||||||
|
if (execvp(argv[1], &argv[1]) == -1) {
|
||||||
|
perror("execvp");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
// Parent
|
||||||
|
wait(NULL);
|
||||||
|
|
||||||
|
if (gettimeofday(&end, NULL) != 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
printf("\nParent ending time = %ld sec, %ld microsec\n",end.tv_sec, end.tv_usec);
|
||||||
|
|
||||||
|
// Read the starting time from shared memory
|
||||||
|
long start_sec, start_usec;
|
||||||
|
sscanf(ptr, "%ld %ld", &start_sec, &start_usec);
|
||||||
|
|
||||||
|
// Determine elapsed time
|
||||||
|
long elapsed_sec = end.tv_sec - start_sec;
|
||||||
|
long elapsed_usec = end.tv_usec - start_usec;
|
||||||
|
if (elapsed_usec < 0) {
|
||||||
|
elapsed_sec--;
|
||||||
|
elapsed_usec += 1000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Elapsed time = %ld sec, %ld microsec\n", elapsed_sec, elapsed_usec);
|
||||||
|
|
||||||
|
shm_unlink(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* ZombieCode.c
|
||||||
|
* This small program generates a zombie process.
|
||||||
|
*
|
||||||
|
* A zombie process is created when a process terminates,
|
||||||
|
* but the parent does not invoke wait(), but the parent
|
||||||
|
* continues to run. By not invoking wait(), the child
|
||||||
|
* process maintains an entry in the process entry table
|
||||||
|
* as well as maintaining its pid.
|
||||||
|
*
|
||||||
|
* Pretty simple to do:
|
||||||
|
*
|
||||||
|
* (1) Create a child process
|
||||||
|
* (2) Have the parent run for a specified amount of time.
|
||||||
|
*
|
||||||
|
* If this program is run in the background, the state of the child
|
||||||
|
* process illustrates it is a zombie process.
|
||||||
|
* (Z underneath the S field using ps)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
pid = fork();
|
||||||
|
|
||||||
|
if (pid < 0) {
|
||||||
|
fprintf(stderr,"Unable to create child process\n");
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if (pid == 0) {
|
||||||
|
/**
|
||||||
|
* Just have the child exit
|
||||||
|
* and turn into a zombie.
|
||||||
|
*/
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
// [FILL UP] Have the parent sleep for 15 seconds
|
||||||
|
sleep(15);
|
||||||
|
|
||||||
|
printf("Parent exiting\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 106 KiB |
|
After Width: | Height: | Size: 40 KiB |
@@ -0,0 +1,96 @@
|
|||||||
|
#include <pthread.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
/* the list of integers */
|
||||||
|
int *list;
|
||||||
|
int num_of_args;
|
||||||
|
|
||||||
|
/* the threads will set these values */
|
||||||
|
double average;
|
||||||
|
int maximum;
|
||||||
|
int minimum;
|
||||||
|
|
||||||
|
void *calculate_average(void *param);
|
||||||
|
void *calculate_maximum(void *param);
|
||||||
|
void *calculate_minimum(void *param);
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
num_of_args = argc-1;
|
||||||
|
pthread_t tid_1;
|
||||||
|
pthread_t tid_2;
|
||||||
|
pthread_t tid_3;
|
||||||
|
|
||||||
|
/* allocate memory to hold array of integers */
|
||||||
|
list = malloc(sizeof(int)*num_of_args);
|
||||||
|
|
||||||
|
for (i = 0; i < num_of_args; i++)
|
||||||
|
list[i] = atoi(argv[i+1]);
|
||||||
|
|
||||||
|
/* create the threads */
|
||||||
|
//-------------[TO BE COMPLETED]-------------
|
||||||
|
pthread_create(&tid_1, NULL, calculate_average, NULL);
|
||||||
|
pthread_create(&tid_2, NULL, calculate_maximum, NULL);
|
||||||
|
pthread_create(&tid_3, NULL, calculate_minimum, NULL);
|
||||||
|
|
||||||
|
/* wait for the threads to exit */
|
||||||
|
//-------------[TO BE COMPLETED]-------------
|
||||||
|
pthread_join(tid_1, NULL);
|
||||||
|
pthread_join(tid_2, NULL);
|
||||||
|
pthread_join(tid_3, NULL);
|
||||||
|
|
||||||
|
printf("The average is %f\n", average);
|
||||||
|
printf("The maximum is %d\n", maximum);
|
||||||
|
printf("The minimum is %d\n", minimum);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *calculate_average(void *param)
|
||||||
|
{
|
||||||
|
//-------------[TO BE COMPLETED]-------------
|
||||||
|
double sum = 0.0;
|
||||||
|
|
||||||
|
for (int i = 0; i < num_of_args; i++)
|
||||||
|
{
|
||||||
|
sum += list[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
average = sum / num_of_args;
|
||||||
|
pthread_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *calculate_maximum(void *param)
|
||||||
|
{
|
||||||
|
//-------------[TO BE COMPLETED]-------------
|
||||||
|
maximum = list[0];
|
||||||
|
|
||||||
|
for (int i = 1; i < num_of_args; i++)
|
||||||
|
{
|
||||||
|
if (list[i] > maximum)
|
||||||
|
{
|
||||||
|
maximum = list[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *calculate_minimum(void *param)
|
||||||
|
{
|
||||||
|
//-------------[TO BE COMPLETED]-------------
|
||||||
|
minimum = list[0];
|
||||||
|
|
||||||
|
for (int i = 1; i < num_of_args; i++)
|
||||||
|
{
|
||||||
|
if (list[i] < minimum)
|
||||||
|
{
|
||||||
|
minimum = list[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_exit(0);
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
#include <pthread.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
/* the list of integers */
|
||||||
|
int *list;
|
||||||
|
|
||||||
|
/* the threads will set these values */
|
||||||
|
double average;
|
||||||
|
int maximum;
|
||||||
|
int minimum;
|
||||||
|
|
||||||
|
void *calculate_average(void *param);
|
||||||
|
void *calculate_maximum(void *param);
|
||||||
|
void *calculate_minimum(void *param);
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int num_of_args = argc-1;
|
||||||
|
pthread_t tid_1;
|
||||||
|
pthread_t tid_2;
|
||||||
|
pthread_t tid_3;
|
||||||
|
|
||||||
|
/* allocate memory to hold array of integers */
|
||||||
|
list = malloc(sizeof(int)*num_of_args);
|
||||||
|
|
||||||
|
for (i = 0; i < num_of_args; i++)
|
||||||
|
list[i] = atoi(argv[i+1]);
|
||||||
|
|
||||||
|
/* create the threads */
|
||||||
|
//-------------[TO BE COMPLETED]-------------
|
||||||
|
pthread_create(&tid_1, NULL, calculate_average, NULL);
|
||||||
|
pthread_create(&tid_2, NULL, calculate_maximum, NULL);
|
||||||
|
pthread_create(&tid_3, NULL, calculate_minimum, NULL);
|
||||||
|
|
||||||
|
/* wait for the threads to exit */
|
||||||
|
//-------------[TO BE COMPLETED]-------------
|
||||||
|
pthread_join(tid_1, NULL);
|
||||||
|
pthread_join(tid_2, NULL);
|
||||||
|
pthread_join(tid_3, NULL);
|
||||||
|
|
||||||
|
printf("The average is %f\n", average);
|
||||||
|
printf("The maximum is %d\n", maximum);
|
||||||
|
printf("The minimum is %d\n", minimum);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *calculate_average(void *param)
|
||||||
|
{
|
||||||
|
//-------------[TO BE COMPLETED]-------------
|
||||||
|
double sum = 0.0;
|
||||||
|
int num_of_args = argc - 1;
|
||||||
|
|
||||||
|
for (int i = 0; i < num_of_args; i++)
|
||||||
|
{
|
||||||
|
sum += list[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
average = sum / num_of_args;
|
||||||
|
pthread_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *calculate_maximum(void *param)
|
||||||
|
{
|
||||||
|
//-------------[TO BE COMPLETED]-------------
|
||||||
|
int num_of_args = argc - 1;
|
||||||
|
maximum = list[0];
|
||||||
|
|
||||||
|
for (int i = 1; i < num_of_args; i++)
|
||||||
|
{
|
||||||
|
if (list[i] > maximum)
|
||||||
|
{
|
||||||
|
maximum = list[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *calculate_minimum(void *param)
|
||||||
|
{
|
||||||
|
//-------------[TO BE COMPLETED]-------------
|
||||||
|
int num_of_args = argc - 1;
|
||||||
|
minimum = list[0];
|
||||||
|
|
||||||
|
for (int i = 1; i < num_of_args; i++)
|
||||||
|
{
|
||||||
|
if (list[i] < minimum)
|
||||||
|
{
|
||||||
|
minimum = list[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_exit(0);
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
#include <pthread.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define SIZE 10
|
||||||
|
#define NUMBER_OF_THREADS 3
|
||||||
|
|
||||||
|
void *sorter(void *params); /* thread that performs basic sorting algorithm */
|
||||||
|
void *merger(void *params); /* thread that performs merging of results */
|
||||||
|
|
||||||
|
int list[SIZE] = {7,12,19,3,18,4,2,6,15,8};
|
||||||
|
|
||||||
|
int result[SIZE];
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int from_index;
|
||||||
|
int to_index;
|
||||||
|
} parameters;
|
||||||
|
|
||||||
|
int main (int argc, const char * argv[])
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
pthread_t workers[NUMBER_OF_THREADS];
|
||||||
|
|
||||||
|
/* establish the first sorting thread */
|
||||||
|
parameters *data = (parameters *) malloc (sizeof(parameters));
|
||||||
|
data->from_index = 0;
|
||||||
|
data->to_index = (SIZE/2) - 1;
|
||||||
|
pthread_create(&workers[0], 0, sorter, data);
|
||||||
|
|
||||||
|
/* establish the second sorting thread */
|
||||||
|
data = (parameters *) malloc (sizeof(parameters));
|
||||||
|
data->from_index = SIZE/2;
|
||||||
|
data->to_index = SIZE - 1;
|
||||||
|
pthread_create(&workers[1], 0, sorter, data);
|
||||||
|
|
||||||
|
/* now wait for the 2 sorting threads to finish */
|
||||||
|
for(i = 0; i < NUMBER_OF_THREADS - 1; i++)
|
||||||
|
pthread_join(workers[i], NULL);
|
||||||
|
|
||||||
|
/* establish the merge thread */
|
||||||
|
data = (parameters *) malloc(sizeof(parameters));
|
||||||
|
data->from_index = 0;
|
||||||
|
data->to_index = SIZE/2;
|
||||||
|
pthread_create(&workers[2], 0, merger, data);
|
||||||
|
|
||||||
|
/* wait for the merge thread to finish */
|
||||||
|
pthread_join(workers[2], NULL);
|
||||||
|
|
||||||
|
/* output the sorted array */
|
||||||
|
for (i = 0; i < SIZE; i++)
|
||||||
|
printf("%d ",result[i]);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sorting thread.
|
||||||
|
*
|
||||||
|
* This thread can essentially use any algorithm for sorting
|
||||||
|
*/
|
||||||
|
|
||||||
|
void *sorter(void *params)
|
||||||
|
{
|
||||||
|
int i,j,temp;
|
||||||
|
parameters* p = (parameters *)params;
|
||||||
|
|
||||||
|
int begin = p->from_index;
|
||||||
|
int end = p->to_index;
|
||||||
|
|
||||||
|
// simple bubble sort
|
||||||
|
for(i=begin;i<=end;i++){
|
||||||
|
for(j=i+1;j<=end;j++){
|
||||||
|
if(list[i]>list[j]){
|
||||||
|
temp=list[i];
|
||||||
|
list[i]=list[j];
|
||||||
|
list[j]=temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merge thread
|
||||||
|
*
|
||||||
|
* Uses simple merge sort for merging two sublists
|
||||||
|
*/
|
||||||
|
|
||||||
|
void *merger(void *params)
|
||||||
|
{
|
||||||
|
parameters* p = (parameters *)params;
|
||||||
|
|
||||||
|
int i,j;
|
||||||
|
|
||||||
|
i = p->from_index;
|
||||||
|
j = p->to_index;
|
||||||
|
|
||||||
|
int position = 0; /* position being inserted into result list */
|
||||||
|
|
||||||
|
while (i < p->to_index && j < SIZE) {
|
||||||
|
if (list[i] <= list[j]) {
|
||||||
|
result[position++] = list[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result[position++] = list[j];
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* copy the remainder */
|
||||||
|
if (i < p->to_index) {
|
||||||
|
while (i < p->to_index) {
|
||||||
|
result[position] = list[i];
|
||||||
|
position++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
while (j < SIZE) {
|
||||||
|
result[position] = list[j];
|
||||||
|
position++;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pthread_exit(0);
|
||||||
|
}
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
//CS 321: Skeleton code for multithreaded sorting program
|
||||||
|
//Feel free to modify the code as you wish.
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define SIZE 10
|
||||||
|
#define NUMBER_OF_THREADS 3
|
||||||
|
|
||||||
|
void *sorter(void *params); /* thread that performs basic sorting algorithm */
|
||||||
|
void *merger(void *params); /* thread that performs merging of results */
|
||||||
|
|
||||||
|
int list[SIZE] = {7,12,19,3,18,4,2,6,15,8};
|
||||||
|
|
||||||
|
int result[SIZE];
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int from_index;
|
||||||
|
int to_index;
|
||||||
|
} parameters;
|
||||||
|
|
||||||
|
int main (int argc, const char * argv[])
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
pthread_t workers[NUMBER_OF_THREADS];
|
||||||
|
|
||||||
|
/* establish the first sorting thread */
|
||||||
|
parameters *data = (parameters *) malloc (sizeof(parameters));
|
||||||
|
data->from_index = 0;
|
||||||
|
data->to_index = (SIZE/2) - 1;
|
||||||
|
pthread_create(&workers[0], 0, sorter, data);
|
||||||
|
|
||||||
|
/* establish the second sorting thread */
|
||||||
|
//-------------[TO BE COMPLETED]-------------
|
||||||
|
|
||||||
|
|
||||||
|
/* now wait for the 2 sorting threads to finish */
|
||||||
|
//-------------[TO BE COMPLETED]-------------
|
||||||
|
|
||||||
|
|
||||||
|
/* establish the merge thread */
|
||||||
|
//-------------[TO BE COMPLETED]-------------
|
||||||
|
|
||||||
|
|
||||||
|
/* wait for the merge thread to finish */
|
||||||
|
//-------------[TO BE COMPLETED]-------------
|
||||||
|
|
||||||
|
/* output the sorted array */
|
||||||
|
for (i = 0; i < SIZE; i++)
|
||||||
|
printf("%d ",result[i]);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sorting thread.
|
||||||
|
*
|
||||||
|
* This thread can essentially use any algorithm for sorting
|
||||||
|
*/
|
||||||
|
|
||||||
|
void *sorter(void *params)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
parameters* p = (parameters *)params;
|
||||||
|
|
||||||
|
int begin = p->from_index;
|
||||||
|
int end = p->to_index;
|
||||||
|
|
||||||
|
//-------------[TO BE COMPLETED]-------------
|
||||||
|
|
||||||
|
pthread_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merge thread
|
||||||
|
*
|
||||||
|
* Uses simple merge sort for merging two sublists
|
||||||
|
*/
|
||||||
|
|
||||||
|
void *merger(void *params)
|
||||||
|
{
|
||||||
|
parameters* p = (parameters *)params;
|
||||||
|
|
||||||
|
int i,j;
|
||||||
|
|
||||||
|
i = p->from_index;
|
||||||
|
j = p->to_index;
|
||||||
|
|
||||||
|
int position = 0; /* position being inserted into result list */
|
||||||
|
|
||||||
|
while (i < p->to_index && j < SIZE) {
|
||||||
|
if (list[i] <= list[j]) {
|
||||||
|
result[position++] = list[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result[position++] = list[j];
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* copy the remainder */
|
||||||
|
if (i < p->to_index) {
|
||||||
|
while (i < p->to_index) {
|
||||||
|
result[position] = list[i];
|
||||||
|
position++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
while (j < SIZE) {
|
||||||
|
result[position] = list[j];
|
||||||
|
position++;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pthread_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||