Skip to content

Commit 2b2a579

Browse files
committed
Adding episode 7
1 parent c33acb7 commit 2b2a579

4 files changed

Lines changed: 221 additions & 0 deletions

File tree

Assembly64.sln

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConditionalJumps", "Episode
2929
EndProject
3030
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode 6", "Episode 6", "{F3695239-C1C4-487E-A513-9D53EDECD849}"
3131
EndProject
32+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode 7", "Episode 7", "{BAD8B21D-E3A6-4E48-B460-E07CDA086953}"
33+
EndProject
34+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CmpInstruction", "Episode7\CmpInstruction\CmpInstruction.vcxproj", "{B1ED6EA7-DD8F-4F43-B429-4EB53F83041E}"
35+
EndProject
3236
Global
3337
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3438
Debug|x64 = Debug|x64
@@ -63,6 +67,10 @@ Global
6367
{4DD40142-837D-4461-BA3F-0A805A2A057A}.Debug|x64.Build.0 = Debug|x64
6468
{4DD40142-837D-4461-BA3F-0A805A2A057A}.Release|x64.ActiveCfg = Release|x64
6569
{4DD40142-837D-4461-BA3F-0A805A2A057A}.Release|x64.Build.0 = Release|x64
70+
{B1ED6EA7-DD8F-4F43-B429-4EB53F83041E}.Debug|x64.ActiveCfg = Debug|x64
71+
{B1ED6EA7-DD8F-4F43-B429-4EB53F83041E}.Debug|x64.Build.0 = Debug|x64
72+
{B1ED6EA7-DD8F-4F43-B429-4EB53F83041E}.Release|x64.ActiveCfg = Release|x64
73+
{B1ED6EA7-DD8F-4F43-B429-4EB53F83041E}.Release|x64.Build.0 = Release|x64
6674
EndGlobalSection
6775
GlobalSection(SolutionProperties) = preSolution
6876
HideSolutionNode = FALSE
@@ -75,6 +83,7 @@ Global
7583
{49E26C62-F111-4C69-AC6A-784B219B9ADE} = {BDAB1C19-10D8-42C3-B247-7EBF52866D78}
7684
{03695492-74FF-4903-BE0B-6B46CFABA571} = {5A70F316-4DFE-4502-9A21-51B2BD05D446}
7785
{4DD40142-837D-4461-BA3F-0A805A2A057A} = {F3695239-C1C4-487E-A513-9D53EDECD849}
86+
{B1ED6EA7-DD8F-4F43-B429-4EB53F83041E} = {BAD8B21D-E3A6-4E48-B460-E07CDA086953}
7887
EndGlobalSection
7988
GlobalSection(ExtensibilityGlobals) = postSolution
8089
SolutionGuid = {74B06FA8-487D-4545-8B72-13DF56D10686}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|x64">
5+
<Configuration>Debug</Configuration>
6+
<Platform>x64</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|x64">
9+
<Configuration>Release</Configuration>
10+
<Platform>x64</Platform>
11+
</ProjectConfiguration>
12+
</ItemGroup>
13+
<PropertyGroup Label="Globals">
14+
<VCProjectVersion>16.0</VCProjectVersion>
15+
<Keyword>Win32Proj</Keyword>
16+
<ProjectGuid>{b1ed6ea7-dd8f-4f43-b429-4eb53f83041e}</ProjectGuid>
17+
<RootNamespace>CmpInstruction</RootNamespace>
18+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
19+
</PropertyGroup>
20+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
21+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
22+
<ConfigurationType>Application</ConfigurationType>
23+
<UseDebugLibraries>true</UseDebugLibraries>
24+
<PlatformToolset>v143</PlatformToolset>
25+
<CharacterSet>Unicode</CharacterSet>
26+
</PropertyGroup>
27+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
28+
<ConfigurationType>Application</ConfigurationType>
29+
<UseDebugLibraries>false</UseDebugLibraries>
30+
<PlatformToolset>v143</PlatformToolset>
31+
<WholeProgramOptimization>true</WholeProgramOptimization>
32+
<CharacterSet>Unicode</CharacterSet>
33+
</PropertyGroup>
34+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
35+
<ImportGroup Label="ExtensionSettings">
36+
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" />
37+
</ImportGroup>
38+
<ImportGroup Label="Shared">
39+
</ImportGroup>
40+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
41+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
42+
</ImportGroup>
43+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
44+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
45+
</ImportGroup>
46+
<PropertyGroup Label="UserMacros" />
47+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
48+
<ClCompile>
49+
<WarningLevel>Level3</WarningLevel>
50+
<SDLCheck>true</SDLCheck>
51+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
52+
<ConformanceMode>true</ConformanceMode>
53+
</ClCompile>
54+
<Link>
55+
<SubSystem>Console</SubSystem>
56+
<GenerateDebugInformation>true</GenerateDebugInformation>
57+
<EntryPointSymbol>main</EntryPointSymbol>
58+
</Link>
59+
</ItemDefinitionGroup>
60+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
61+
<ClCompile>
62+
<WarningLevel>Level3</WarningLevel>
63+
<FunctionLevelLinking>true</FunctionLevelLinking>
64+
<IntrinsicFunctions>true</IntrinsicFunctions>
65+
<SDLCheck>true</SDLCheck>
66+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
67+
<ConformanceMode>true</ConformanceMode>
68+
</ClCompile>
69+
<Link>
70+
<SubSystem>Console</SubSystem>
71+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
72+
<OptimizeReferences>true</OptimizeReferences>
73+
<GenerateDebugInformation>true</GenerateDebugInformation>
74+
<EntryPointSymbol>main</EntryPointSymbol>
75+
</Link>
76+
</ItemDefinitionGroup>
77+
<ItemGroup>
78+
<MASM Include="main.asm" />
79+
</ItemGroup>
80+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
81+
<ImportGroup Label="ExtensionTargets">
82+
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
83+
</ImportGroup>
84+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<MASM Include="main.asm" />
5+
</ItemGroup>
6+
</Project>

Episode7/CmpInstruction/main.asm

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
2+
.CODE
3+
4+
main PROC
5+
6+
; if (a == b) ; Check for A equals B
7+
8+
mov rcx, 7
9+
mov rdx, 7
10+
call testEqual
11+
12+
mov rcx, 7
13+
mov rdx, 5
14+
call testEqual
15+
16+
; if (a < b) ; Check for A is less than B
17+
18+
mov rcx, 4
19+
mov rdx, 5
20+
call testLess
21+
22+
mov rcx, 5
23+
mov rdx, 5
24+
call testLess
25+
26+
; if (a <= b) ; Check for A is less than or equal to B
27+
28+
mov rcx, 5
29+
mov rdx, 5
30+
call testLessEqual
31+
32+
mov rcx, 6
33+
mov rdx, 5
34+
call testLessEqual
35+
36+
; if (a > b) ; Check for A is greater than B
37+
38+
mov rcx, 7
39+
mov rdx, 4
40+
call testGreater
41+
42+
mov rcx, 4
43+
mov rdx, 7
44+
call testGreater
45+
46+
; if (a >= b) ; Check for A is greater than or equal to B
47+
48+
mov rcx, 9
49+
mov rdx, 8
50+
call testGreaterEqual
51+
52+
mov rcx, 8
53+
mov rdx, 9
54+
call testGreaterEqual
55+
56+
57+
mov rax, 0
58+
ret
59+
main ENDP
60+
61+
62+
testEqual PROC
63+
cmp rcx, rdx ; Zero flag (ZR) = 1 when Equal, else ZR = 0
64+
je Equal
65+
jne NotEqual ; these 2 lines are obsolete, just for demonstrating jne instruction
66+
ret ; these 2 lines are obsolete, just for demonstrating jne instruction
67+
NotEqual:
68+
ret
69+
Equal:
70+
ret
71+
testEqual ENDP
72+
73+
74+
testLess PROC
75+
cmp rcx, rdx ; Carry flag CY = 1 and Zero flag ZR = 0 when Less, else not Less (CY = 0 or ZR = 1)
76+
jl Less
77+
jnl NotLess ; these 2 lines are obsolete, just for demonstrating jnl instruction
78+
ret ; these 2 lines are obsolete, just for demonstrating jnl instruction
79+
NotLess:
80+
ret
81+
Less:
82+
ret
83+
testLess ENDP
84+
85+
86+
testLessEqual PROC
87+
cmp rcx, rdx ; Carry flag CY = 1 or Zero flag ZR = 1 (LessOrEqual), else Greater (CY and ZR flags are 0)
88+
jle LessEqual
89+
jg NotLessEqual ; these 2 lines are obsolete, just for demonstrating jg instruction
90+
ret ; these 2 lines are obsolete, just for demonstrating jg instruction
91+
NotLessEqual:
92+
ret
93+
LessEqual:
94+
ret
95+
testLessEqual ENDP
96+
97+
98+
testGreater PROC
99+
cmp rcx, rdx ; Carry flag CY = 0 and Zero flag ZR = 0 when Greater, else not Greater (CY = 1 or ZR = 1)
100+
jg Greater
101+
jng NotGreater ; these 2 lines are obsolete, just for demonstrating jng instruction
102+
ret ; these 2 lines are obsolete, just for demonstrating jng instruction
103+
NotGreater:
104+
ret
105+
Greater:
106+
ret
107+
testGreater ENDP
108+
109+
110+
testGreaterEqual PROC
111+
cmp rcx, rdx ; Carry flag CY = 0 or Zero flag ZR = 1 when GreaterOrEqual, else Less (CY = 1 and ZR = 0)
112+
jge GreaterEqual
113+
jl NotGreaterEqual ; these 2 lines are obsolete, just for demonstrating jl instruction
114+
ret ; these 2 lines are obsolete, just for demonstrating jl instruction
115+
NotGreaterEqual:
116+
ret
117+
GreaterEqual:
118+
ret
119+
testGreaterEqual ENDP
120+
121+
122+
END

0 commit comments

Comments
 (0)