Added VERY old code. Very cringy to look at, but hey, we all had to start somewhere...

This commit is contained in:
2018-01-08 23:37:31 -08:00
parent 7b18f6a807
commit df19ed7631
141 changed files with 26107 additions and 0 deletions

View File

@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASM_Project", "Assignment1.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

View File

@@ -0,0 +1,79 @@
<?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>
<MASM Include="main.asm" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4164AA65-1EF9-4E69-899B-D1BED776070B}</ProjectGuid>
<ProjectName>ASM_Project</ProjectName>
</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>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Link>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<AdditionalLibraryDirectories>c:\Irvine;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Console</SubSystem>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalDependencies>user32.lib;irvine32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<MASM>
<IncludePaths>c:\Irvine</IncludePaths>
</MASM>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
</Project>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@@ -0,0 +1,59 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TITLE Assignment 1 (main.asm)
;Author: Corwin Perren
;Date: 1/19/2014
;Description:
; This program will request two numbers from the user, perform common
; mathematical calculations on them, and print the results
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INCLUDE Irvine32.inc
.data
ProgramTitle BYTE "CS 271 - Assignment 1",0dh,0ah,0
CreatorName BYTE "Creator: Corwin Peren",0dh,0ah,0
Prompt1 BYTE "Please enter the first number: ",0
Prompt2 BYTE "Please enter the second number: ",0
SumMessage BYTE "Sum: ",0
DifMessage BYTE "Difference: ",0
ProdMessage BYTE "Product: ",0
QuotMessage BYTE "Quotient: ",0
RemainMessage BYTE "Remainder: ",0
TermMessage BYTE "Computations Complete...",0dh,0ah,0
FirstNumber DWORD ?
SecondNumber DWORD ?
FinalSum DWORD ?
FinalDif DWORD ?
FinalProd DWORD ?
FinalQuot DWORD ?
FinalRemain DWORD ?
.code
NineToFive PROC uses EAX
mov eax, 9
call WriteInt
mov eax, 8
call WriteInt
mov eax, 7
call WriteInt
mov eax, 6
call WriteInt
mov eax, 5
call WriteInt
ret
NineToFive ENDP
main PROC
call NineToFive
exit
main ENDP
END main

View File

@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASM_Project", "Assignement 2.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

View File

@@ -0,0 +1,79 @@
<?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>
<MASM Include="main.asm" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4164AA65-1EF9-4E69-899B-D1BED776070B}</ProjectGuid>
<ProjectName>ASM_Project</ProjectName>
</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>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Link>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<AdditionalLibraryDirectories>c:\Irvine;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Console</SubSystem>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalDependencies>user32.lib;irvine32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<MASM>
<IncludePaths>c:\Irvine</IncludePaths>
</MASM>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
</Project>

View File

@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASM_Project", "Project 2.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

View File

@@ -0,0 +1,268 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TITLE Assignment 2 (main.asm)
;Author: Corwin Perren
;Date: 1/28/2014
;Description:
; This program will calculate and display the nth iteration of the fibonacci
; sequence for n values between 1 and 46
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INCLUDE Irvine32.inc
.data
ProgramTitle BYTE "CS 271 - Assignment 2",0
ProgrammersName BYTE "Programmed By: Corwin Perren",0
NamePrompt BYTE "By what name may I call you?",0
NamePrompt2 BYTE "Your name: ", 0
NameResponse BYTE "Welcome, ", 0
NameResponse2 BYTE ".", 0
FibPrompt BYTE "How many values of the fibonacci sequence would you like to calculate?", 0
FibPrompt2 BYTE "Enter a value from 1 to 46: ", 0
FibPromptIncorrect BYTE "Value was not between 1 and 46. Please try again.", 0
TabString BYTE 9, 0
ExtraTab DWORD 1346269
TryAgainMessage BYTE "Would you like to run the program again?", 0
TryAgainMessage2 BYTE "Answer (y/n): ", 0
IncorrectTryMessage BYTE "Please enter y or n....", 0
TermMessage BYTE "Goodbye, ", 0
TermMessage2 BYTE ".", 0
FibMax DWORD 46
FibMin DWORD 1
UserName BYTE 25 dup(0)
KeyAnswer BYTE 2 dup(0)
NumFib DWORD ?
FibVal DWORD 1
FibVal2 DWORD 1
CurCol DWORD 0
ColMax DWORD 5
Yep BYTE "y", 0
Nope BYTE "n", 0
.code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Simple procedure for printing a tab to the screen
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
InsertTab PROC
mov edx,OFFSET TabString ;Moves the tab character into the buffer
call WriteString ;Writes the tab to the screen
ret ;Returns out of the procedure
InsertTab ENDP
main PROC
call Clrscr ;Clears the screen
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Write title and programmers name to screen
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov edx,OFFSET ProgramTitle ;Gets title ready to print
call WriteString ;Prints title
call Crlf ;Prints a new line
mov edx,OFFSET ProgrammersName ;Gets programmers name ready to print
call WriteString ;Prints programmers name
call Crlf ;Prints newline
call Crlf ;Prints newline
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Prompt user for their name
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov edx,OFFSET NamePrompt ;Gets username prompt ready
call WriteString ;Prints username prompt
call Crlf ;Prints newline
mov edx,OFFSET NamePrompt2 ;Gets second half of username prompt ready
call WriteString ;Prints username prompt part 2
mov edx,OFFSET UserName ;Moves offset for username storage var into edx
mov ecx,SIZEOF UserName ;Sets max number of characters to read in
call ReadString ;Reads in username string from user
call Crlf ;Prints newline
call Crlf ;Prints newline
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Write user welcome message, with their name
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DoAgain:
call Clrscr ;Clears the screen to clean up output
mov edx,OFFSET NameResponse ;Gets the welcome message part 1 ready to print
call WriteString ;Prints welcome message part 1
mov edx,OFFSET UserName ;Gets username ready to print
call WriteString ;Prints username
mov edx,OFFSET NameResponse2 ;Gets welcome message part 2 redy to print
call WriteString ;Prints welcome message part 2
call Crlf ;Prints a new line
call Crlf ;Prints a new line
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Prompt user for number of fibonacci to calculate
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov edx,OFFSET FibPrompt ;Gets prompt for fibonacci number ready
call WriteString ;Prints fib prompt
call Crlf ;Prints a new line
jmp EnterNumber ;Jumps to enter number label to begin input
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;This prompt shows when the number enterred is not within 1 to 46
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IncorrectInput:
call Crlf ;Prints a new line
mov edx,OFFSET FibPromptIncorrect ;Gets incorrect range prompt ready to print
call WriteString ;Prints incorrect range prompt
call Crlf ;Prints a new line
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Main prompt and read-in of fibonacci value from user
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EnterNumber:
mov edx,OFFSET FibPrompt2 ;Get main number entry prompt ready to print
call WriteString ;Prints main input prompt
call ReadInt ;Reads in int from user
cmp eax, FibMin ;Checks if input is less than 1
jl IncorrectInput ;Jumps to incorrect input if true
cmp eax, FibMax ;Checks if input is greater than 46
jg IncorrectInput ;Jumps to incorrect input if true
mov NumFib, eax ;Copies number to variable if in correct range
call Crlf ;Prints a new line
mov FibVal, 1 ;Reset fib start vals
mov FibVal2, 1 ;Reset fib start vals
mov CurCol, 0 ;Reset current column position
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;This section prints the first fibonacci sequence value
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov eax, FibVal ;Gets first value of fibonacci sequence ready to print (1)
call WriteInt ;Writes value to screen
cmp NumFib, 1 ;Checks if only this one value should be displayed
je FibDone ;If true, jump to end of program
inc CurCol ;Increment column index
call InsertTab ;Prints tab for column alignment
call InsertTab ;Prints tab for column alignment
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;This section prints the second fibonacci sequence value
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Call WriteInt ;Prints the second value of the fibonacci sequence (also 1)
cmp NumFib, 2 ;Checks if only these two should be displayed
je FibDone ;If true, jump to end of program
inc CurCol ;Otherwise, increment column index
call InsertTab ;Prints tab for column alignment
call InsertTab ;Prints tab for column alignment
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Setup of registers for the impending loop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov ecx, NumFib ;Sets loop ecx value
sub ecx, 2 ;Subtracts two because of the first two have already been printed
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Main fibonacci calculation and print loop
;PSEUDO
;newval = FibVal2 + Fibval
;print newval
;FibVal = FibVal2
;FibVal2 = newval;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CalcFib:
mov eax, FibVal2 ;Moves most recent fibonacci value into one reg
add eax, FibVal ;Adds second to last to most recent
call WriteInt ;Prints this fibonacci value to screen
push FibVal2 ;Moves old most recent to temp spot for move
pop FibVal ;Replaces second to last old val
mov FibVal2, eax ;Moves new most recent val to FibVal2
call InsertTab ;Prints tab for column alignment
cmp eax, ExtraTab ;Check if output val requires extra tab on output
jl OneExtra ;Jump to extra tab output label if necessary
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Return jump point for extra tab printing to make output alignment nice
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MidCalcFib:
inc CurCol ;Increment column index
mov edx, CurCol ;Place index in reg for compare
cmp edx, ColMax ;Compare current col index with max
jne CalcFibLoop ;Jump to rest of loop if newline not needed
call Crlf ;Prints newline when needed
mov CurCol, 0 ;Resets current column index
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Jump location used for avoiding printing a newline from above
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CalcFibLoop:
loop CalcFib ;Loops fib calc sequence until ecx counter 0
jmp TryAgain ;Jumps to program end if loop done
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Jump location used for printing on screen tabs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
OneExtra:
call InsertTab ;Calls procedure to input tab when necessary
jmp MidCalcFib ;Jumps back to where it was called
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;This section deals with jumping if the user wants to calculate more values
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IncorrectTry:
call Crlf ;Prints a new line
mov edx,OFFSET IncorrectTryMessage ;Gets ready to print the incorrect try message
call Writestring ;Prints the incorrect try message
TryAgain:
call Crlf ;Prints a new line
call Crlf ;Prints a new line
mov edx,OFFSET TryAgainMessage ;Gets ready to print the try again message
call WriteString ;Prints the try again message
call Crlf ;Prints a new line
mov edx,OFFSET TryAgainMessage2 ;Gets ready to print the try again message part 2
call WriteString ;Prints the try again message 2
mov edx,OFFSET KeyAnswer ;Assigns edx to offset of keyanswer for keyboard input
mov ecx,SIZEOF KeyAnswer ;Sets number of characters to read in
call ReadString ;Reads in keyboard input
INVOKE Str_compare,OFFSET KeyAnswer,OFFSET Yep ;Uses a multi-input irvine procedure to do a string comparison
je DoAgain ;Jump to DoAgain if the user answered 'y'
INVOKE Str_compare,OFFSET KeyAnswer,OFFSET Nope ;Uses a multi-input irvine procedure to do a string comparison
je FibDone ;Jumps to end if user answered 'n'
jmp IncorrectTry ;Jumps to an incorrect input section if user enterred wrong values
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Section to show the termination message
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FibDone:
call Crlf ;Prints a new line
call Crlf ;Prints a new line
mov edx,OFFSET TermMessage ;Gets termination message part 1 ready to print
call WriteString ;Prints termination message
mov edx,OFFSET UserName ;Gets username ready to print
call WriteString ;Prints username
mov edx,OFFSET TermMessage2 ;Gets termination message part 2 ready to print
call WriteString ;Prints termination messag part 2
call Crlf ;Prints a new line
exit ;Ends main program
main ENDP
END main

View File

@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASM_Project", "Assignment3.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

View File

@@ -0,0 +1,79 @@
<?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>
<MASM Include="main.asm" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4164AA65-1EF9-4E69-899B-D1BED776070B}</ProjectGuid>
<ProjectName>ASM_Project</ProjectName>
</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>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Link>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<AdditionalLibraryDirectories>c:\Irvine;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Console</SubSystem>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalDependencies>user32.lib;irvine32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<MASM>
<IncludePaths>c:\Irvine</IncludePaths>
</MASM>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
</Project>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@@ -0,0 +1,441 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TITLE Assignment 5 (main.asm)
;Author: Corwin Perren
;Date: 3/3/2014
;Description:
; This program runs all three programs from assignment 5 from a menu screen
; These programs include an array reverser, frequency table generator, and
; prime number generator
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INCLUDE Irvine32.inc
.data
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Variables to change for testing program capabilities
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SieveArray BYTE 1000000 dup(?)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Globally relevant vars
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ProgramTitle BYTE "CS 271 - Assignment 5",0
ProgrammerName BYTE "Written by: Corwin Perren",0
SelectInstructions BYTE "Please enter 1-4 to run desired program.", 0
MenuItem1 BYTE "1: Reverse Array In Place (Chapter 4, Exercise 5)",0
MenuItem2 BYTE "2: Frequency Table (Chapter 9, Exercise 6)",0
MenuItem3 BYTE "3: Sieve of Eratosthenes (Chapter 9, Exercise 7)",0
MenuItem4 BYTE "4: Exit",0
Selection BYTE "Selection: ",0
IncorrectNumberEntry BYTE "You did not enter 1-4. Press enter to try again.", 0
ReturnToSelect BYTE "Program Complete. Press enter to return to selection screen.", 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Vars for Prog 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ArrayToReverse BYTE 1,2,3,4,5,6,7,8,9,10, 11, 12, 13, 14
PressEnter BYTE "Press enter to reverse the currently reversed array. Enter 1 to quit.", 0
OriginalArray BYTE "Original Array:", 0
ReversedArray BYTE "Reversed Array:", 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Vars for Prog 2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
StringEntry BYTE "Please enter a string to create a frequency table for.", 0
StringThing BYTE "Your string: ", 0
StringArray BYTE 256 dup(?)
FrequencyTable DWORD 256 dup(?)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Vars for Prog 3
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EnterPrimes1 BYTE "Press enter to calculate primes up to ", 0
EnterPrimes2 BYTE ".", 0
.code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for writing string with newline
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Write_String_NL PROC uses EDX,
StringPtr:Ptr BYTE ;Varible to store string offset pointer
mov edx, StringPtr ;Moves the string to the proper register
call WriteString ;Prints the string
call Crlf ;Prints a new line
ret ;Return from procedure
Write_String_NL ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for writing string without newline
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Write_String PROC uses EDX,
StringPtr:Ptr BYTE ;Variable to store string offset pointer
mov edx, StringPtr ;Moves the string to the proper registers
call WriteString ;Prints the string
ret
Write_String ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for printing program title and programmer name
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintTitle PROC
INVOKE Write_String_NL, OFFSET ProgramTitle ;Prints the program title
INVOKE Write_String_NL, OFFSET ProgrammerName ;prints the programmer's name
call Crlf ;Prints a new line
INVOKE Write_String_NL, OFFSET SelectInstructions ;Prints the selection screen instructions
call Crlf ;Prints a new line
INVOKE Write_String_NL, OFFSET MenuItem1 ;Prints menu item 1
INVOKE Write_String_NL, OFFSET MenuItem2 ;Prints menu item 2
INVOKE Write_String_NL, OFFSET MenuItem3 ;Prints menu item 3
INVOKE Write_String_NL, OFFSET MenuItem4 ;Prints menu item 4
INVOKE Write_String, OFFSET Selection ;Print selction prompt
ret
PrintTitle ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to fill array with zeros using stosb
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FillWithZeros PROC
mov al, 0 ;Set al with value we want to fill array with
cld ;Clear Direction Flag
mov edi, OFFSET SieveArray ;Point edi to array
mov ecx, LENGTHOF SieveArray ;Set counter so instruction knows when to end
dec ecx ;Subtract one because it's starting at zero instead of one
rep stosb ;Repeats the fill operation until the array is full
ret ;Returns from function
FillWithZeros ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to mark multiples of primes with ones
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MarkMultiples PROC
mov esi, OFFSET SieveArray ;Move into esi to get easy access
mov BYTE PTR [esi], 1 ;Mark zero as non-prime
mov BYTE PTR [esi+1], 1 ;Mark one as non-prime
mov eax, 2 ;Set cursor position
mov ebx, 2 ;Multiplication value
jmp Inner
Outer:
pop eax ;Pop eax if we got here so the stack gets aligned and we know where we are
LookForOne:
inc eax ;Go up by one
cmp BYTE PTR [esi+eax], 1 ;Check to see if the new value at that position of the array has been marked
je LookForOne ;If so, increment again to find an unmarked one
cmp eax, LENGTHOF SieveArray ;Once an unmarked is found, make sure it's not outside our array size
jg MultEnd ;If it's out of array bounds, we're done so exit
mov ebx, 2 ;Otherwise, get ready to mark multiples of current prime starting with two times the prime
Inner:
push eax ;Save our original prime we're using
mul ebx ;Multiply prime by scaler
cmp eax, LENGTHOF SieveArray ;Make sure new value is not out of array size
jg Outer ;If it is, we're done with this prime
mov BYTE PTR [esi+eax], 1 ;Otherwise, mark the multiple with a one
inc ebx ;Increase our scaler
pop eax ;Restore the prime we're on
jmp Inner ;Re-do for next scaler
MultEnd:
ret ;Return from procedure
MarkMultiples ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to print out unmarked values in array, which are primes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintPrimes PROC
mov esi, OFFSET SieveArray ;Load array into esi to get ready to print
mov eax, 0 ;Set our cursor to zero
LookForZeros:
inc eax ;Move cursor forward one
cmp eax, LENGTHOF SieveArray ;Check if cursor is out of array bounds
jg PrintExit ;If so, exit because we are done
cmp BYTE PTR [esi+eax], 1 ;If we're in bounds, check if the position is marked
je LookForZeros ;If so, don't print and look at the next position
call WriteDec ;If unmarked, print the prime number sotred here
call Crlf ;Print a new line to make things look nice
jmp LookForZeros ;Continue for the next array position
PrintExit:
ret ;Return from procedure
PrintPrimes ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to run program 3
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Program3 PROC
call ClrScr ;Clears the screen
INVOKE Write_String, OFFSET EnterPrimes1 ;Prints prompt part one
mov eax, LENGTHOF SieveArray ;Moves number of primes to calculate to print
call WriteDec ;Prints number of primes to calculate
INVOKE Write_String_NL, OFFSET EnterPrimes2 ;Prints end of prompt line
call ReadInt ;Waits for any key
call FillWithZeros ;Fills the sieve array with zeros using stosb method
call MarkMultiples ;Marks positions that are multiples of primes
call PrintPrimes ;Prints remaining prime numbers
ret ;Returns from procedure
Program3 ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to determine the character frequency of a string
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Get_Frequencies PROC InputString:PTR BYTE, OutputTable:PTR DWORD
mov esi, InputString ;Moves string to parse into esi
mov edi, OutputTable ;Moves output table into edi
FreqLoop:
mov eax, 0 ;Zeros eax to make things work right
mov al, BYTE PTR [esi] ;Moves ascii decimal value into eax
mov ecx, eax ;Saves current decimal value
mov ebx, 4 ;Multiply eax by four because it's stored in DWORD and not BYTE array
mul ebx ;Actual multiplication
add DWORD PTR [edi+eax], 1 ;Increments frequency table position by one for this character
cmp ecx, 0 ;Checks if we've hit the NUL character
je FreqDone ;Exit if it's found because we're done
inc esi ;Otherwise, move to the next string array position
jmp FreqLoop ;Do above again for next character
FreqDone:
ret ;Return from procedure
Get_Frequencies ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to read in string from user
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GetNewString PROC StringPtr:PTR BYTE
mov edx, StringPtr ;Move string array into edx for read in
mov ecx, 256 ;Read in a max of 256 characters
call ReadString ;Read in string from user
ret ;Exit from procedure
GetNewString ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to print out the frequency table
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintFreqTable PROC TablePtr:PTR DWORD
mov esi, TablePtr ;Move frequency table into esi
mov ecx, 256 ;Set number of elements
mov ebx, 4 ;Set size of storage elements
call DumpMem ;Dump memory for the array
ret
PrintFreqTable ENDP
ZeroProg2 PROC
mov eax, 0 ;Set al with value we want to fill array with
cld ;Clear Direction Flag
mov edi, OFFSET StringArray ;Point edi to array
mov ecx, 256 ;Set counter so instruction knows when to end
dec ecx ;Subtract one because it's starting at zero instead of one
rep stosb ;Repeats the fill operation until the array is full
mov eax, 0 ;Set al with value we want to fill array with
cld ;Clear Direction Flag
mov edi, OFFSET FrequencyTable ;Point edi to array
mov ecx, 1024 ;Set counter so instruction knows when to end
dec ecx ;Subtract one because it's starting at zero instead of one
rep stosb ;Repeats the fill operation until the array is full
ret ;Returns from function
ZeroProg2 ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to run program 2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Program2 PROC
call ClrScr ;Clear the screen
call ZeroProg2 ;Zeros string and freq table array
INVOKE Write_String_NL, OFFSET StringEntry ;Prompts the user to enter a string
INVOKE Write_String, OFFSET StringThing ;Line prompt for above
INVOKE GetNewString, OFFSET StringArray ;Reads in user string
INVOKE Get_Frequencies, OFFSET StringArray, OFFSET FrequencyTable ;Runs frequency procedure on input string
INVOKE PrintFreqTable, OFFSET FrequencyTable ;Prints out the new frequency table
ret ;Returns from procedure
Program2 ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to run program 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Program1 PROC
call ClrScr ;Clears the screen
INVOKE Write_String_NL, OFFSET OriginalArray ;Prints header for original array
mov eax, TYPE ArrayToReverse ;Moves the array type into eax
cmp eax, 1 ;Checks if it's a BYTE array
je ITSBYTE ;Jumps to BYTE section if so
cmp eax, 2 ;Checks if WORD array
je ITSWORD ;Jumps to WORD section if so
cmp eax, 4 ;Check if DWORD array
je ITSDWORD ;Jumps to DWORD section if so
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Run for BYTE Array
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ITSBYTE:
mov esi, OFFSET ArrayToReverse ;Moves array into esi
mov ecx, LENGTHOF ArrayToReverse ;Moves number of elements in array into ecx
mov ebx, TYPE ArrayToReverse ;Moves type of array into ebx
call DumpMem ;Shows original array
mov esi, OFFSET ArrayToReverse ;Re-moves array into esi
mov edi, OFFSET ArrayToReverse + SIZEOF ArrayToReverse - TYPE ArrayToReverse ;Moves the pointer to the last value of the array into edi
mov eax, LENGTHOF ArrayToReverse ;Moves number of elements in array into eax
mov edx, 0 ;Sets remainder to zero by default
mov ebx, 2 ;Moves two into ebx
div ebx ;Divides number of elements by two
mov ecx, eax ;Puts that number into our loop counter
ReverseBYTE:
mov bl, [esi] ;Move data at beginning cursor to tmp storage
mov dl, [edi] ;Move data at end cursor to tmp storage
mov [esi], dl ;Move end data to beginning
mov [edi], bl ;Move beginning data to end
add esi, TYPE ArrayToReverse ;Move beginning cursor forward
sub edi, TYPE ArrayToReverse ;Move ending cursor back
loop ReverseBYTE ;Loop until count expired
jmp Prog1Ret ;Jump to procedure end when done
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Run for WORD Array
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ITSWORD:
mov esi, OFFSET ArrayToReverse ;Moves array into esi
mov ecx, LENGTHOF ArrayToReverse ;Moves number of elements in array into ecx
mov ebx, TYPE ArrayToReverse ;Moves type of array into ebx
call DumpMem ;Shows original array
mov esi, OFFSET ArrayToReverse ;Re-moves array into esi
mov edi, OFFSET ArrayToReverse + SIZEOF ArrayToReverse - TYPE ArrayToReverse ;Moves the pointer to the last value of the array into edi
mov eax, LENGTHOF ArrayToReverse ;Moves number of elements in array into eax
mov edx, 0 ;Sets remainder to zero by default
mov ebx, 2 ;Moves two into ebx
div ebx ;Divides number of elements by two
mov ecx, eax ;Puts that number into our loop counter
ReverseWORD:
mov bx, [esi] ;Move data at beginning cursor to tmp storage
mov dx, [edi] ;Move data at end cursor to tmp storage
mov [esi], dx ;Move end data to beginning
mov [edi], bx ;Move beginning data to end
add esi, TYPE ArrayToReverse ;Move beginning cursor forward
sub edi, TYPE ArrayToReverse ;Move ending cursor back
loop ReverseWORD ;Loop until count expired
jmp Prog1Ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Run for DWORD Array
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ITSDWORD:
mov esi, OFFSET ArrayToReverse ;Moves array into esi
mov ecx, LENGTHOF ArrayToReverse ;Moves number of elements in array into ecx
mov ebx, TYPE ArrayToReverse ;Moves type of array into ebx
call DumpMem ;Shows original array
mov esi, OFFSET ArrayToReverse ;Re-moves array into esi
mov edi, OFFSET ArrayToReverse + SIZEOF ArrayToReverse - TYPE ArrayToReverse ;Moves the pointer to the last value of the array into edi
mov eax, LENGTHOF ArrayToReverse ;Moves number of elements in array into eax
mov edx, 0 ;Sets remainder to zero by default
mov ebx, 2 ;Moves two into ebx
div ebx ;Divides number of elements by two
mov ecx, eax ;Puts that number into our loop counter
ReverseDWORD:
mov ebx, [esi] ;Move data at beginning cursor to tmp storage
mov edx, [edi] ;Move data at end cursor to tmp storage
mov [esi], edx ;Move end data to beginning
mov [edi], ebx ;Move beginning data to end
add esi, TYPE ArrayToReverse ;Move beginning cursor forward
sub edi, TYPE ArrayToReverse ;Move ending cursor back
loop ReverseWORD ;Loop until count expired
Prog1Ret:
call Crlf ;Print a new line
call Crlf ;Print a second new line
INVOKE Write_String_NL, OFFSET ReversedArray ;Print header to say this is the reversed array
mov esi, OFFSET ArrayToReverse ;Move array into esi
mov ecx, LENGTHOF ArrayToReverse ;Set number of elements
mov ebx, TYPE ArrayToReverse ;Set size of elements
call DumpMem ;Display array
ret ;Return from procedure
Program1 ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Main Procedure
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
main PROC
MainTitle:
call ClrScr ;Clear screen
call PrintTitle ;Print the title screen
call ReadInt ;Read in user selection
cmp eax, 1 ;Check if user selected entry item 1
je Prog1Jmp ;If so, jump to that program
cmp eax, 2 ;Check if user selected entry item 2
je Prog2Jmp ;If so, jump to that program
cmp eax, 3 ;Check if user selected entry item 3
je Prog3Jmp ;If so, jump to that program
cmp eax, 4 ;Check if user selected exit
je MainExit ;If so, jump to end of program
call ClrScr ;Clear screeen
INVOKE Write_String_NL, OFFSET IncorrectNumberEntry ;Scold user for not entering one to four
call ReadInt ;Wait for enter key
jmp MainTitle ;Jump back to main screen
Prog1Jmp:
call Program1 ;Call array reverse program
call Crlf ;Print new line
INVOKE Write_String_NL, OFFSET ReturnToSelect ;Print hit enter to return to screen
call ReadInt ;Wait for enter
jmp MainTitle ;Jump to main screen
Prog2Jmp:
call Program2 ;Call String frequency program
call Crlf ;Print new line
INVOKE Write_String_NL, OFFSET ReturnToSelect ;Print hit enter to return to screen
call ReadInt ;Wait for enter
jmp MainTitle ;Jump to main screen
Prog3Jmp:
call Program3 ;Call prime generator program
call Crlf ;Print new line
INVOKE Write_String_NL, OFFSET ReturnToSelect ;Print hit enter to return to screen
call ReadInt ;Wait for enter
jmp MainTitle ;Jump to main screen
MainExit:
exit
main ENDP
END main

View File

@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASM_Project", "Assignment3.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

View File

@@ -0,0 +1,79 @@
<?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>
<MASM Include="Assignment4_perrenc.asm" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4164AA65-1EF9-4E69-899B-D1BED776070B}</ProjectGuid>
<ProjectName>ASM_Project</ProjectName>
</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>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Link>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<AdditionalLibraryDirectories>c:\Irvine;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Console</SubSystem>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalDependencies>user32.lib;irvine32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<MASM>
<IncludePaths>c:\Irvine</IncludePaths>
</MASM>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
</Project>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@@ -0,0 +1,254 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TITLE Assignment 3 (main.asm)
;Author: Corwin Perren
;Date: 2/05/2014
;Description:
; This program greets a user by name, takes in ten integers, sums
; non-negative ones, and computers the average of that sum before saying
; goodbye to the user
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INCLUDE Irvine32.inc
.data
ProgramTitle BYTE "CS 271 - Assignment 3",0
ProgrammerName BYTE "Written by: Corwin Perren",0
NamePrompt BYTE "By what name may I call you?",0
NamePrompt2 BYTE "Your name: ", 0
NameResponse BYTE "Welcome, ", 0
NameResponse2 BYTE ".", 0
EnterNumPrompt BYTE "Please enter ten numbers between 0 and 100.", 0
TooGreat BYTE "The number you entered was too large, please try again.", 0
IncorrectInputMessage BYTE "You did not enter a valid number.", 0
ListingPrint BYTE "Number ", 0
ListingPrint2 BYTE ":", 0
NoPosMessage BYTE "No Positive Integers Entered...", 0
NumPosMessage BYTE "Number of Positive Integers: ", 0
SumMessage BYTE "Sum of Positive Integers: ", 0
AvgMessage BYTE "Average of Positive Integers: ", 0
TermMessage BYTE "Goodbye, ", 0
TermMessage2 BYTE ".", 0
TESTMessage BYTE "Equal to Zero", 0
NumEntries DWORD 10
MaxEntryVal DWORD 100
StorArray DWORD 10 dup(0)
UserName BYTE 25 dup(0)
NumPos DWORD 0
FinalSum DWORD 0
FinalAvg DWORD 0
.code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for writing string with newline
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Write_String_NL PROC uses EDX,
StringPtr:Ptr BYTE ;Varible to store string offset pointer
mov edx, StringPtr ;Moves the string to the proper register
call WriteString ;Prints the string
call Crlf ;Prints a new line
ret
Write_String_NL ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for writing string without newline
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Write_String PROC uses EDX,
StringPtr:Ptr BYTE ;Variable to store string offset pointer
mov edx, StringPtr ;Moves the string to the proper registers
call WriteString ;Prints the string
ret
Write_String ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for printing program title and programmer name
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintTitle PROC
INVOKE Write_String_NL, OFFSET ProgramTitle ;Prints the program title
INVOKE Write_String_NL, OFFSET ProgrammerName ;prints the programmer's name'
call Crlf ;Prints a new line
ret
PrintTitle ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for getting user's name and greeting them
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MeetAndGreet PROC
INVOKE Write_String_NL, OFFSET NamePrompt ;Gets username prompt ready
INVOKE Write_String, OFFSET NamePrompt2 ;Gets second half of username prompt ready
mov edx,OFFSET UserName ;Moves offset for username storage var into edx
mov ecx,SIZEOF UserName ;Sets max number of characters to read in
call ReadString ;Reads in username string from user
call Clrscr ;Clears the screen to clean up output
INVOKE Write_String, OFFSET NameResponse ;Prints the first part of the welcome message
INVOKE Write_String, OFFSET UserName ;Prints the user's name
INVOKE Write_String_NL, OFFSET NameResponse2 ;Prints teh second half of the welcome message
call Crlf ;Prints a new line
ret
MeetAndGreet ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for printing what the user may enter
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintEnterNumPrompt PROC
INVOKE Write_String_NL, OFFSET EnterNumPrompt ;Gets welcome message part 2 redy to print
ret
PrintEnterNumPrompt ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for retreiving integer inputs from user
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GetNumbers PROC
mov ecx, NumEntries ;Sets loop count variable
mov esi, OFFSET StorArray ;Puts storage array into esi reg
jmp EnterNum ;Jump to beginning of number entry
IncorrectInput:
INVOKE Write_String_NL, OFFSET IncorrectInputMessage ;Displays incorrect input message
jmp EnterNum ;Jumps to beginning of number entry
GreaterThanMax:
INVOKE Write_String_NL, OFFSET TooGreat ;Displays number to great message
EnterNum:
INVOKE Write_String, OFFSET ListingPrint ;Prints number entry listing
mov eax, NumEntries ;Moves total entries to eax
inc eax ;Increments by one to start at 1 rather than 0
sub eax, ecx ;Subracts current loop var to determine count val
call WriteInt ;Writes for number entry listing
INVOKE Write_String, OFFSET ListingPrint2 ;Finishes priting number entry listing
call ReadInt ;Reads in int from user
jo IncorrectInput ;Re-do previous if incorrect input
cmp eax, MaxEntryVal ;Check if number too great
jg GreaterThanMax ;Jump if number too great
mov [esi], eax ;Move number if valid into array
add esi, 4 ;Increment array pointer
loop EnterNum ;Loop unti ecx equals 0
ret
GetNumbers ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for determining number of positive integers, summing them, and
;calculating their average
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CalcStuff PROC
mov ecx, NumEntries ;Puts loop counter in
mov esi, OFFSET StorArray ;Gets array ready to loop through
mov eax, 0 ;Makes sum register zero
ArrayLoop:
mov edx, [esi] ;Read out one array value
add esi, 4 ;Increment array pointer
cmp edx, 0 ;Check if negative
jl ArrayLoopEnd ;Jump to ignore if negative
add eax, edx ;If non-negative, add to sum reg
inc NumPos ;Increment number of positive found
ArrayLoopEnd:
loop ArrayLoop ;Loop until array empty
cmp NumPos, 0 ;Check if any positive found
jne MoreThanZero ;Jump if there are positive integers
Invoke Write_String_NL, OFFSET NoPosMessage ;Write no positive intergers message
jmp QuickEnd ;End program because no positive integers
MoreThanZero:
mov FinalSum, eax ;Move positive integers sum to variable
mov edx, 0 ;Zero upper of numerator
mov ebx, NumPos ;Put value in lower of numerator
div ebx ;Divide sum by number of positive integers
mov FinalAvg, eax ;Take result which is average and store in varible
call Crlf ;Print a new line
ret
CalcStuff ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Prints the number of positive integers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintNumPos PROC
Invoke Write_String, OFFSET NumPosMessage ;Print string for number of positive integers
mov eax, NumPos ;Move varaible into printing register
call WriteInt ;Print number of positive integers
call Crlf ;Print a new line
ret
PrintNumPos ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Prints the sum of the positive integers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintSumOf PROC
Invoke Write_String, OFFSET SumMessage ;Print the message for the sum
mov eax, FinalSum ;Move sum into printing register
call WriteInt ;Print sum
call Crlf ;Print new line
ret
PrintSumOf ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Prints the average of the positive integers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintAverageOf PROC
Invoke Write_String, OFFSET AvgMessage ;Print message for the average
mov eax, FinalAvg ;Move average into printing register
call WriteInt ;Print the average
call Crlf ;Print a new line
ret
PrintAverageOf ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for printing the termination message
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintTerm PROC
Invoke Write_String, OFFSET TermMessage ;Print the first part of the termination message
Invoke Write_String, OFFSET UserName ;Print the user's name
Invoke Write_String_NL, OFFSET TermMessage2 ;Print the second part of the termination message
ret
PrintTerm ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Main Procedure
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
main PROC
call PrintTitle ;Prints title
call MeetAndGreet ;Greets user by name
call PrintEnterNumPrompt ;Print prompt for program use
call GetNumbers ;Retrieves user integer entries
call CalcStuff ;Performs math on numbers entered
call PrintNumPos ;Prints number of positive integers
call PrintSumOf ;Prints sum of positive integers
call PrintAverageOf ;Prints average of positive integers
QuickEnd::
call PrintTerm ;Prints termination message
exit
main ENDP
END main

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASM_Project", "Assignment5.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

View File

@@ -0,0 +1,79 @@
<?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>
<MASM Include="CS271_proj5_perrenc.asm" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4164AA65-1EF9-4E69-899B-D1BED776070B}</ProjectGuid>
<ProjectName>ASM_Project</ProjectName>
</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>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Link>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<AdditionalLibraryDirectories>c:\Irvine;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Console</SubSystem>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalDependencies>user32.lib;irvine32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<MASM>
<IncludePaths>c:\Irvine</IncludePaths>
</MASM>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
</Project>

View File

@@ -0,0 +1,441 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TITLE Assignment 5 (main.asm)
;Author: Corwin Perren
;Date: 3/3/2014
;Description:
; This program runs all three programs from assignment 5 from a menu screen
; These programs include an array reverser, frequency table generator, and
; prime number generator
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INCLUDE Irvine32.inc
.data
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Variables to change for testing program capabilities
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SieveArray BYTE 5000 dup(?)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Globally relevant vars
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ProgramTitle BYTE "CS 271 - Assignment 5",0
ProgrammerName BYTE "Written by: Corwin Perren",0
SelectInstructions BYTE "Please enter 1-4 to run desired program.", 0
MenuItem1 BYTE "1: Reverse Array In Place (Chapter 4, Exercise 5)",0
MenuItem2 BYTE "2: Frequency Table (Chapter 9, Exercise 6)",0
MenuItem3 BYTE "3: Sieve of Eratosthenes (Chapter 9, Exercise 7)",0
MenuItem4 BYTE "4: Exit",0
Selection BYTE "Selection: ",0
IncorrectNumberEntry BYTE "You did not enter 1-4. Press enter to try again.", 0
ReturnToSelect BYTE "Program Complete. Press enter to return to selection screen.", 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Vars for Prog 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ArrayToReverse BYTE 1,2,3,4,5,6,7,8,9,10, 11, 12, 13, 14
PressEnter BYTE "Press enter to reverse the currently reversed array. Enter 1 to quit.", 0
OriginalArray BYTE "Original Array:", 0
ReversedArray BYTE "Reversed Array:", 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Vars for Prog 2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
StringEntry BYTE "Please enter a string to create a frequency table for.", 0
StringThing BYTE "Your string: ", 0
StringArray BYTE 256 dup(?)
FrequencyTable DWORD 256 dup(?)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Vars for Prog 3
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EnterPrimes1 BYTE "Press enter to calculate primes up to ", 0
EnterPrimes2 BYTE ".", 0
.code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for writing string with newline
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Write_String_NL PROC uses EDX,
StringPtr:Ptr BYTE ;Varible to store string offset pointer
mov edx, StringPtr ;Moves the string to the proper register
call WriteString ;Prints the string
call Crlf ;Prints a new line
ret ;Return from procedure
Write_String_NL ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for writing string without newline
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Write_String PROC uses EDX,
StringPtr:Ptr BYTE ;Variable to store string offset pointer
mov edx, StringPtr ;Moves the string to the proper registers
call WriteString ;Prints the string
ret
Write_String ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for printing program title and programmer name
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintTitle PROC
INVOKE Write_String_NL, OFFSET ProgramTitle ;Prints the program title
INVOKE Write_String_NL, OFFSET ProgrammerName ;prints the programmer's name
call Crlf ;Prints a new line
INVOKE Write_String_NL, OFFSET SelectInstructions ;Prints the selection screen instructions
call Crlf ;Prints a new line
INVOKE Write_String_NL, OFFSET MenuItem1 ;Prints menu item 1
INVOKE Write_String_NL, OFFSET MenuItem2 ;Prints menu item 2
INVOKE Write_String_NL, OFFSET MenuItem3 ;Prints menu item 3
INVOKE Write_String_NL, OFFSET MenuItem4 ;Prints menu item 4
INVOKE Write_String, OFFSET Selection ;Print selction prompt
ret
PrintTitle ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to fill array with zeros using stosb
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FillWithZeros PROC
mov al, 0 ;Set al with value we want to fill array with
cld ;Clear Direction Flag
mov edi, OFFSET SieveArray ;Point edi to array
mov ecx, LENGTHOF SieveArray ;Set counter so instruction knows when to end
dec ecx ;Subtract one because it's starting at zero instead of one
rep stosb ;Repeats the fill operation until the array is full
ret ;Returns from function
FillWithZeros ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to mark multiples of primes with ones
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MarkMultiples PROC
mov esi, OFFSET SieveArray ;Move into esi to get easy access
mov BYTE PTR [esi], 1 ;Mark zero as non-prime
mov BYTE PTR [esi+1], 1 ;Mark one as non-prime
mov eax, 2 ;Set cursor position
mov ebx, 2 ;Multiplication value
jmp Inner
Outer:
pop eax ;Pop eax if we got here so the stack gets aligned and we know where we are
LookForOne:
inc eax ;Go up by one
cmp BYTE PTR [esi+eax], 1 ;Check to see if the new value at that position of the array has been marked
je LookForOne ;If so, increment again to find an unmarked one
cmp eax, LENGTHOF SieveArray ;Once an unmarked is found, make sure it's not outside our array size
jg MultEnd ;If it's out of array bounds, we're done so exit
mov ebx, 2 ;Otherwise, get ready to mark multiples of current prime starting with two times the prime
Inner:
push eax ;Save our original prime we're using
mul ebx ;Multiply prime by scaler
cmp eax, LENGTHOF SieveArray ;Make sure new value is not out of array size
jg Outer ;If it is, we're done with this prime
mov BYTE PTR [esi+eax], 1 ;Otherwise, mark the multiple with a one
inc ebx ;Increase our scaler
pop eax ;Restore the prime we're on
jmp Inner ;Re-do for next scaler
MultEnd:
ret ;Return from procedure
MarkMultiples ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to print out unmarked values in array, which are primes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintPrimes PROC
mov esi, OFFSET SieveArray ;Load array into esi to get ready to print
mov eax, 0 ;Set our cursor to zero
LookForZeros:
inc eax ;Move cursor forward one
cmp eax, LENGTHOF SieveArray ;Check if cursor is out of array bounds
jg PrintExit ;If so, exit because we are done
cmp BYTE PTR [esi+eax], 1 ;If we're in bounds, check if the position is marked
je LookForZeros ;If so, don't print and look at the next position
call WriteDec ;If unmarked, print the prime number sotred here
call Crlf ;Print a new line to make things look nice
jmp LookForZeros ;Continue for the next array position
PrintExit:
ret ;Return from procedure
PrintPrimes ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to run program 3
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Program3 PROC
call ClrScr ;Clears the screen
INVOKE Write_String, OFFSET EnterPrimes1 ;Prints prompt part one
mov eax, LENGTHOF SieveArray ;Moves number of primes to calculate to print
call WriteDec ;Prints number of primes to calculate
INVOKE Write_String_NL, OFFSET EnterPrimes2 ;Prints end of prompt line
call ReadInt ;Waits for any key
call FillWithZeros ;Fills the sieve array with zeros using stosb method
call MarkMultiples ;Marks positions that are multiples of primes
call PrintPrimes ;Prints remaining prime numbers
ret ;Returns from procedure
Program3 ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to determine the character frequency of a string
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Get_Frequencies PROC InputString:PTR BYTE, OutputTable:PTR DWORD
mov esi, InputString ;Moves string to parse into esi
mov edi, OutputTable ;Moves output table into edi
FreqLoop:
mov eax, 0 ;Zeros eax to make things work right
mov al, BYTE PTR [esi] ;Moves ascii decimal value into eax
mov ecx, eax ;Saves current decimal value
mov ebx, 4 ;Multiply eax by four because it's stored in DWORD and not BYTE array
mul ebx ;Actual multiplication
add DWORD PTR [edi+eax], 1 ;Increments frequency table position by one for this character
cmp ecx, 0 ;Checks if we've hit the NUL character
je FreqDone ;Exit if it's found because we're done
inc esi ;Otherwise, move to the next string array position
jmp FreqLoop ;Do above again for next character
FreqDone:
ret ;Return from procedure
Get_Frequencies ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to read in string from user
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GetNewString PROC StringPtr:PTR BYTE
mov edx, StringPtr ;Move string array into edx for read in
mov ecx, 256 ;Read in a max of 256 characters
call ReadString ;Read in string from user
ret ;Exit from procedure
GetNewString ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to print out the frequency table
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintFreqTable PROC TablePtr:PTR DWORD
mov esi, TablePtr ;Move frequency table into esi
mov ecx, 256 ;Set number of elements
mov ebx, 4 ;Set size of storage elements
call DumpMem ;Dump memory for the array
ret
PrintFreqTable ENDP
ZeroProg2 PROC
mov eax, 0 ;Set al with value we want to fill array with
cld ;Clear Direction Flag
mov edi, OFFSET StringArray ;Point edi to array
mov ecx, 256 ;Set counter so instruction knows when to end
dec ecx ;Subtract one because it's starting at zero instead of one
rep stosb ;Repeats the fill operation until the array is full
mov eax, 0 ;Set al with value we want to fill array with
cld ;Clear Direction Flag
mov edi, OFFSET FrequencyTable ;Point edi to array
mov ecx, 1024 ;Set counter so instruction knows when to end
dec ecx ;Subtract one because it's starting at zero instead of one
rep stosb ;Repeats the fill operation until the array is full
ret ;Returns from function
ZeroProg2 ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to run program 2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Program2 PROC
call ClrScr ;Clear the screen
call ZeroProg2 ;Zeros string and freq table array
INVOKE Write_String_NL, OFFSET StringEntry ;Prompts the user to enter a string
INVOKE Write_String, OFFSET StringThing ;Line prompt for above
INVOKE GetNewString, OFFSET StringArray ;Reads in user string
INVOKE Get_Frequencies, OFFSET StringArray, OFFSET FrequencyTable ;Runs frequency procedure on input string
INVOKE PrintFreqTable, OFFSET FrequencyTable ;Prints out the new frequency table
ret ;Returns from procedure
Program2 ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure to run program 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Program1 PROC
call ClrScr ;Clears the screen
INVOKE Write_String_NL, OFFSET OriginalArray ;Prints header for original array
mov eax, TYPE ArrayToReverse ;Moves the array type into eax
cmp eax, 1 ;Checks if it's a BYTE array
je ITSBYTE ;Jumps to BYTE section if so
cmp eax, 2 ;Checks if WORD array
je ITSWORD ;Jumps to WORD section if so
cmp eax, 4 ;Check if DWORD array
je ITSDWORD ;Jumps to DWORD section if so
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Run for BYTE Array
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ITSBYTE:
mov esi, OFFSET ArrayToReverse ;Moves array into esi
mov ecx, LENGTHOF ArrayToReverse ;Moves number of elements in array into ecx
mov ebx, TYPE ArrayToReverse ;Moves type of array into ebx
call DumpMem ;Shows original array
mov esi, OFFSET ArrayToReverse ;Re-moves array into esi
mov edi, OFFSET ArrayToReverse + SIZEOF ArrayToReverse - TYPE ArrayToReverse ;Moves the pointer to the last value of the array into edi
mov eax, LENGTHOF ArrayToReverse ;Moves number of elements in array into eax
mov edx, 0 ;Sets remainder to zero by default
mov ebx, 2 ;Moves two into ebx
div ebx ;Divides number of elements by two
mov ecx, eax ;Puts that number into our loop counter
ReverseBYTE:
mov bl, [esi] ;Move data at beginning cursor to tmp storage
mov dl, [edi] ;Move data at end cursor to tmp storage
mov [esi], dl ;Move end data to beginning
mov [edi], bl ;Move beginning data to end
add esi, TYPE ArrayToReverse ;Move beginning cursor forward
sub edi, TYPE ArrayToReverse ;Move ending cursor back
loop ReverseBYTE ;Loop until count expired
jmp Prog1Ret ;Jump to procedure end when done
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Run for WORD Array
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ITSWORD:
mov esi, OFFSET ArrayToReverse ;Moves array into esi
mov ecx, LENGTHOF ArrayToReverse ;Moves number of elements in array into ecx
mov ebx, TYPE ArrayToReverse ;Moves type of array into ebx
call DumpMem ;Shows original array
mov esi, OFFSET ArrayToReverse ;Re-moves array into esi
mov edi, OFFSET ArrayToReverse + SIZEOF ArrayToReverse - TYPE ArrayToReverse ;Moves the pointer to the last value of the array into edi
mov eax, LENGTHOF ArrayToReverse ;Moves number of elements in array into eax
mov edx, 0 ;Sets remainder to zero by default
mov ebx, 2 ;Moves two into ebx
div ebx ;Divides number of elements by two
mov ecx, eax ;Puts that number into our loop counter
ReverseWORD:
mov bx, [esi] ;Move data at beginning cursor to tmp storage
mov dx, [edi] ;Move data at end cursor to tmp storage
mov [esi], dx ;Move end data to beginning
mov [edi], bx ;Move beginning data to end
add esi, TYPE ArrayToReverse ;Move beginning cursor forward
sub edi, TYPE ArrayToReverse ;Move ending cursor back
loop ReverseWORD ;Loop until count expired
jmp Prog1Ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Run for DWORD Array
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ITSDWORD:
mov esi, OFFSET ArrayToReverse ;Moves array into esi
mov ecx, LENGTHOF ArrayToReverse ;Moves number of elements in array into ecx
mov ebx, TYPE ArrayToReverse ;Moves type of array into ebx
call DumpMem ;Shows original array
mov esi, OFFSET ArrayToReverse ;Re-moves array into esi
mov edi, OFFSET ArrayToReverse + SIZEOF ArrayToReverse - TYPE ArrayToReverse ;Moves the pointer to the last value of the array into edi
mov eax, LENGTHOF ArrayToReverse ;Moves number of elements in array into eax
mov edx, 0 ;Sets remainder to zero by default
mov ebx, 2 ;Moves two into ebx
div ebx ;Divides number of elements by two
mov ecx, eax ;Puts that number into our loop counter
ReverseDWORD:
mov ebx, [esi] ;Move data at beginning cursor to tmp storage
mov edx, [edi] ;Move data at end cursor to tmp storage
mov [esi], edx ;Move end data to beginning
mov [edi], ebx ;Move beginning data to end
add esi, TYPE ArrayToReverse ;Move beginning cursor forward
sub edi, TYPE ArrayToReverse ;Move ending cursor back
loop ReverseWORD ;Loop until count expired
Prog1Ret:
call Crlf ;Print a new line
call Crlf ;Print a second new line
INVOKE Write_String_NL, OFFSET ReversedArray ;Print header to say this is the reversed array
mov esi, OFFSET ArrayToReverse ;Move array into esi
mov ecx, LENGTHOF ArrayToReverse ;Set number of elements
mov ebx, TYPE ArrayToReverse ;Set size of elements
call DumpMem ;Display array
ret ;Return from procedure
Program1 ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Main Procedure
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
main PROC
MainTitle:
call ClrScr ;Clear screen
call PrintTitle ;Print the title screen
call ReadInt ;Read in user selection
cmp eax, 1 ;Check if user selected entry item 1
je Prog1Jmp ;If so, jump to that program
cmp eax, 2 ;Check if user selected entry item 2
je Prog2Jmp ;If so, jump to that program
cmp eax, 3 ;Check if user selected entry item 3
je Prog3Jmp ;If so, jump to that program
cmp eax, 4 ;Check if user selected exit
je MainExit ;If so, jump to end of program
call ClrScr ;Clear screeen
INVOKE Write_String_NL, OFFSET IncorrectNumberEntry ;Scold user for not entering one to four
call ReadInt ;Wait for enter key
jmp MainTitle ;Jump back to main screen
Prog1Jmp:
call Program1 ;Call array reverse program
call Crlf ;Print new line
INVOKE Write_String_NL, OFFSET ReturnToSelect ;Print hit enter to return to screen
call ReadInt ;Wait for enter
jmp MainTitle ;Jump to main screen
Prog2Jmp:
call Program2 ;Call String frequency program
call Crlf ;Print new line
INVOKE Write_String_NL, OFFSET ReturnToSelect ;Print hit enter to return to screen
call ReadInt ;Wait for enter
jmp MainTitle ;Jump to main screen
Prog3Jmp:
call Program3 ;Call prime generator program
call Crlf ;Print new line
INVOKE Write_String_NL, OFFSET ReturnToSelect ;Print hit enter to return to screen
call ReadInt ;Wait for enter
jmp MainTitle ;Jump to main screen
MainExit:
exit
main ENDP
END main

View File

@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASM_Project", "Assignment6.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

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@@ -0,0 +1,79 @@
<?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>
<MASM Include="CS271_proj6_perrenc.asm" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4164AA65-1EF9-4E69-899B-D1BED776070B}</ProjectGuid>
<ProjectName>ASM_Project</ProjectName>
</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>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Link>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<AdditionalLibraryDirectories>c:\Irvine;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Console</SubSystem>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalDependencies>user32.lib;irvine32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<MASM>
<IncludePaths>c:\Irvine</IncludePaths>
</MASM>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
</Project>

View File

@@ -0,0 +1,632 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TITLE Assignment 6 (main.asm)
;Author: Corwin Perren
;Date: 3/13/2014
;Description:
; This program runs all five programs from assignment 6 from a menu screen
; These programs include a letter matrix generator, array row sum calculator,
; a floating point comparator, circle area computer, and quadratic formula
; calculator
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INCLUDE Irvine32.inc
.data
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Program Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Global Relevant Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ProgramTitle BYTE "CS 271 - Assignment 6",0
ProgrammerName BYTE "Written by: Corwin Perren",0
SelectInstructions BYTE "Please enter 1-6 to run desired program.", 0
MenuItem1 BYTE "1: Letter Matrix Generator (Chapter 9, Exercise 10)",0
MenuItem2 BYTE "2: Two Dimensional Array Row Summer (Chapter 9, Exercise 12)",0
MenuItem3 BYTE "3: Floating Point Comparator (Chapter 12, Exercise 1)",0
MenuItem4 BYTE "4: Area of Circle Calculator (Chapter 12, Exercise 5)",0
MenuItem5 BYTE "5: Quadratic Formula Calculator (Chapter 12, Exercise 6)",0
MenuItem6 BYTE "6: Exit",0
Selection BYTE "Selection: ",0
IncorrectNumberEntry BYTE "You did not enter 1-7. Press enter to try again.", 0
ReturnToSelect BYTE "Program Complete. Press enter to return to selection screen.", 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Letter Matrix Generator Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
NumVowels DWORD 6
VowelArray BYTE "AEIOUY"
NumConsonants DWORD 20
ConsonantArray BYTE "BCDFGHJKLMNPQRSTVWXZ"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Two Dimensional Array Row Summer Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CurrentArrayContents BYTE "Array Contents:",0
TableRow1 BYTE "1 2 3 4 5",0 ;For printing to display only
TableRow2 BYTE "6 7 8 9 10",0 ;For printing to display only
TableRow3 BYTE "11 12 13 14 15",0 ;For printing to display only
TableRow4 BYTE "16 17 18 19 20",0 ;For printing to display only
TableRow5 BYTE "21 22 23 24 25",0 ;For printing to display only
SummerPleaseEnterIndex BYTE "Enter a row to sum between 1 and 5.",0
SummerIndexPrompt BYTE "Row: ",0
TableArrayIndex DWORD ?
TableArrayBYTE BYTE 1,2,3,4,5 ;Row 1
TableArrayRowSizeBYTE = ($-TableArrayBYTE) ;Size of single row
BYTE 6,7,8,9,10 ;Row 2
BYTE 11,12,13,14,15 ;Row 3
BYTE 16,17,18,19,20 ;Row 4
BYTE 21,22,23,24,25 ;Row 5
TableArrayWORD WORD 1,2,3,4,5 ;Row 1
TableArrayRowSizeWORD = ($-TableArrayWORD) ;Size of single row
WORD 6,7,8,9,10 ;Row 2
WORD 11,12,13,14,15 ;Row 3
WORD 16,17,18,19,20 ;Row 4
WORD 21,22,23,24,25 ;Row 5
TableArrayDWORD DWORD 1,2,3,4,5 ;Row 1
TableArrayRowSizeDWORD = ($-TableArrayDWORD) ;Size of single row
DWORD 6,7,8,9,10 ;Row 2
DWORD 11,12,13,14,15 ;Row 3
DWORD 16,17,18,19,20 ;Row 4
DWORD 21,22,23,24,25 ;Row 5
SummerBYTE BYTE "Sum using BYTE array: ",0
SummerWORD BYTE "Sum using WORD array: ",0
SummerDWORD BYTE"Sum using DWORD array: ",0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Floating Point Comparator Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EnterTwoFloat BYTE "Please enter two floating point numbers to compare.",0
Float1Prompt BYTE "First Number : ", 0
Float2Prompt BYTE "Second Number: ", 0
FirstLargerThanFloat BYTE "The first value you entered was larger than the second.", 0
SecondLargerThanFloat BYTE "The second value you entered was larger than the first.", 0
EqualFloat BYTE "The numbers you entered were equal",0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Area of Circle Calculator Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EnterRadius BYTE "Enter the radius of a circle to calculate it's area.",0
RadiusPrompt BYTE "Radius: ",0
CircleAreaCalculated BYTE "The area for this circle is: ",0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Quadratic Formula Calculator Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PleaseEnterCoeff BYTE "Please enter coefficients a, b, and c for a quadratic forumula in the form", 10, 13, "ax",253," + bx + c = 0 to calculate it's real roots.",0
RootsNonRealMsg BYTE "These coefficients result in non-real roots. Exiting.",0
Root1Msg BYTE "Root1: ",0
Root2Msg BYTE "Root2: ",0
CoeffA BYTE "a: ",0
CoeffB BYTE "b: ",0
CoeffC BYTE "c: ",0
Stores2 DWORD 2
Stores4 DWORD 4
FloatA REAL10 ?
FloatB REAL10 ?
FloatC REAL10 ?
AfterRootTaken REAL10 ?
Root1 REAL10 ?
Root2 REAL10 ?
.code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Globally Useful Procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for writing string with newline
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Write_String_NL PROC uses EDX,
StringPtr:Ptr BYTE ;Varible to store string offset pointer
mov edx, StringPtr ;Moves the string to the proper register
call WriteString ;Prints the string
call Crlf ;Prints a new line
ret ;Return from procedure
Write_String_NL ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for writing string without newline
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Write_String PROC uses EDX,
StringPtr:Ptr BYTE ;Variable to store string offset pointer
mov edx, StringPtr ;Moves the string to the proper registers
call WriteString ;Prints the string
ret
Write_String ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for printing program title and programmer name
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintTitle PROC
INVOKE Write_String_NL, OFFSET ProgramTitle ;Prints the program title
INVOKE Write_String_NL, OFFSET ProgrammerName ;prints the programmer's name
call Crlf ;Prints a new line
INVOKE Write_String_NL, OFFSET SelectInstructions ;Prints the selection screen instructions
call Crlf ;Prints a new line
INVOKE Write_String_NL, OFFSET MenuItem1 ;Prints menu item 1
INVOKE Write_String_NL, OFFSET MenuItem2 ;Prints menu item 2
INVOKE Write_String_NL, OFFSET MenuItem3 ;Prints menu item 3
INVOKE Write_String_NL, OFFSET MenuItem4 ;Prints menu item 4
INVOKE Write_String_NL, OFFSET MenuItem5 ;Prints menu item 2
INVOKE Write_String_NL, OFFSET MenuItem6 ;Prints menu item 3
INVOKE Write_String, OFFSET Selection ;Print selction prompt
ret
PrintTitle ENDP
ClearFPU PROC
FFREE ST(0)
FFREE ST(1)
FFREE ST(2)
FFREE ST(3)
FFREE ST(4)
FFREE ST(5)
FFREE ST(6)
FFREE ST(7)
ret
ClearFPU ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Letter Matrix Generator Procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure returns a random consonant
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GetRandomConsonant PROC uses EBX
mov EAX, NumConsonants ;Set up range for random generator
mov EBX, offset ConsonantArray ;Move ConsonantArray into ebp for dereferencing
call RandomRange ;Get random number within range
add EBX, EAX ;Point to element in ebp
mov AL, [EBX] ;Store pointed to value in AL
ret ;Return from procedure
GetRandomConsonant ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure returns a random vowel
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GetRandomVowel PROC uses EBX
mov EAX, NumVowels ;Set up range for random generator
mov EBX, offset VowelArray ;Move VowelArray into ebp for dereferencing
call RandomRange ;Get random number within range
add EBX, EAX ;Point to element in ebp
mov AL, [EBX] ;Store pointed to value in AL
ret ;Return from procedure
GetRandomVowel ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure prints the matrixes in proper rows with random chars
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintMatrix PROC uses EAX ECX EDX
mov ECX, 4 ;Move column count into ECX
PrintLineLoop:
mov EDX, 4 ;Move row count into EDX
call CrLf ;Print new line
PrintShortLoop:
mov EAX, 2 ;Put in range for RandomRange of 2 (0-1)
call RandomRange ;Get random 0 to 1
cmp EAX, 0 ;Check if zero
jnz GetConsonant ;If one, print consonant
call GetRandomVowel ;Get Vowel from generator
jmp WriteCharToMatrix ;Go print the character
GetConsonant:
call GetRandomConsonant ;Get consonant from generator
WriteCharToMatrix:
call WriteChar ;Print current character
dec EDX ;Move forward one column
jnz PrintShortLoop ;Repeat column print until at column end
dec ECX ;Move down one row
jnz PrintLineLoop ;Print out column on new row
call CrLf ;Print a new line
ret ;Return from procedure
PrintMatrix ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure for running program1 functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Program1 PROC
call ClrScr
call Randomize ;Seeds the random number generator
mov ECX, 5 ;Set loop counter to 5 to display matrix five times
Program1Loop:
call PrintMatrix ;Call procedure to print out one matrix
loop Program1Loop ;Continue printing until 5 arrays are one screen
ret ;Return from Program1 procedure
Program1 ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Two Dimensional Array Row Summer Procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure calculates the sum for a row using stack passed parameters
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Calc_Row_Sum PROC
mov ebp, esp ;Get access to the stack
mov ebx, [ebp+4] ;Save users selected row index
dec ebx ;Remove one to make math simpler
mov edx, [ebp+8] ;Save table type
mov ecx, [ebp+12] ;Setup counter with row length
mov esi, [ebp+16] ;Move array into array reg
cmp edx, 1 ;Check if it's a BYTE
je RowSumBYTE ;Jump if BYTE
cmp edx, 2 ;Check if it's a WORD
je RowSumWORD ;Jump if WORD
cmp edx, 4 ;Check if DWORD
je RowSumDWORD ;Jump if DWORD
RowSumBYTE:
mov eax, ecx ;Move row length into eax
mul ebx ;Mutiply by row index
add esi, eax ;Add this offset to esi
mov eax, 0 ;Zero accumulator
RowSumBYTELoop:
add al, [esi] ;Add value to al
inc esi ;Move to the next value in the array
loop RowSumBYTELoop ;Loop until row finished
jmp CalcRowSumEnd ;Jump when finished
RowSumWORD:
push edx ;Save EDX to stack
mov eax, ecx ;Set up multiplication of 2
mul ebx ;Multiply user index by two (Now if WORD format)
add esi, eax ;Move cursor to index location using offset
pop edx ;Return EDX to reg
mov ebx, edx ;Store TYPE in EBX
mov edx, 0 ;Zero upper half for multiplication
mov eax, ecx ;Set lower half to row size
div ebx ;Divide by TYPE
mov ecx, eax ;Set this number in the loop count reg
mov eax, 0 ;Zero accumulator
RowSumWORDLoop:
add ax, [esi] ;Add value to ax
add esi, 2 ;Move to the next value in the array
loop RowSumWORDLoop ;Loop until row finished
jmp CalcRowSumEnd ;Jump when finished
RowSumDWORD:
push edx ;Save EDX to stack
mov eax, ecx ;Set up multiplication of 4
mul ebx ;Multiply user index by four (Now in DWORD format)
add esi, eax ;Move cursor to index location using offset
pop edx ;Return EDX to reg
mov ebx, edx ;Store TYPE in EBX
mov edx, 0 ;Zero upper half for multiplication
mov eax, ecx ;Set lower half to row size
div ebx ;Divide by TYPE
mov ecx, eax ;Set this number in the loop count reg
mov eax, 0 ;Zero accumulator
RowSumDWORDLoop:
add eax, [esi] ;Add value to ax
add esi, 4 ;Move to the next value in the array
loop RowSumDWORDLoop ;Loop until row finished
CalcRowSumEnd:
ret ;Return from procedure
Calc_Row_Sum ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Program2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Program2 PROC
call ClrScr ;Clears the screen
INVOKE Write_String_NL, OFFSET CurrentArrayContents ;Prints out array contents header
INVOKE Write_String_NL, OFFSET TableRow1 ;Prints table row 1
INVOKE Write_String_NL, OFFSET TableRow2 ;Prints table row 2
INVOKE Write_String_NL, OFFSET TableRow3 ;Prints table row 3
INVOKE Write_String_NL, OFFSET TableRow4 ;Prints table row 4
INVOKE Write_String_NL, OFFSET TableRow5 ;Prints table row 5
INVOKE Write_String_NL, OFFSET SummerPleaseEnterIndex ;Asks user to enter index value
INVOKE Write_String, OFFSET SummerIndexPrompt ;Row prompt for niceity
call ReadInt ;Read in Index from user
mov TableArrayIndex, EAX ;Moves user selection into variable
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Using BYTES
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
push OFFSET TableArrayBYTE ;Pushes the offset for the table array (32-bit)
mov eax, 0 ;Clears the eax register
mov eax, TableArrayRowSizeBYTE ;Moves the table array row size into eax
push eax ;Pushes that number onto the stack (32-bit)
mov eax, 0 ;Clears the eax register
mov eax, TYPE TableArrayBYTE ;Moves the type of table array into eax
push eax ;Pushes the type of the array onto the stack (32-bit)
push TableArrayIndex ;Pushes the index selected by the user onto the stack (32-bit)
call Calc_Row_Sum ;Calculates sum for row and prints it
INVOKE Write_String, OFFSET SummerBYTE ;Prints out what array was used to sum
call WriteInt ;Writes to display
call Crlf ;Prints a new line
add esp, 16 ;Cleanup the stack (4 times 32-bit)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Using WORDS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
push OFFSET TableArrayWORD ;Pushes the offset for the table array (32-bit)
mov eax, 0 ;Clears the eax register
mov eax, TableArrayRowSizeWORD ;Moves the table array row size into eax
push eax ;Pushes that number onto the stack (32-bit)
mov eax, 0 ;Clears the eax register
mov eax, TYPE TableArrayWORD ;Moves the type of table array into eax
push eax ;Pushes the type of the array onto the stack (32-bit)
push TableArrayIndex ;Pushes the index selected by the user onto the stack (32-bit)
call Calc_Row_Sum ;Calculates sum for row and prints it
INVOKE Write_String, OFFSET SummerWORD ;Prints out what array was used to sum
call WriteInt ;Writes sum to display
call Crlf ;Prints a new line
add esp, 16 ;Cleanup the stack (4 times 32-bit)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Using DWORDS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
push OFFSET TableArrayDWORD ;Pushes the offset for the table array (32-bit)
mov eax, 0 ;Clears the eax register
mov eax, TableArrayRowSizeDWORD ;Moves the table array row size into eax
push eax ;Pushes that number onto the stack (32-bit)
mov eax, 0 ;Clears the eax register
mov eax, TYPE TableArrayDWORD ;Moves the type of table array into eax
push eax ;Pushes the type of the array onto the stack (32-bit)
push TableArrayIndex ;Pushes the index selected by the user onto the stack (32-bit)
call Calc_Row_Sum ;Calculates sum for row and prints it
INVOKE Write_String, OFFSET SummerDWORD ;Prints out what array was used to sum
call WriteInt ;Writes sum to the screen
add esp, 16 ;Cleanup the stack (4 times 32-bit)
ret ;Return from Program2 procedure
Program2 ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Floating Point Comparator Procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure runs program 3 functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Program3 PROC
call ClrScr
INVOKE Write_String_NL, OFFSET EnterTwoFloat ;Prompt to enter two floating point numbers
INVOKE Write_String, OFFSET Float1Prompt ;Prompt for first val
call ReadFloat ;Read in value
INVOKE Write_String, OFFSET Float2Prompt ;Prompt for second val
call ReadFloat ;Read in value
call CRLF ;Print newline
FCOMI ST(0), ST(1) ;Compare second value entered to first
ja SecondWasGreater ;If the second is above the first, it's greater so jump
INVOKE Write_String_NL, OFFSET FirstLargerThanFloat ;Otherwise, the first was greater and we print a message saying so
jmp Prog3Ending ;Then we jump to program end
SecondWasGreater:
INVOKE Write_String_NL, OFFSET SecondLargerThanFloat ;In the case the second is greater than the first, we will print that instead
Prog3Ending:
ret ;Return from Program3 procedure
Program3 ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Area of Circle Calculator Procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure runs program 4 functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Program4 PROC
call ClrScr ;Clear the screen
INVOKE Write_String_NL, OFFSET EnterRadius ;Prompt the user to enter the radius
INVOKE Write_String, OFFSET RadiusPrompt ;Provide nice header
FLDPI ;Load pi onto floating point unit stack
call ReadFloat ;Read in float from user
fld ST(0) ;Load a second radius onto floating point stack
FMULP ;Mulitply and pop
FMULP ;Multiply and pop
INVOKE Write_String, OFFSET CircleAreaCalculated ;Print header for final value
call WriteFloat ;Write calculated value to screen
FFREE ST(0) ;Free FPU stack
ret ;Return from Program4 procedure
Program4 ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Quadratic Formula Calculator Procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure reads in float coefficients from user
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GetCoefficients PROC
INVOKE Write_String_NL, OFFSET PleaseEnterCoeff ;Asks user to enter coefficients
call Crlf ;Prints a new line
INVOKE Write_String, OFFSET CoeffA ;Asks for a
call ReadFloat ;Reads in a
INVOKE Write_String, OFFSET CoeffB ;Asks for b
call ReadFloat ;Reads in b
INVOKE Write_String, OFFSET CoeffC ;Asks for c
call ReadFloat ;Reads in c
FSTP FloatC ;Store coeff c in var
FSTP FloatB ;Store coeff b in var
FSTP FloatA ;Store coeff a in var
ret ;Return from procedure
GetCoefficients ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Procedure runs program5 functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Program5 PROC
call ClrScr ;Clear the screen
call GetCoefficients ;Reading in coefficients from user
FLD FLoatB ;Load b
FMUL ST(0), ST(0) ;Square b
FLD FloatA ;Load a
FLD FloatC ;Load c
FIMUL Stores4 ;Multiply c by 4
FMULP ST(1), ST(0) ;End result is 4*a*c
FSUBP ST(1), ST(0) ;End result is b^2-4ac
FLDZ ;Load zero onto stack for comparison
FCOMIP ST(0), ST(1) ;Check if roots are going to be real or not
ja NonRealRoots ;Jump to message if roots are non-real and exit
FSQRT ;Take square root as it's real
FSTP AfterRootTaken ;Store for use later on other root
FLD FloatB ;Load b
FCHS ;Negate b
FLD AfterRootTaken ;Load rooted val
FSUB ;Subtract rooted val from negated b (-b - sqrt(b^2-4ac))
FLD FloatA ;Load a
FIMUL Stores2 ;Multiply a by 2
FDIV ;Divide numerator by denominator
FSTP Root1 ;Store first root value
FLD FloatB ;Load b
FCHS ;Negate b
FLD AfterRootTaken ;Load rooted val
FADD ;Add rooted val from negated b (-b - sqrt(b^2-4ac))
FLD FloatA ;Load a
FIMUL Stores2 ;Multiply a by 2
FDIV ;Divide numerator by denominator
FSTP Root2 ;Store second root value
call Crlf
INVOKE Write_String, OFFSET Root1Msg ;Print Root1 Header
FLD Root1 ;Load root1 into register
call WriteFloat ;Print root1
FFREE ST(0) ;Free FPU register
call Crlf ;Print new line
INVOKE Write_String, OFFSET Root2Msg ;Print root2 header
FLD Root2 ;Load root2 into register
call WriteFloat ;Print root2
FFREE ST(0) ;Free FPU register
call Crlf ;Print a new line
jmp Program5Ending ;Jump to program end
NonRealRoots:
FFREE ST(0) ;Free up register so it can be used again
INVOKE Write_String_NL, OFFSET RootsNonRealMsg ;Print message saying there are no real roots
Program5Ending:
ret ;Return from Program5 procedure
Program5 ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Program Main Function
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Main Procedure
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
main PROC
FINIT ;Initialize floating point unit
MainTitle:
call ClrScr ;Clear screen
call PrintTitle ;Print the title screen
call ReadInt ;Read in user selection
cmp eax, 1 ;Check if user selected entry item 1
je Prog1Jmp ;If so, jump to that program
cmp eax, 2 ;Check if user selected entry item 2
je Prog2Jmp ;If so, jump to that program
cmp eax, 3 ;Check if user selected entry item 3
je Prog3Jmp ;If so, jump to that program
cmp eax, 4 ;Check if user selected entry item 4
je Prog4Jmp ;If so, jump to that program
cmp eax, 5 ;Check if user selected entry item 5
je Prog5Jmp ;If so, jump to that program
cmp eax, 6 ;Check if user selected exit
je MainExit ;If so, jump to end of program
call ClrScr ;Clear screeen
INVOKE Write_String_NL, OFFSET IncorrectNumberEntry ;Scold user for not entering one to six
call ReadInt ;Wait for enter key
jmp MainTitle ;Jump back to main screen
Prog1Jmp:
call Program1 ;Call program1
call Crlf ;Print new line
INVOKE Write_String_NL, OFFSET ReturnToSelect ;Print hit enter to return to screen
call ReadInt ;Wait for enter
jmp MainTitle ;Jump to main screen
Prog2Jmp:
call Program2 ;Call program2
call Crlf ;Print new line
INVOKE Write_String_NL, OFFSET ReturnToSelect ;Print hit enter to return to screen
call ReadInt ;Wait for enter
jmp MainTitle ;Jump to main screen
Prog3Jmp:
call ClearFPU ;Empties FPU Registers to keep things from crashing
call Program3 ;Call program3
call Crlf ;Print new line
INVOKE Write_String_NL, OFFSET ReturnToSelect ;Print hit enter to return to screen
call ReadInt ;Wait for enter
jmp MainTitle ;Jump to main screen
Prog4Jmp:
call ClearFPU ;Empties FPU Registers to keep things from crashing
call Program4 ;Call program4
call Crlf ;Print new line
INVOKE Write_String_NL, OFFSET ReturnToSelect ;Print hit enter to return to screen
call ReadInt ;Wait for enter
jmp MainTitle ;Jump to main screen
Prog5Jmp:
call ClearFPU ;Empties FPU Registers to keep things from crashing
call Program5 ;Call program5
call Crlf ;Print new line
INVOKE Write_String_NL, OFFSET ReturnToSelect ;Print hit enter to return to screen
call ReadInt ;Wait for enter
jmp MainTitle ;Jump to main screen
MainExit:
exit
main ENDP
END main

View File

@@ -0,0 +1,25 @@
<html>
<body>
<pre>
<h1><EFBFBD>Vision Build Log</h1>
<h2>Project:</h2>
D:\Google Drive\_School\Current Term\CS 271\Final Paper\Code\Program1\ARMv7\Proj.uvproj
Project File Date: 03/18/2014
<h2>Output:</h2>
Rebuild target 'Target 1'
assembling assem.s...
linking...
Program Size: Code=96 RO-data=0 RW-data=0 ZI-data=0
".\Proj.axf" - 0 Error(s), 0 Warning(s).
</pre>
</body>
</html>
.\Proj.axf" - 2 Error(s), 0 Warning(s).
Target not created
(s).
Target not created
g(s).
Target not created
" - 3 Error(s), 0 Warning(s).
Target not created

View File

@@ -0,0 +1,20 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html><head>
<title>Static Call Graph - [.\Proj.axf]</title></head>
<body><HR>
<H1>Static Call Graph for image .\Proj.axf</H1><HR>
<BR><P>#&#060CALLGRAPH&#062# ARM Linker, 5.03 [Build 76]: Last Updated: Tue Mar 18 03:46:41 2014
<BR><P>
<H3>Maximum Stack Usage = 0 bytes</H3><H3>
Call chain for Maximum Stack Depth:</H3>
<P>
<H3>
Global Symbols
</H3><P>
<H3>
Local Symbols
</H3><P>
<H3>
Undefined Global Symbols
</H3><HR></body></html>

View File

@@ -0,0 +1,5 @@
--cpu ARM7TDMI
".\assem.o"
--ro-base 0x00000000 --entry 0x00000000 --rw-base 0x00000000 --strict --summary_stderr --info summarysizes --map --xref --callgraph --symbols
--info sizes --info totals --info unused --info veneers
--list ".\Proj.map" -o .\Proj.axf

View File

@@ -0,0 +1,89 @@
ARM Linker, 5.03 [Build 76] [MDK-ARM Lite]
==============================================================================
Section Cross References
==============================================================================
Image Symbol Table
Local Symbols
Symbol Name Value Ov Type Size Object(Section)
ConstrainProg 0x00000000 Section 96 assem.o(ConstrainProg)
assem.s 0x00000000 Number 0 assem.o ABSOLUTE
Global Symbols
Symbol Name Value Ov Type Size Object(Section)
BuildAttributes$$THM_ISAv1$ARM_ISAv4$S$PE$A:L22$X:L11$S22$IEEE1$IW$USESV6$~STKCKD$USESV7$~SHL$OSPACE$EBA8$STANDARDLIB$EABIv2 0x00000000 Number 0 anon$$obj.o ABSOLUTE
==============================================================================
Memory Map of the image
Image Entry point : 0x00000000
Load Region LR_1 (Base: 0x00000000, Size: 0x00000060, Max: 0xffffffff, ABSOLUTE)
Execution Region ER_RO (Base: 0x00000000, Size: 0x00000000, Max: 0xffffffff, ABSOLUTE)
**** No section assigned to this execution region ****
Execution Region ER_RW (Base: 0x00000000, Size: 0x00000060, Max: 0xffffffff, ABSOLUTE)
Base Addr Size Type Attr Idx E Section Name Object
0x00000000 0x00000060 Code RW 1 * ConstrainProg assem.o
Execution Region ER_ZI (Base: 0x00000060, Size: 0x00000000, Max: 0xffffffff, ABSOLUTE)
**** No section assigned to this execution region ****
==============================================================================
Image component sizes
Code (inc. data) RO Data RW Data ZI Data Debug Object Name
96 16 0 0 0 248 assem.o
----------------------------------------------------------------------
96 16 0 0 0 248 Object Totals
0 0 0 0 0 0 (incl. Generated)
0 0 0 0 0 0 (incl. Padding)
----------------------------------------------------------------------
0 0 0 0 0 0 Library Totals
0 0 0 0 0 0 (incl. Padding)
----------------------------------------------------------------------
==============================================================================
Code (inc. data) RO Data RW Data ZI Data Debug
96 16 0 0 0 248 Grand Totals
96 16 0 0 0 248 ELF Image Totals
96 16 0 0 0 0 ROM Totals
==============================================================================
Total RO Size (Code + RO Data) 96 ( 0.09kB)
Total RW Size (RW Data + ZI Data) 0 ( 0.00kB)
Total ROM Size (Code + RO Data + RW Data) 96 ( 0.09kB)
==============================================================================

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,193 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_opt.xsd">
<SchemaVersion>1.0</SchemaVersion>
<Header>### uVision Project, (C) Keil Software</Header>
<Extensions>
<cExt>*.c</cExt>
<aExt>*.s*; *.src; *.a*</aExt>
<oExt>*.obj</oExt>
<lExt>*.lib</lExt>
<tExt>*.txt; *.h; *.inc</tExt>
<pExt>*.plm</pExt>
<CppX>*.cpp</CppX>
</Extensions>
<DaveTm>
<dwLowDateTime>0</dwLowDateTime>
<dwHighDateTime>0</dwHighDateTime>
</DaveTm>
<Target>
<TargetName>Target 1</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<TargetOption>
<CLKADS>60000000</CLKADS>
<OPTTT>
<gFlags>0</gFlags>
<BeepAtEnd>1</BeepAtEnd>
<RunSim>1</RunSim>
<RunTarget>0</RunTarget>
</OPTTT>
<OPTHX>
<HexSelection>1</HexSelection>
<FlashByte>65535</FlashByte>
<HexRangeLowAddress>0</HexRangeLowAddress>
<HexRangeHighAddress>0</HexRangeHighAddress>
<HexOffset>0</HexOffset>
</OPTHX>
<OPTLEX>
<PageWidth>79</PageWidth>
<PageLength>66</PageLength>
<TabStop>8</TabStop>
<ListingPath>.\</ListingPath>
</OPTLEX>
<ListingPage>
<CreateCListing>1</CreateCListing>
<CreateAListing>1</CreateAListing>
<CreateLListing>1</CreateLListing>
<CreateIListing>0</CreateIListing>
<AsmCond>1</AsmCond>
<AsmSymb>1</AsmSymb>
<AsmXref>0</AsmXref>
<CCond>1</CCond>
<CCode>0</CCode>
<CListInc>0</CListInc>
<CSymb>0</CSymb>
<LinkerCodeListing>0</LinkerCodeListing>
</ListingPage>
<OPTXL>
<LMap>1</LMap>
<LComments>1</LComments>
<LGenerateSymbols>1</LGenerateSymbols>
<LLibSym>1</LLibSym>
<LLines>1</LLines>
<LLocSym>1</LLocSym>
<LPubSym>1</LPubSym>
<LXref>0</LXref>
<LExpSel>0</LExpSel>
</OPTXL>
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>255</CpuCode>
<DllOpt>
<SimDllName>SARM.DLL</SimDllName>
<SimDllArguments></SimDllArguments>
<SimDlgDllName>DARMP.DLL</SimDlgDllName>
<SimDlgDllArguments></SimDlgDllArguments>
<TargetDllName>SARM.DLL</TargetDllName>
<TargetDllArguments></TargetDllArguments>
<TargetDlgDllName>TARMP.DLL</TargetDlgDllName>
<TargetDlgDllArguments></TargetDlgDllArguments>
</DllOpt>
<DebugOpt>
<uSim>1</uSim>
<uTrg>0</uTrg>
<sLdApp>1</sLdApp>
<sGomain>1</sGomain>
<sRbreak>1</sRbreak>
<sRwatch>1</sRwatch>
<sRmem>1</sRmem>
<sRfunc>1</sRfunc>
<sRbox>1</sRbox>
<tLdApp>1</tLdApp>
<tGomain>0</tGomain>
<tRbreak>1</tRbreak>
<tRwatch>1</tRwatch>
<tRmem>1</tRmem>
<tRfunc>0</tRfunc>
<tRbox>1</tRbox>
<tRtrace>1</tRtrace>
<sRunDeb>0</sRunDeb>
<sLrtime>0</sLrtime>
<nTsel>-1</nTsel>
<sDll></sDll>
<sDllPa></sDllPa>
<sDlgDll></sDlgDll>
<sDlgPa></sDlgPa>
<sIfile></sIfile>
<tDll></tDll>
<tDllPa></tDllPa>
<tDlgDll></tDlgDll>
<tDlgPa></tDlgPa>
<tIfile></tIfile>
<pMon></pMon>
</DebugOpt>
<TargetDriverDllRegistry>
<SetRegEntry>
<Number>0</Number>
<Key>DLGDARM</Key>
<Name>(134=-1,-1,-1,-1,0)(135=-1,-1,-1,-1,0)(107=-1,-1,-1,-1,0)(108=-1,-1,-1,-1,0)(106=-1,-1,-1,-1,0)(105=-1,-1,-1,-1,0)(80=-1,-1,-1,-1,0)(104=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(113=-1,-1,-1,-1,0)(112=-1,-1,-1,-1,0)(136=-1,-1,-1,-1,0)(117=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(114=-1,-1,-1,-1,0)(115=-1,-1,-1,-1,0)(116=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>ARMDBGFLAGS</Key>
<Name>-T5F</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint/>
<Tracepoint>
<THDelay>0</THDelay>
</Tracepoint>
<DebugFlag>
<trace>0</trace>
<periodic>1</periodic>
<aLwin>1</aLwin>
<aCover>0</aCover>
<aSer1>0</aSer1>
<aSer2>0</aSer2>
<aPa>0</aPa>
<viewmode>1</viewmode>
<vrSel>0</vrSel>
<aSym>0</aSym>
<aTbox>0</aTbox>
<AscS1>0</AscS1>
<AscS2>0</AscS2>
<AscS3>0</AscS3>
<aSer3>0</aSer3>
<eProf>0</eProf>
<aLa>0</aLa>
<aPa1>0</aPa1>
<AscS4>0</AscS4>
<aSer4>0</aSer4>
<StkLoc>0</StkLoc>
<TrcWin>0</TrcWin>
<newCpu>0</newCpu>
<uProt>0</uProt>
</DebugFlag>
<LintExecutable></LintExecutable>
<LintConfigFile></LintConfigFile>
</TargetOption>
</Target>
<Group>
<GroupName>Source Group 1</GroupName>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>1</GroupNumber>
<FileNumber>1</FileNumber>
<FileType>2</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>1</TopLine>
<CurrentLine>1</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>.\assem.s</PathWithFileName>
<FilenameWithoutPath>assem.s</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
</ProjectOpt>

View File

@@ -0,0 +1,412 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_proj.xsd">
<SchemaVersion>1.1</SchemaVersion>
<Header>### uVision Project, (C) Keil Software</Header>
<Targets>
<Target>
<TargetName>Target 1</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<TargetOption>
<TargetCommonOption>
<Device>ARM7 (Little Endian)</Device>
<Vendor>ARM</Vendor>
<Cpu>CLOCK(60000000) CPUTYPE(ARM7TDMI)</Cpu>
<FlashUtilSpec></FlashUtilSpec>
<StartupFile></StartupFile>
<FlashDriverDll></FlashDriverDll>
<DeviceId>3654</DeviceId>
<RegisterFile></RegisterFile>
<MemoryEnv></MemoryEnv>
<Cmp></Cmp>
<Asm></Asm>
<Linker></Linker>
<OHString></OHString>
<InfinionOptionDll></InfinionOptionDll>
<SLE66CMisc></SLE66CMisc>
<SLE66AMisc></SLE66AMisc>
<SLE66LinkerMisc></SLE66LinkerMisc>
<SFDFile></SFDFile>
<bCustSvd>0</bCustSvd>
<UseEnv>0</UseEnv>
<BinPath></BinPath>
<IncludePath></IncludePath>
<LibPath></LibPath>
<RegisterFilePath></RegisterFilePath>
<DBRegisterFilePath></DBRegisterFilePath>
<TargetStatus>
<Error>0</Error>
<ExitCodeStop>0</ExitCodeStop>
<ButtonStop>0</ButtonStop>
<NotGenerated>0</NotGenerated>
<InvalidFlash>1</InvalidFlash>
</TargetStatus>
<OutputDirectory>.\</OutputDirectory>
<OutputName>Proj</OutputName>
<CreateExecutable>1</CreateExecutable>
<CreateLib>0</CreateLib>
<CreateHexFile>0</CreateHexFile>
<DebugInformation>1</DebugInformation>
<BrowseInformation>1</BrowseInformation>
<ListingPath>.\</ListingPath>
<HexFormatSelection>1</HexFormatSelection>
<Merge32K>0</Merge32K>
<CreateBatchFile>0</CreateBatchFile>
<BeforeCompile>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopU1X>0</nStopU1X>
<nStopU2X>0</nStopU2X>
</BeforeCompile>
<BeforeMake>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
</BeforeMake>
<AfterMake>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
</AfterMake>
<SelectedForBatchBuild>0</SelectedForBatchBuild>
<SVCSIdString></SVCSIdString>
</TargetCommonOption>
<CommonProperty>
<UseCPPCompiler>0</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>1</IncludeInBuild>
<AlwaysBuild>0</AlwaysBuild>
<GenerateAssemblyFile>0</GenerateAssemblyFile>
<AssembleAssemblyFile>0</AssembleAssemblyFile>
<PublicsOnly>0</PublicsOnly>
<StopOnExitCode>3</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<DllOption>
<SimDllName>SARM.DLL</SimDllName>
<SimDllArguments></SimDllArguments>
<SimDlgDll>DARMP.DLL</SimDlgDll>
<SimDlgDllArguments></SimDlgDllArguments>
<TargetDllName>SARM.DLL</TargetDllName>
<TargetDllArguments></TargetDllArguments>
<TargetDlgDll>TARMP.DLL</TargetDlgDll>
<TargetDlgDllArguments></TargetDlgDllArguments>
</DllOption>
<DebugOption>
<OPTHX>
<HexSelection>1</HexSelection>
<HexRangeLowAddress>0</HexRangeLowAddress>
<HexRangeHighAddress>0</HexRangeHighAddress>
<HexOffset>0</HexOffset>
<Oh166RecLen>16</Oh166RecLen>
</OPTHX>
<Simulator>
<UseSimulator>1</UseSimulator>
<LoadApplicationAtStartup>1</LoadApplicationAtStartup>
<RunToMain>1</RunToMain>
<RestoreBreakpoints>1</RestoreBreakpoints>
<RestoreWatchpoints>1</RestoreWatchpoints>
<RestoreMemoryDisplay>1</RestoreMemoryDisplay>
<RestoreFunctions>1</RestoreFunctions>
<RestoreToolbox>1</RestoreToolbox>
<LimitSpeedToRealTime>0</LimitSpeedToRealTime>
</Simulator>
<Target>
<UseTarget>0</UseTarget>
<LoadApplicationAtStartup>1</LoadApplicationAtStartup>
<RunToMain>0</RunToMain>
<RestoreBreakpoints>1</RestoreBreakpoints>
<RestoreWatchpoints>1</RestoreWatchpoints>
<RestoreMemoryDisplay>1</RestoreMemoryDisplay>
<RestoreFunctions>0</RestoreFunctions>
<RestoreToolbox>1</RestoreToolbox>
<RestoreTracepoints>1</RestoreTracepoints>
</Target>
<RunDebugAfterBuild>0</RunDebugAfterBuild>
<TargetSelection>-1</TargetSelection>
<SimDlls>
<CpuDll></CpuDll>
<CpuDllArguments></CpuDllArguments>
<PeripheralDll></PeripheralDll>
<PeripheralDllArguments></PeripheralDllArguments>
<InitializationFile></InitializationFile>
</SimDlls>
<TargetDlls>
<CpuDll></CpuDll>
<CpuDllArguments></CpuDllArguments>
<PeripheralDll></PeripheralDll>
<PeripheralDllArguments></PeripheralDllArguments>
<InitializationFile></InitializationFile>
<Driver></Driver>
</TargetDlls>
</DebugOption>
<Utilities>
<Flash1>
<UseTargetDll>0</UseTargetDll>
<UseExternalTool>0</UseExternalTool>
<RunIndependent>0</RunIndependent>
<UpdateFlashBeforeDebugging>0</UpdateFlashBeforeDebugging>
<Capability>0</Capability>
<DriverSelection>-1</DriverSelection>
</Flash1>
<bUseTDR>0</bUseTDR>
<Flash2></Flash2>
<Flash3></Flash3>
<Flash4></Flash4>
<pFcarmOut></pFcarmOut>
<pFcarmGrp></pFcarmGrp>
<pFcArmRoot></pFcArmRoot>
<FcArmLst>0</FcArmLst>
</Utilities>
<TargetArmAds>
<ArmAdsMisc>
<GenerateListings>0</GenerateListings>
<asHll>1</asHll>
<asAsm>1</asAsm>
<asMacX>1</asMacX>
<asSyms>1</asSyms>
<asFals>1</asFals>
<asDbgD>1</asDbgD>
<asForm>1</asForm>
<ldLst>0</ldLst>
<ldmm>1</ldmm>
<ldXref>1</ldXref>
<BigEnd>0</BigEnd>
<AdsALst>1</AdsALst>
<AdsACrf>1</AdsACrf>
<AdsANop>0</AdsANop>
<AdsANot>0</AdsANot>
<AdsLLst>1</AdsLLst>
<AdsLmap>1</AdsLmap>
<AdsLcgr>1</AdsLcgr>
<AdsLsym>1</AdsLsym>
<AdsLszi>1</AdsLszi>
<AdsLtoi>1</AdsLtoi>
<AdsLsun>1</AdsLsun>
<AdsLven>1</AdsLven>
<AdsLsxf>1</AdsLsxf>
<RvctClst>0</RvctClst>
<GenPPlst>0</GenPPlst>
<AdsCpuType>ARM7TDMI</AdsCpuType>
<RvctDeviceName></RvctDeviceName>
<mOS>0</mOS>
<uocRom>0</uocRom>
<uocRam>0</uocRam>
<hadIROM>0</hadIROM>
<hadIRAM>0</hadIRAM>
<hadXRAM>0</hadXRAM>
<uocXRam>0</uocXRam>
<RvdsVP>0</RvdsVP>
<hadIRAM2>0</hadIRAM2>
<hadIROM2>0</hadIROM2>
<StupSel>0</StupSel>
<useUlib>0</useUlib>
<EndSel>0</EndSel>
<uLtcg>0</uLtcg>
<RoSelD>0</RoSelD>
<RwSelD>5</RwSelD>
<CodeSel>0</CodeSel>
<OptFeed>0</OptFeed>
<NoZi1>0</NoZi1>
<NoZi2>0</NoZi2>
<NoZi3>0</NoZi3>
<NoZi4>0</NoZi4>
<NoZi5>0</NoZi5>
<Ro1Chk>0</Ro1Chk>
<Ro2Chk>0</Ro2Chk>
<Ro3Chk>0</Ro3Chk>
<Ir1Chk>0</Ir1Chk>
<Ir2Chk>0</Ir2Chk>
<Ra1Chk>0</Ra1Chk>
<Ra2Chk>0</Ra2Chk>
<Ra3Chk>0</Ra3Chk>
<Im1Chk>0</Im1Chk>
<Im2Chk>0</Im2Chk>
<OnChipMemories>
<Ocm1>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm1>
<Ocm2>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm2>
<Ocm3>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm3>
<Ocm4>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm4>
<Ocm5>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm5>
<Ocm6>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm6>
<IRAM>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</IRAM>
<IROM>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</IROM>
<XRAM>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</XRAM>
<OCR_RVCT1>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT1>
<OCR_RVCT2>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT2>
<OCR_RVCT3>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT3>
<OCR_RVCT4>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT4>
<OCR_RVCT5>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT5>
<OCR_RVCT6>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT6>
<OCR_RVCT7>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT7>
<OCR_RVCT8>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT8>
<OCR_RVCT9>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT9>
<OCR_RVCT10>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT10>
</OnChipMemories>
<RvctStartVector></RvctStartVector>
</ArmAdsMisc>
<Cads>
<interw>1</interw>
<Optim>1</Optim>
<oTime>0</oTime>
<SplitLS>0</SplitLS>
<OneElfS>0</OneElfS>
<Strict>0</Strict>
<EnumInt>0</EnumInt>
<PlainCh>0</PlainCh>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<wLevel>0</wLevel>
<uThumb>0</uThumb>
<uSurpInc>0</uSurpInc>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
<Aads>
<interw>1</interw>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<thumb>0</thumb>
<SplitLS>0</SplitLS>
<SwStkChk>0</SwStkChk>
<NoWarn>0</NoWarn>
<uSurpInc>0</uSurpInc>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Aads>
<LDads>
<umfTarg>0</umfTarg>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<noStLib>0</noStLib>
<RepFail>1</RepFail>
<useFile>0</useFile>
<TextAddressRange>0x00000000</TextAddressRange>
<DataAddressRange>0x00000000</DataAddressRange>
<ScatterFile></ScatterFile>
<IncludeLibs></IncludeLibs>
<IncludeLibsPath></IncludeLibsPath>
<Misc></Misc>
<LinkerInputFile></LinkerInputFile>
<DisabledWarnings></DisabledWarnings>
</LDads>
</TargetArmAds>
</TargetOption>
<Groups>
<Group>
<GroupName>Source Group 1</GroupName>
<Files>
<File>
<FileName>assem.s</FileName>
<FileType>2</FileType>
<FilePath>.\assem.s</FilePath>
</File>
</Files>
</Group>
</Groups>
</Target>
</Targets>
</Project>

View File

@@ -0,0 +1,2 @@
Dependencies for Project 'Proj', Target 'Target 1': (DO NOT MODIFY !)
F (.\assem.s)(0x53282410)(--cpu ARM7TDMI --pd "__EVAL SETA 1" -g --apcs=interwork

View File

@@ -0,0 +1,124 @@
ARM Macro Assembler Page 1
1 00000000 AREA ConstrainProg, CODE, READWRITE
2 00000000 ENTRY
3 00000000 Start
4 00000000 E28FD054 ADR sp, Base ;Point to the base
of the stack
5 00000004 E59F004C LDR r0, LowerVal ;Load the lower va
lue into r0
6 00000008 E59F1044 LDR r1, UpperVal ;Load the upper va
lue in r1
7 0000000C E59F203C LDR r2, ParamToConstrain ;Load the
value to constrain
into r2
8 00000010 E50D0004 STR r0,[sp,#-4] ;Load r0 onto the s
tack pointer
9 00000014 E50D1004 STR r1,[sp,#-4] ;Load r1 onto the s
tack pointer
10 00000018 E50D2004 STR r2,[sp,#-4] ;Load r2 onto the s
tack pointer
11 0000001C EB000001 BL Constrain ;Call constrain pro
cedure
12 00000020 E59D2000 LDR r2, [sp] ;Load constrained v
alue back into r2
13 00000024 ;r2 should now contain 2000
14 00000024 E28DD008 ADD sp, sp, #8 ;Fix the stack poin
ter
15 00000028 Constrain
16 00000028 E50DE004 STR LR, [sp, #-4]
17 0000002C E59D500C LDR r5, [sp, #12]
18 00000030 E59D4008 LDR r4, [sp, #8]
19 00000034 E59D3004 LDR r3, [sp, #4]
20 00000038 E1530004 CMP r3, r4
21 0000003C 359D3008 LDRLO r3, [sp, #8]
22 00000040 E1530005 CMP r3, r5
23 00000044 859D300C LDRHI r3, [sp, #12]
24 00000048 E58D3004 STR r3, [sp, #4]
25 0000004C E49DF004 LDR PC, [sp], #4
26 00000050 00000898
ParamToConstrain
DCD 2200 ;Value to constrain
27 00000054 000007D0
UpperVal
DCD 2000 ;Value to constrain
28 00000058 000003E8
LowerVal
DCD 1000 ;Value to constrain
29 0000005C AAAAAAAA
Base DCD 0xAAAAAAAA
30 00000060 END
Command Line: --debug --xref --apcs=interwork --depend=.\assem.d -o.\assem.o -I
C:\Keil\ARM\RV31\INC -IC:\Keil\ARM\CMSIS\Include --predefine="__EVAL SETA 1" --
list=.\assem.lst assem.s
ARM Macro Assembler Page 1 Alphabetic symbol ordering
Relocatable symbols
Base 0000005C
Symbol: Base
Definitions
At line 29 in file assem.s
Uses
At line 4 in file assem.s
Comment: Base used once
Constrain 00000028
Symbol: Constrain
Definitions
At line 15 in file assem.s
Uses
At line 11 in file assem.s
Comment: Constrain used once
ConstrainProg 00000000
Symbol: ConstrainProg
Definitions
At line 1 in file assem.s
Uses
None
Comment: ConstrainProg unused
LowerVal 00000058
Symbol: LowerVal
Definitions
At line 28 in file assem.s
Uses
At line 5 in file assem.s
Comment: LowerVal used once
ParamToConstrain 00000050
Symbol: ParamToConstrain
Definitions
At line 26 in file assem.s
Uses
At line 7 in file assem.s
Comment: ParamToConstrain used once
Start 00000000
Symbol: Start
Definitions
At line 3 in file assem.s
Uses
None
Comment: Start unused
UpperVal 00000054
Symbol: UpperVal
Definitions
At line 27 in file assem.s
Uses
At line 6 in file assem.s
Comment: UpperVal used once
7 symbols
338 symbols in table

View File

@@ -0,0 +1,30 @@
AREA ConstrainProg, CODE, READWRITE
ENTRY
Start
ADR sp, Base ;Point to the base of the stack
LDR r0, LowerVal ;Load the lower value into r0
LDR r1, UpperVal ;Load the upper value in r1
LDR r2, ParamToConstrain ;Load the value to constrain into r2
STR r0,[sp,#-4] ;Load r0 onto the stack pointer
STR r1,[sp,#-4] ;Load r1 onto the stack pointer
STR r2,[sp,#-4] ;Load r2 onto the stack pointer
BL Constrain ;Call constrain procedure
LDR r2, [sp] ;Load constrained value back into r2
;r2 should now contain 2000
ADD sp, sp, #8 ;Fix the stack pointer
Constrain
STR LR, [sp, #-4] ;Store return address
LDR r5, [sp, #12] ;Retrieve lower
LDR r4, [sp, #8] ;Retrieve upper
LDR r3, [sp, #4] ;Retrieve val to constrain
CMP r3, r4 ;Check if higher than max
LDRHI r3, [sp, #8] ;If so, load max
CMP r3, r5 ;Check if lower than min
LDRLO r3, [sp, #12] ;If so, load min
STR r3, [sp, #4] ;Overwrite constrained val
LDR PC, [sp], #4 ;Return from procedure
ParamToConstrain DCD 2200 ;Value to constrain
UpperVal DCD 2000 ;Value to constrain
LowerVal DCD 1000 ;Value to constrain
Base DCD 0xAAAAAAAA
END

View File

@@ -0,0 +1,3 @@
AREA Pointers, CODE, READONLY
ENTRY
Start ADR r0, List

View File

@@ -0,0 +1,17 @@
AREA Pointers, CODE, READONLY
ENTRY
Start
ADR r0, Array ;Point to address of array
MOV r1, #5 ;Set up a loop counter for array
MOV r2, #1 ;Set first val to one so math works
MultLoop
LDR r3,[r0] ;Put current array value into r3
MUL r2,r3,r2 ;Multiply array val by stored product
ADD r0,r0,#4 ;Move forward by one array element
SUBS r1,r1,#1 ;Decrease loop counter
BNE MultLoop ;repeat until all elements added
;Final value in r2 (0x78 == 120 == 5!)
Array DCD 1,2,3,4,5 ;Array to hold values
END

View File

@@ -0,0 +1,32 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TITLE LoopArrayMultiply (main.asm)
;Author: Corwin Perren
;Date: 3/13/2014
;Description:
; This program runs through an array and multiplies each value until all
; array elements have been iterated through
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INCLUDE Irvine32.inc
.data
Array DWORD 1,2,3,4,5 ;Array with five values
.code
main PROC
cld ;Set direction forward
mov esi, OFFSET Array ;Point esi to offset for array
mov ecx, LENGTHOF Array ;Set loop counter to length of array
mov ebx, 1 ;Set storage reg to 1 so initial multiplication works
MultLoop:
lodsd ;Load current array value into eax
mul ebx ;Multiply eax by ebx
mov ebx, eax ;Store result in ebx
loop MultLoop ;Loop until array empty
mov eax, ebx ;Move final value into eax for printing
call WriteDec ;Print to screen
call Crlf ;Print line
exit ;Exit program
main ENDP
END main

View File

@@ -0,0 +1,30 @@
AREA ConstrainProg, CODE, READWRITE
ENTRY
Start
ADR sp, Base ;Point to the base of the stack
LDR r0, LowerVal ;Load the lower value into r0
LDR r1, UpperVal ;Load the upper value in r1
LDR r2, ParamToConstrain ;Load the value to constrain into r2
STR r0,[sp,#-4] ;Load r0 onto the stack pointer
STR r1,[sp,#-4] ;Load r1 onto the stack pointer
STR r2,[sp,#-4] ;Load r2 onto the stack pointer
BL Constrain ;Call constrain procedure
LDR r2, [sp] ;Load constrained value back into r2
;r2 should now contain 2000
ADD sp, sp, #8 ;Fix the stack pointer
Constrain
STR LR, [sp, #-4] ;Store return address
LDR r5, [sp, #12] ;Retrieve lower
LDR r4, [sp, #8] ;Retrieve upper
LDR r3, [sp, #4] ;Retrieve val to constrain
CMP r3, r4 ;Check if higher than max
LDRHI r3, [sp, #8] ;If so, load max
CMP r3, r5 ;Check if lower than min
LDRLO r3, [sp, #12] ;If so, load min
STR r3, [sp, #4] ;Overwrite constrained val
LDR PC, [sp], #4 ;Return from procedure
ParamToConstrain DCD 2200 ;Value to constrain
UpperVal DCD 2000 ;Value to constrain
LowerVal DCD 1000 ;Value to constrain
Base DCD 0xAAAAAAAA
END

View File

@@ -0,0 +1,48 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TITLE Constrain (main.asm)
;Author: Corwin Perren
;Date: 3/13/2014
;Description:
; This program runs passes an argument via stack to a constain function
; based off of hobby R/C pulse times (1000-2000 microseconds)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INCLUDE Irvine32.inc
.data
ParamToConstrain DWORD 2500 ;;;;Value to constrain
UpperVal DWORD 2000 ;;;;Upper limit for constraint
LowerVal DWORD 1000 ;;;;Lower limit for constraint
.code
Constrain PROC
mov ebp, esp ;;;;Move stack pointer into ebp
mov eax, [ebp+4] ;;;;Move the param to constrain into eax
cmp eax, [ebp+8] ;;;;Compare param to constrain to upper val
jg IsGreater ;;;;If it's greater, jump to isgreater
cmp eax, [ebp+12] ;;;;If it's not greater check if it's lower than lower val
jg NoChange ;;;;If it's not lower, jump to end of procedure
mov eax, [ebp+12] ;;;;If lower, move lower constrain value into eax
mov [ebp+4], eax ;;;;Replace value to constrain with eax
jmp NoChange ;;;;Just to end of procedure
IsGreater:
mov eax, [ebp+8] ;;;;If greater, move upper val into eax
mov [ebp+4], eax ;;;;Replace value to constrain with eax
NoChange:
ret ;;;;Return from procedure
Constrain ENDP
main PROC
MultLoop:
push LowerVal ;;;;Push lower constraint to the stack
push UpperVal ;;;;Push upper constraint to the stack
push ParamToConstrain ;;;;Push value onto the stack
call Constrain ;;;;Constrain this value
pop eax ;;;;Pop constrained value off the stack
add esp, 8 ;;;;Clean up stack
call WriteDec ;;;;Write value to screen
call Crlf ;;;;Prints a new line
exit ;;;;Exits the program
main ENDP
END main