-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 11.00 | ||
# Visual Studio 2010 | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project", "Project.vcxproj", "{4164AA65-1EF9-4E69-899B-D1BED776070B}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Win32 = Debug|Win32 | ||
Release|Win32 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{4164AA65-1EF9-4E69-899B-D1BED776070B}.Debug|Win32.ActiveCfg = Debug|Win32 | ||
{4164AA65-1EF9-4E69-899B-D1BED776070B}.Debug|Win32.Build.0 = Debug|Win32 | ||
{4164AA65-1EF9-4E69-899B-D1BED776070B}.Release|Win32.ActiveCfg = Release|Win32 | ||
{4164AA65-1EF9-4E69-899B-D1BED776070B}.Release|Win32.Build.0 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|Win32"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|Win32"> | ||
<Configuration>Release</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="main.cpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<MASM Include="assign4.asm" /> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>{4164AA65-1EF9-4E69-899B-D1BED776070B}</ProjectGuid> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<PlatformToolset>v120</PlatformToolset> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<PlatformToolset>v120</PlatformToolset> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" /> | ||
</ImportGroup> | ||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup> | ||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> | ||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir> | ||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir> | ||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<MASM> | ||
<IncludePaths>c:\Irvine</IncludePaths> | ||
</MASM> | ||
<Link> | ||
<AdditionalDependencies>user32.lib;irvine32.lib;%(AdditionalDependencies)</AdditionalDependencies> | ||
<AdditionalLibraryDirectories>c:\Irvine;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||
<SubSystem>Console</SubSystem> | ||
<RandomizedBaseAddress>false</RandomizedBaseAddress> | ||
<DataExecutionPrevention> | ||
</DataExecutionPrevention> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<Link> | ||
<RandomizedBaseAddress>false</RandomizedBaseAddress> | ||
<DataExecutionPrevention> | ||
</DataExecutionPrevention> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" /> | ||
</ImportGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
TITLE Calculating Modibonacci (Assign4.asm) | ||
|
||
;Chad Bartley | ||
; This program uses recursion to calculate the | ||
; Nth Modibonacci value | ||
|
||
.586 | ||
.model flat,C | ||
|
||
.code | ||
|
||
Modibonacci PROC | ||
|
||
|
||
push ebp | ||
mov ebp, esp | ||
sub esp, 4 ;reserve space for local variable | ||
mov eax, [ebp + 8] ; get N | ||
|
||
;Base case N = 3 | ||
cmp eax, 3 | ||
je N3 | ||
|
||
;Base case N = 2 | ||
cmp eax, 2 | ||
je N2 | ||
|
||
;Base case N = 1 | ||
cmp eax, 1 | ||
je N1 | ||
|
||
|
||
L1: | ||
|
||
dec eax ; N - 1 | ||
push eax | ||
call Modibonacci ; Alpha recursive call | ||
|
||
add esp, 4 ; counter "push eax" | ||
mov [ebp - 4], eax ; save eax to local | ||
mov eax, [ebp + 8] ;Get N | ||
sub eax, 2 ; N - 2 | ||
push eax | ||
|
||
call Modibonacci ; Beta recursive call | ||
|
||
add esp, 4 ; counter "push eax" | ||
mov ebx, [ebp - 4] ; get previous local value (N - 1) | ||
shr eax, 1 ; (N - 2)/2 | ||
add eax, ebx ; (N - 1) + (N - 2)/2 | ||
mov [ebp - 4], eax ;save (N - 1) + (N - 2)/2 to local | ||
mov eax, [ebp + 8] ; get N | ||
sub eax, 3 ;N - 3 | ||
push eax | ||
|
||
call Modibonacci ; Gamma recursive call | ||
|
||
add esp, 4 | ||
mov ebx, [ebp - 4] ; put previous value into ebx (N - 1) + (N - 2)/2 | ||
shr eax, 1 ; (N - 3)/ 2 | ||
add eax, ebx ; (N - 1) + (N - 2)/2 + (N - 3)/ 2 | ||
|
||
jmp Quit | ||
|
||
|
||
|
||
N1: | ||
|
||
mov eax, 1 ; First Modibonacci = 1 | ||
jmp Quit | ||
|
||
N2: | ||
|
||
mov eax, 2 ; Second Modibonacci = 2 | ||
jmp Quit | ||
|
||
N3: | ||
|
||
mov eax, 4 ; Third Modibonacci = 4 | ||
jmp Quit | ||
|
||
Quit: | ||
|
||
mov esp, ebp | ||
pop ebp | ||
|
||
ret | ||
|
||
Modibonacci ENDP | ||
END | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
#include <iostream> | ||
using namespace std; | ||
|
||
extern "C" unsigned int Modibonacci(unsigned int n); | ||
|
||
|
||
void main() | ||
{ | ||
unsigned int N; | ||
|
||
cout << "Calculate the Nth Modibonacci: "; | ||
cin >> N; | ||
|
||
cout << N << " Modibonacci = " << Modibonacci(N); | ||
cout << endl; | ||
} |