Skip to content

Commit c5c9b85

Browse files
committed
Adding epsisode 4
1 parent 67e6b9f commit c5c9b85

File tree

4 files changed

+171
-0
lines changed

4 files changed

+171
-0
lines changed

Assembly64.sln

+9
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode 3", "Episode 3", "{
1717
EndProject
1818
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Directives", "Episode3\Directives\Directives.vcxproj", "{58E5588C-DC09-4951-B8B0-3EF2BABD38F4}"
1919
EndProject
20+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode 4", "Episode 4", "{BDAB1C19-10D8-42C3-B247-7EBF52866D78}"
21+
EndProject
22+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Add_Sub_Inc_Dec", "Episode4\Add_Sub_Inc_Dec\Add_Sub_Inc_Dec.vcxproj", "{49E26C62-F111-4C69-AC6A-784B219B9ADE}"
23+
EndProject
2024
Global
2125
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2226
Debug|x64 = Debug|x64
@@ -39,6 +43,10 @@ Global
3943
{58E5588C-DC09-4951-B8B0-3EF2BABD38F4}.Debug|x64.Build.0 = Debug|x64
4044
{58E5588C-DC09-4951-B8B0-3EF2BABD38F4}.Release|x64.ActiveCfg = Release|x64
4145
{58E5588C-DC09-4951-B8B0-3EF2BABD38F4}.Release|x64.Build.0 = Release|x64
46+
{49E26C62-F111-4C69-AC6A-784B219B9ADE}.Debug|x64.ActiveCfg = Debug|x64
47+
{49E26C62-F111-4C69-AC6A-784B219B9ADE}.Debug|x64.Build.0 = Debug|x64
48+
{49E26C62-F111-4C69-AC6A-784B219B9ADE}.Release|x64.ActiveCfg = Release|x64
49+
{49E26C62-F111-4C69-AC6A-784B219B9ADE}.Release|x64.Build.0 = Release|x64
4250
EndGlobalSection
4351
GlobalSection(SolutionProperties) = preSolution
4452
HideSolutionNode = FALSE
@@ -48,6 +56,7 @@ Global
4856
{2428959B-A8CD-4714-925C-449824952972} = {61B13938-2A49-4055-9F82-408CA73A43E0}
4957
{A1259A23-9513-4BC9-955C-8460C98A84AF} = {00B8EA82-EE93-4557-A6F6-27E1FF7E9EB7}
5058
{58E5588C-DC09-4951-B8B0-3EF2BABD38F4} = {95ABA174-1152-401A-9D3E-9D6CDE2B9228}
59+
{49E26C62-F111-4C69-AC6A-784B219B9ADE} = {BDAB1C19-10D8-42C3-B247-7EBF52866D78}
5160
EndGlobalSection
5261
GlobalSection(ExtensibilityGlobals) = postSolution
5362
SolutionGuid = {74B06FA8-487D-4545-8B72-13DF56D10686}
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>{49e26c62-f111-4c69-ac6a-784b219b9ade}</ProjectGuid>
17+
<RootNamespace>Add_Sub_Inc_Dec</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>
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>

Episode4/Add_Sub_Inc_Dec/main.asm

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
.DATA
3+
MyData QWORD 42
4+
5+
6+
.CODE
7+
main PROC
8+
9+
mov rax, 0
10+
11+
; add/sub <register>, <immediate values>
12+
13+
add rax, 5
14+
add rax, 2
15+
sub rax, 3
16+
sub rax, 4
17+
18+
; add/sub <register>, <register>
19+
20+
mov rax, 5
21+
mov rbx, 2
22+
add rax, rbx
23+
sub rax, rbx
24+
25+
; add <register>, <memory>
26+
; add <memory>, <register>
27+
28+
add rax, MyData
29+
sub MyData, 2
30+
31+
; overflow
32+
33+
mov al, 255
34+
add al, 1 ; overflow, carry flag set
35+
36+
mov al, 255
37+
add ax, 1
38+
39+
mov ax, 2
40+
sub al, 1
41+
sub al, 1
42+
sub al, 1 ; underflow, carry flag set
43+
44+
; inc / dec
45+
46+
mov rax, 7
47+
inc rax
48+
inc rax
49+
dec rax
50+
dec rax
51+
52+
; inc <memory>
53+
; dec <memory>
54+
55+
inc MyData
56+
dec MyData
57+
58+
; inc / dec do not set (or clear) the carry flag (overflow is not detected)
59+
60+
mov al, 252
61+
add al, 1
62+
inc al
63+
inc al
64+
inc al ; no carry flag set, add would have set the flag
65+
dec al ; no carry flag set, sub would have set the flag
66+
67+
mov eax, 0
68+
ret
69+
main ENDP
70+
71+
72+
END

0 commit comments

Comments
 (0)