├── .gitignore ├── Assembly64.sln ├── Episode1 ├── AssemblyAndC │ ├── AssemblyAndC.vcxproj │ ├── AssemblyAndC.vcxproj.filters │ ├── main.cpp │ └── sum.asm └── AssemblyOnly │ ├── AssemblyOnly.vcxproj │ ├── AssemblyOnly.vcxproj.filters │ └── main.asm ├── Episode10 └── Printf │ ├── Printf.vcxproj │ ├── Printf.vcxproj.filters │ └── main.asm ├── Episode11 └── Disassembly │ ├── Disassembly.vcxproj │ ├── Disassembly.vcxproj.filters │ └── main.cpp ├── Episode12 └── Scanf │ ├── Scanf.vcxproj │ ├── Scanf.vcxproj.filters │ └── main.asm ├── Episode13 └── BitwiseLogicalInstructions │ ├── BitwiseLogicalInstructions.vcxproj │ ├── BitwiseLogicalInstructions.vcxproj.filters │ └── main.asm ├── Episode14 └── NumberGuessingGame │ ├── NumberGuessingGame.vcxproj │ ├── NumberGuessingGame.vcxproj.filters │ └── main.asm ├── Episode15 └── CreateWindow │ ├── CreateWindow.vcxproj │ ├── CreateWindow.vcxproj.filters │ ├── main.asm │ └── windows.inc ├── Episode16 └── 16_BasicFloatingPointsSSE │ ├── 16_BasicFloatingPointsSSE.vcxproj │ ├── 16_BasicFloatingPointsSSE.vcxproj.filters │ └── main.asm ├── Episode2 └── Registers+MOV │ ├── Registers+MOV.vcxproj │ ├── Registers+MOV.vcxproj.filters │ ├── main.cpp │ └── registers+MOV.asm ├── Episode3 └── Directives │ ├── Directives.vcxproj │ ├── Directives.vcxproj.filters │ └── main.asm ├── Episode4 └── Add_Sub_Inc_Dec │ ├── Add_Sub_Inc_Dec.vcxproj │ ├── Add_Sub_Inc_Dec.vcxproj.filters │ └── main.asm ├── Episode5 └── Flags │ ├── Flags.vcxproj │ ├── Flags.vcxproj.filters │ └── main.asm ├── Episode6 └── ConditionalJumps │ ├── ConditionalJumps.vcxproj │ ├── ConditionalJumps.vcxproj.filters │ └── main.asm ├── Episode7 └── CmpInstruction │ ├── CmpInstruction.vcxproj │ ├── CmpInstruction.vcxproj.filters │ └── main.asm ├── Episode8 └── DebuggingAssemblyCode │ ├── DebuggingAssemblyCode.vcxproj │ ├── DebuggingAssemblyCode.vcxproj.filters │ └── main.asm └── Episode9 └── Stack ├── Stack.vcxproj ├── Stack.vcxproj.filters └── main.asm /.gitignore: -------------------------------------------------------------------------------- 1 | .vs 2 | x64 3 | 4 | *.user 5 | *.bak -------------------------------------------------------------------------------- /Assembly64.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.6.33723.286 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssemblyAndC", "Episode1\AssemblyAndC\AssemblyAndC.vcxproj", "{B6DFCD0B-A590-489A-BD7D-54EDE27EBCCA}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssemblyOnly", "Episode1\AssemblyOnly\AssemblyOnly.vcxproj", "{2428959B-A8CD-4714-925C-449824952972}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode 1", "Episode 1", "{61B13938-2A49-4055-9F82-408CA73A43E0}" 11 | EndProject 12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode 2", "Episode 2", "{00B8EA82-EE93-4557-A6F6-27E1FF7E9EB7}" 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Registers+MOV", "Episode2\Registers+MOV\Registers+MOV.vcxproj", "{A1259A23-9513-4BC9-955C-8460C98A84AF}" 15 | EndProject 16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode 3", "Episode 3", "{95ABA174-1152-401A-9D3E-9D6CDE2B9228}" 17 | EndProject 18 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Directives", "Episode3\Directives\Directives.vcxproj", "{58E5588C-DC09-4951-B8B0-3EF2BABD38F4}" 19 | 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 24 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Flags", "Episode5\Flags\Flags.vcxproj", "{03695492-74FF-4903-BE0B-6B46CFABA571}" 25 | EndProject 26 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode 5", "Episode 5", "{5A70F316-4DFE-4502-9A21-51B2BD05D446}" 27 | EndProject 28 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConditionalJumps", "Episode6\ConditionalJumps\ConditionalJumps.vcxproj", "{4DD40142-837D-4461-BA3F-0A805A2A057A}" 29 | EndProject 30 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode 6", "Episode 6", "{F3695239-C1C4-487E-A513-9D53EDECD849}" 31 | 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 36 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode 8", "Episode 8", "{F01AFD1D-F14F-405A-ACAF-5CD165266DC1}" 37 | EndProject 38 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DebuggingAssemblyCode", "Episode8\DebuggingAssemblyCode\DebuggingAssemblyCode.vcxproj", "{99AC3A86-A531-4D77-92F9-461B12DC9B9C}" 39 | EndProject 40 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode 9", "Episode 9", "{C2B7084E-0A4D-415C-B798-6AF9D358861C}" 41 | EndProject 42 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Stack", "Episode9\Stack\Stack.vcxproj", "{9D66960B-9A65-4EBC-A634-54069B572D11}" 43 | EndProject 44 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode_10", "Episode_10", "{FB0B381C-979C-4651-AE85-A2E92A6579CB}" 45 | EndProject 46 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Printf", "Episode10\Printf\Printf.vcxproj", "{B21A457E-3E5C-4E42-9AFB-538781AD9F39}" 47 | EndProject 48 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode_11", "Episode_11", "{65103D72-F115-49D4-BEAD-F0481A7C80E3}" 49 | EndProject 50 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Disassembly", "Episode11\Disassembly\Disassembly.vcxproj", "{E303115F-3605-4683-A43D-57D46D553F27}" 51 | EndProject 52 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode_12", "Episode_12", "{10BB7B6A-C1ED-49E8-8222-2D3943458912}" 53 | EndProject 54 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Scanf", "Episode12\Scanf\Scanf.vcxproj", "{840F8D30-4C17-4596-890B-0CD8281307E4}" 55 | EndProject 56 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode_13", "Episode_13", "{7C5C8E6E-462B-48F4-9D85-F162F59FD5CF}" 57 | EndProject 58 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BitwiseLogicalInstructions", "Episode13\BitwiseLogicalInstructions\BitwiseLogicalInstructions.vcxproj", "{4F3265E2-67C5-4967-B8FA-1571762A8294}" 59 | EndProject 60 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode_14", "Episode_14", "{D354EE7B-7CE9-48C7-B7D8-217592787F83}" 61 | EndProject 62 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NumberGuessingGame", "Episode14\NumberGuessingGame\NumberGuessingGame.vcxproj", "{B3E230C9-A303-4C68-8691-8AB0822925C3}" 63 | EndProject 64 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode_15", "Episode_15", "{36099529-66C7-49EF-AFDA-F3D3F0AF19D0}" 65 | EndProject 66 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateWindow", "Episode15\CreateWindow\CreateWindow.vcxproj", "{A5DD5FF2-D454-456E-B80A-7E77EAFB4433}" 67 | EndProject 68 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Episode_16", "Episode_16", "{1F025D64-5B90-4D6B-96A8-06B27B54A0AC}" 69 | EndProject 70 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "16_BasicFloatingPointsSSE", "Episode16\16_BasicFloatingPointsSSE\16_BasicFloatingPointsSSE.vcxproj", "{D95A104F-5A90-4A76-9518-E28A13062BE7}" 71 | EndProject 72 | Global 73 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 74 | Debug|x64 = Debug|x64 75 | Release|x64 = Release|x64 76 | EndGlobalSection 77 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 78 | {B6DFCD0B-A590-489A-BD7D-54EDE27EBCCA}.Debug|x64.ActiveCfg = Debug|x64 79 | {B6DFCD0B-A590-489A-BD7D-54EDE27EBCCA}.Debug|x64.Build.0 = Debug|x64 80 | {B6DFCD0B-A590-489A-BD7D-54EDE27EBCCA}.Release|x64.ActiveCfg = Release|x64 81 | {B6DFCD0B-A590-489A-BD7D-54EDE27EBCCA}.Release|x64.Build.0 = Release|x64 82 | {2428959B-A8CD-4714-925C-449824952972}.Debug|x64.ActiveCfg = Debug|x64 83 | {2428959B-A8CD-4714-925C-449824952972}.Debug|x64.Build.0 = Debug|x64 84 | {2428959B-A8CD-4714-925C-449824952972}.Release|x64.ActiveCfg = Release|x64 85 | {2428959B-A8CD-4714-925C-449824952972}.Release|x64.Build.0 = Release|x64 86 | {A1259A23-9513-4BC9-955C-8460C98A84AF}.Debug|x64.ActiveCfg = Debug|x64 87 | {A1259A23-9513-4BC9-955C-8460C98A84AF}.Debug|x64.Build.0 = Debug|x64 88 | {A1259A23-9513-4BC9-955C-8460C98A84AF}.Release|x64.ActiveCfg = Release|x64 89 | {A1259A23-9513-4BC9-955C-8460C98A84AF}.Release|x64.Build.0 = Release|x64 90 | {58E5588C-DC09-4951-B8B0-3EF2BABD38F4}.Debug|x64.ActiveCfg = Debug|x64 91 | {58E5588C-DC09-4951-B8B0-3EF2BABD38F4}.Debug|x64.Build.0 = Debug|x64 92 | {58E5588C-DC09-4951-B8B0-3EF2BABD38F4}.Release|x64.ActiveCfg = Release|x64 93 | {58E5588C-DC09-4951-B8B0-3EF2BABD38F4}.Release|x64.Build.0 = Release|x64 94 | {49E26C62-F111-4C69-AC6A-784B219B9ADE}.Debug|x64.ActiveCfg = Debug|x64 95 | {49E26C62-F111-4C69-AC6A-784B219B9ADE}.Debug|x64.Build.0 = Debug|x64 96 | {49E26C62-F111-4C69-AC6A-784B219B9ADE}.Release|x64.ActiveCfg = Release|x64 97 | {49E26C62-F111-4C69-AC6A-784B219B9ADE}.Release|x64.Build.0 = Release|x64 98 | {03695492-74FF-4903-BE0B-6B46CFABA571}.Debug|x64.ActiveCfg = Debug|x64 99 | {03695492-74FF-4903-BE0B-6B46CFABA571}.Debug|x64.Build.0 = Debug|x64 100 | {03695492-74FF-4903-BE0B-6B46CFABA571}.Release|x64.ActiveCfg = Release|x64 101 | {03695492-74FF-4903-BE0B-6B46CFABA571}.Release|x64.Build.0 = Release|x64 102 | {4DD40142-837D-4461-BA3F-0A805A2A057A}.Debug|x64.ActiveCfg = Debug|x64 103 | {4DD40142-837D-4461-BA3F-0A805A2A057A}.Debug|x64.Build.0 = Debug|x64 104 | {4DD40142-837D-4461-BA3F-0A805A2A057A}.Release|x64.ActiveCfg = Release|x64 105 | {4DD40142-837D-4461-BA3F-0A805A2A057A}.Release|x64.Build.0 = Release|x64 106 | {B1ED6EA7-DD8F-4F43-B429-4EB53F83041E}.Debug|x64.ActiveCfg = Debug|x64 107 | {B1ED6EA7-DD8F-4F43-B429-4EB53F83041E}.Debug|x64.Build.0 = Debug|x64 108 | {B1ED6EA7-DD8F-4F43-B429-4EB53F83041E}.Release|x64.ActiveCfg = Release|x64 109 | {B1ED6EA7-DD8F-4F43-B429-4EB53F83041E}.Release|x64.Build.0 = Release|x64 110 | {99AC3A86-A531-4D77-92F9-461B12DC9B9C}.Debug|x64.ActiveCfg = Debug|x64 111 | {99AC3A86-A531-4D77-92F9-461B12DC9B9C}.Debug|x64.Build.0 = Debug|x64 112 | {99AC3A86-A531-4D77-92F9-461B12DC9B9C}.Release|x64.ActiveCfg = Release|x64 113 | {99AC3A86-A531-4D77-92F9-461B12DC9B9C}.Release|x64.Build.0 = Release|x64 114 | {9D66960B-9A65-4EBC-A634-54069B572D11}.Debug|x64.ActiveCfg = Debug|x64 115 | {9D66960B-9A65-4EBC-A634-54069B572D11}.Debug|x64.Build.0 = Debug|x64 116 | {9D66960B-9A65-4EBC-A634-54069B572D11}.Release|x64.ActiveCfg = Release|x64 117 | {9D66960B-9A65-4EBC-A634-54069B572D11}.Release|x64.Build.0 = Release|x64 118 | {B21A457E-3E5C-4E42-9AFB-538781AD9F39}.Debug|x64.ActiveCfg = Debug|x64 119 | {B21A457E-3E5C-4E42-9AFB-538781AD9F39}.Debug|x64.Build.0 = Debug|x64 120 | {B21A457E-3E5C-4E42-9AFB-538781AD9F39}.Release|x64.ActiveCfg = Release|x64 121 | {B21A457E-3E5C-4E42-9AFB-538781AD9F39}.Release|x64.Build.0 = Release|x64 122 | {E303115F-3605-4683-A43D-57D46D553F27}.Debug|x64.ActiveCfg = Debug|x64 123 | {E303115F-3605-4683-A43D-57D46D553F27}.Debug|x64.Build.0 = Debug|x64 124 | {E303115F-3605-4683-A43D-57D46D553F27}.Release|x64.ActiveCfg = Release|x64 125 | {E303115F-3605-4683-A43D-57D46D553F27}.Release|x64.Build.0 = Release|x64 126 | {840F8D30-4C17-4596-890B-0CD8281307E4}.Debug|x64.ActiveCfg = Debug|x64 127 | {840F8D30-4C17-4596-890B-0CD8281307E4}.Debug|x64.Build.0 = Debug|x64 128 | {840F8D30-4C17-4596-890B-0CD8281307E4}.Release|x64.ActiveCfg = Release|x64 129 | {840F8D30-4C17-4596-890B-0CD8281307E4}.Release|x64.Build.0 = Release|x64 130 | {4F3265E2-67C5-4967-B8FA-1571762A8294}.Debug|x64.ActiveCfg = Debug|x64 131 | {4F3265E2-67C5-4967-B8FA-1571762A8294}.Debug|x64.Build.0 = Debug|x64 132 | {4F3265E2-67C5-4967-B8FA-1571762A8294}.Release|x64.ActiveCfg = Release|x64 133 | {4F3265E2-67C5-4967-B8FA-1571762A8294}.Release|x64.Build.0 = Release|x64 134 | {B3E230C9-A303-4C68-8691-8AB0822925C3}.Debug|x64.ActiveCfg = Debug|x64 135 | {B3E230C9-A303-4C68-8691-8AB0822925C3}.Debug|x64.Build.0 = Debug|x64 136 | {B3E230C9-A303-4C68-8691-8AB0822925C3}.Release|x64.ActiveCfg = Release|x64 137 | {B3E230C9-A303-4C68-8691-8AB0822925C3}.Release|x64.Build.0 = Release|x64 138 | {A5DD5FF2-D454-456E-B80A-7E77EAFB4433}.Debug|x64.ActiveCfg = Debug|x64 139 | {A5DD5FF2-D454-456E-B80A-7E77EAFB4433}.Debug|x64.Build.0 = Debug|x64 140 | {A5DD5FF2-D454-456E-B80A-7E77EAFB4433}.Release|x64.ActiveCfg = Release|x64 141 | {A5DD5FF2-D454-456E-B80A-7E77EAFB4433}.Release|x64.Build.0 = Release|x64 142 | {D95A104F-5A90-4A76-9518-E28A13062BE7}.Debug|x64.ActiveCfg = Debug|x64 143 | {D95A104F-5A90-4A76-9518-E28A13062BE7}.Debug|x64.Build.0 = Debug|x64 144 | {D95A104F-5A90-4A76-9518-E28A13062BE7}.Release|x64.ActiveCfg = Release|x64 145 | {D95A104F-5A90-4A76-9518-E28A13062BE7}.Release|x64.Build.0 = Release|x64 146 | EndGlobalSection 147 | GlobalSection(SolutionProperties) = preSolution 148 | HideSolutionNode = FALSE 149 | EndGlobalSection 150 | GlobalSection(NestedProjects) = preSolution 151 | {B6DFCD0B-A590-489A-BD7D-54EDE27EBCCA} = {61B13938-2A49-4055-9F82-408CA73A43E0} 152 | {2428959B-A8CD-4714-925C-449824952972} = {61B13938-2A49-4055-9F82-408CA73A43E0} 153 | {A1259A23-9513-4BC9-955C-8460C98A84AF} = {00B8EA82-EE93-4557-A6F6-27E1FF7E9EB7} 154 | {58E5588C-DC09-4951-B8B0-3EF2BABD38F4} = {95ABA174-1152-401A-9D3E-9D6CDE2B9228} 155 | {49E26C62-F111-4C69-AC6A-784B219B9ADE} = {BDAB1C19-10D8-42C3-B247-7EBF52866D78} 156 | {03695492-74FF-4903-BE0B-6B46CFABA571} = {5A70F316-4DFE-4502-9A21-51B2BD05D446} 157 | {4DD40142-837D-4461-BA3F-0A805A2A057A} = {F3695239-C1C4-487E-A513-9D53EDECD849} 158 | {B1ED6EA7-DD8F-4F43-B429-4EB53F83041E} = {BAD8B21D-E3A6-4E48-B460-E07CDA086953} 159 | {99AC3A86-A531-4D77-92F9-461B12DC9B9C} = {F01AFD1D-F14F-405A-ACAF-5CD165266DC1} 160 | {9D66960B-9A65-4EBC-A634-54069B572D11} = {C2B7084E-0A4D-415C-B798-6AF9D358861C} 161 | {B21A457E-3E5C-4E42-9AFB-538781AD9F39} = {FB0B381C-979C-4651-AE85-A2E92A6579CB} 162 | {E303115F-3605-4683-A43D-57D46D553F27} = {65103D72-F115-49D4-BEAD-F0481A7C80E3} 163 | {840F8D30-4C17-4596-890B-0CD8281307E4} = {10BB7B6A-C1ED-49E8-8222-2D3943458912} 164 | {4F3265E2-67C5-4967-B8FA-1571762A8294} = {7C5C8E6E-462B-48F4-9D85-F162F59FD5CF} 165 | {B3E230C9-A303-4C68-8691-8AB0822925C3} = {D354EE7B-7CE9-48C7-B7D8-217592787F83} 166 | {A5DD5FF2-D454-456E-B80A-7E77EAFB4433} = {36099529-66C7-49EF-AFDA-F3D3F0AF19D0} 167 | {D95A104F-5A90-4A76-9518-E28A13062BE7} = {1F025D64-5B90-4D6B-96A8-06B27B54A0AC} 168 | EndGlobalSection 169 | GlobalSection(ExtensibilityGlobals) = postSolution 170 | SolutionGuid = {74B06FA8-487D-4545-8B72-13DF56D10686} 171 | EndGlobalSection 172 | EndGlobal 173 | -------------------------------------------------------------------------------- /Episode1/AssemblyAndC/AssemblyAndC.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {b6dfcd0b-a590-489a-bd7d-54ede27ebcca} 17 | AssemblyAndC 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | v143 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v143 31 | true 32 | Unicode 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Level3 50 | true 51 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | 54 | 55 | Console 56 | true 57 | 58 | 59 | 60 | 61 | Level3 62 | true 63 | true 64 | true 65 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 66 | true 67 | 68 | 69 | Console 70 | true 71 | true 72 | true 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Episode1/AssemblyAndC/AssemblyAndC.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Episode1/AssemblyAndC/main.cpp: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | 3 | 4 | #define ASSEMBLY 5 | 6 | 7 | #ifdef ASSEMBLY 8 | 9 | extern "C" int Sum(int a, int b); 10 | 11 | #else 12 | 13 | int Sum(int a, int b) 14 | { 15 | return a + b; 16 | } 17 | 18 | #endif 19 | 20 | 21 | 22 | int main() 23 | { 24 | int a, b, sum; 25 | 26 | a = 3; 27 | b = 2; 28 | sum = Sum(a, b); 29 | 30 | printf("The sum is %d\n", sum); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /Episode1/AssemblyAndC/sum.asm: -------------------------------------------------------------------------------- 1 | .CODE 2 | 3 | 4 | Sum PROC 5 | mov rax, rcx 6 | add rax, rdx 7 | ret 8 | Sum ENDP 9 | 10 | 11 | END 12 | -------------------------------------------------------------------------------- /Episode1/AssemblyOnly/AssemblyOnly.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {2428959b-a8cd-4714-925c-449824952972} 17 | AssemblyOnly 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | v143 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v143 31 | true 32 | Unicode 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Level3 50 | true 51 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | 54 | 55 | Console 56 | true 57 | main 58 | 59 | 60 | 61 | 62 | Level3 63 | true 64 | true 65 | true 66 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 67 | true 68 | 69 | 70 | Console 71 | true 72 | true 73 | true 74 | main 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Episode1/AssemblyOnly/AssemblyOnly.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Episode1/AssemblyOnly/main.asm: -------------------------------------------------------------------------------- 1 | includelib ucrt.lib 2 | includelib legacy_stdio_definitions.lib 3 | 4 | 5 | EXTERN printf: PROC 6 | 7 | 8 | 9 | .DATA 10 | fmtStr byte 'The sum is %d', 10, 0 11 | 12 | 13 | .CODE 14 | main PROC 15 | mov rcx, 3 16 | mov rdx, 2 17 | 18 | call Sum 19 | call Print 20 | 21 | xor rax, rax 22 | ret 23 | main ENDP 24 | 25 | 26 | Sum Proc 27 | mov rax, rcx 28 | add rax, rdx 29 | ret 30 | Sum ENDP 31 | 32 | 33 | Print PROC 34 | sub rsp, 20h 35 | lea rcx, fmtStr 36 | mov rdx, rax 37 | call printf 38 | add rsp, 20h 39 | ret 40 | Print ENDP 41 | 42 | 43 | END 44 | -------------------------------------------------------------------------------- /Episode10/Printf/Printf.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {b21a457e-3e5c-4e42-9afb-538781ad9f39} 17 | Printf 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | v143 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v143 31 | true 32 | Unicode 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Level3 50 | true 51 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | 54 | 55 | Console 56 | true 57 | main 58 | 59 | 60 | 61 | 62 | Level3 63 | true 64 | true 65 | true 66 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 67 | true 68 | 69 | 70 | Console 71 | true 72 | true 73 | true 74 | main 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Episode10/Printf/Printf.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Episode10/Printf/main.asm: -------------------------------------------------------------------------------- 1 | includelib ucrt.lib 2 | includelib legacy_stdio_definitions.lib 3 | 4 | EXTERN printf: PROC 5 | 6 | 7 | .DATA 8 | fmtStr1 DB "Hello World!", 10, 0 9 | fmtStr2 DB "%s are %d and %d", 10, 0 10 | fmtStr3 DB "%s are %d, %d, %d and %d", 10, 0 11 | string DB "The numbers", 0 12 | 13 | 14 | .CODE 15 | 16 | main PROC 17 | 18 | call printString1 19 | call printString2 20 | call printString3 21 | 22 | mov rax, 0 23 | ret 24 | main ENDP 25 | 26 | 27 | printString1 PROC 28 | sub rsp, 20h ; Allocate stack space for function parameters (32 bytes shadow space) 29 | 30 | lea rcx, fmtStr1 ; param 1: format string 31 | call printf 32 | 33 | add rsp, 20h ; Restore the stack 34 | ret 35 | printString1 ENDP 36 | 37 | 38 | printString2 PROC 39 | sub rsp, 20h ; Allocate stack space for function parameters (32 bytes shadow space) 40 | 41 | lea rcx, fmtStr2 ; param 1: format string 42 | lea rdx, string ; param 2: the string format specifier (%s in format string) 43 | mov r8, 5 ; param 3: the 1st integer specifier (1st %d in the format string) 44 | mov r9, 6 ; param 4: the 2nd integer specifier (2nd %d in the format string) 45 | call printf 46 | 47 | add rsp, 20h ; Restore the stack 48 | ret 49 | printString2 ENDP 50 | 51 | 52 | printString3 PROC 53 | 54 | push 4 ; stack param (in reverse order): the 4th integer specifier (4th %d in the format string) 55 | push 3 ; stack param (in reverse order): the 3rd integer specifier (3rd %d in the format string) 56 | 57 | sub rsp, 20h ; Allocate stack space for function parameters (32 bytes shadow space) 58 | 59 | lea rcx, fmtStr3 ; param 1: format string 60 | lea rdx, string ; param 2: the string format specifier (%s in format string) 61 | mov r8, 1 ; param 3: the 1st integer specifier (1st %d in the format string) 62 | mov r9, 2 ; param 4: the 2nd integer specifier (2nd %d in the format string) 63 | 64 | call printf 65 | 66 | add rsp, 30h ; Restore the stack 67 | ret 68 | printString3 ENDP 69 | 70 | 71 | END -------------------------------------------------------------------------------- /Episode11/Disassembly/Disassembly.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {e303115f-3605-4683-a43d-57d46d553f27} 25 | Disassembly 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | Level3 77 | true 78 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 79 | true 80 | 81 | 82 | Console 83 | true 84 | 85 | 86 | 87 | 88 | Level3 89 | true 90 | true 91 | true 92 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 93 | true 94 | 95 | 96 | Console 97 | true 98 | true 99 | true 100 | 101 | 102 | 103 | 104 | Level3 105 | true 106 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 107 | true 108 | 109 | 110 | Console 111 | true 112 | 113 | 114 | 115 | 116 | Level3 117 | true 118 | true 119 | true 120 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 121 | true 122 | 123 | 124 | Console 125 | true 126 | true 127 | true 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /Episode11/Disassembly/Disassembly.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Episode11/Disassembly/main.cpp: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | 3 | 4 | int main() 5 | { 6 | for (unsigned int num = 0; num < 3; num++) 7 | { 8 | printf("This is number %d\n", num); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Episode12/Scanf/Scanf.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {840f8d30-4c17-4596-890b-0cd8281307e4} 17 | Scanf 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | v143 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v143 31 | true 32 | Unicode 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Level3 50 | true 51 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | 54 | 55 | Console 56 | true 57 | main 58 | 59 | 60 | 61 | 62 | Level3 63 | true 64 | true 65 | true 66 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 67 | true 68 | 69 | 70 | Console 71 | true 72 | true 73 | true 74 | main 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Episode12/Scanf/Scanf.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Episode12/Scanf/main.asm: -------------------------------------------------------------------------------- 1 | includelib ucrt.lib 2 | includelib legacy_stdio_definitions.lib 3 | 4 | EXTERN scanf: PROC 5 | 6 | 7 | .DATA 8 | integerFmtString DB "%d", 0 ; Scanf input format string (%d reads an integer value) 9 | stringFmtString DB "%16s", 0 ; Scanf input format string (%s reads a string) 10 | integerValue DQ 0 ; Scanf output integer value is stored here 11 | stringValue DB 17 DUP(0) ; Scanf output buffer (duplicate 17 bytes of value 0) 12 | 13 | 14 | .CODE 15 | 16 | main PROC 17 | 18 | call scanfInteger 19 | call scanfString 20 | 21 | mov rax, 0 22 | ret 23 | main ENDP 24 | 25 | 26 | scanfInteger PROC 27 | sub rsp, 20h ; Allocate stack space for function arguments 28 | 29 | lea rcx, integerFmtString 30 | lea rdx, integerValue 31 | call scanf 32 | 33 | add rsp, 20h ; Restore the stack 34 | ret 35 | scanfInteger ENDP 36 | 37 | 38 | scanfString PROC 39 | sub rsp, 20h ; Allocate stack space for function arguments 40 | 41 | lea rcx, stringFmtString 42 | lea rdx, stringValue 43 | call scanf 44 | 45 | add rsp, 20h ; Restore the stack 46 | ret 47 | scanfString ENDP 48 | 49 | 50 | END -------------------------------------------------------------------------------- /Episode13/BitwiseLogicalInstructions/BitwiseLogicalInstructions.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {4f3265e2-67c5-4967-b8fa-1571762a8294} 17 | BitwiseLogicalInstructions 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | v143 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v143 31 | true 32 | Unicode 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Level3 50 | true 51 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | 54 | 55 | Console 56 | true 57 | main 58 | 59 | 60 | 61 | 62 | Level3 63 | true 64 | true 65 | true 66 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 67 | true 68 | 69 | 70 | Console 71 | true 72 | true 73 | true 74 | main 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Episode13/BitwiseLogicalInstructions/BitwiseLogicalInstructions.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Episode13/BitwiseLogicalInstructions/main.asm: -------------------------------------------------------------------------------- 1 | 2 | .CODE 3 | main PROC 4 | 5 | 6 | ; Bitwise AND & 7 | mov rcx, 0FFFFh ; CX = 1111 1111 1111 1111 8 | mov rdx, 5757h ; DX = 0101 0111 0101 0111 9 | and cx, dx ; CX = 0101 0111 0101 0111 10 | and cx, 3333h ; 0011 0011 0011 0011 (3333h) 11 | ; CX = 0001 0011 0001 0011 (1313h) 12 | 13 | ; Bitwise OR | 14 | mov rcx, 4444h ; CX = 0100 0100 0100 0100 15 | mov rdx, 6767h ; DX = 0110 0111 0110 0111 16 | or cx, dx ; CX = 0110 0111 0110 0111 17 | or cx, 9999h ; 1001 1001 1001 1001 (9999h) 18 | ; CX = 1111 1111 1111 1111 (FFFFh) 19 | 20 | ; Bitwise XOR ^ 21 | mov rcx, 7777h ; CX = 0111 0111 0111 0111 22 | mov rdx, 5555h ; DX = 0101 0101 0101 0101 23 | xor cx, dx ; CX = 0010 0010 0010 0010 24 | xor cx, 9999h ; 1001 1001 1001 1001 (9999h) 25 | ; CX = 1011 1011 1011 1011 (BBBBh) 26 | 27 | ; Bitwise NOT ~ 28 | mov rcx, 7352h ; CX = 0111 0011 1001 0010 29 | not cx ; CX = 1000 1100 0110 1101 (8CADh) 30 | 31 | 32 | ; Using memory operands 33 | mov rax, 1111111111111111b 34 | and rax, QWORD PTR [dataA] 35 | and QWORD PTR [dataB], rax 36 | not QWORD PTR [dataB] 37 | 38 | 39 | xor rax, rax ; clear rax 40 | ret 41 | main ENDP 42 | 43 | 44 | .DATA 45 | dataA QWORD 7777777777777777h 46 | dataB QWORD 9999999999999999h 47 | 48 | 49 | END 50 | -------------------------------------------------------------------------------- /Episode14/NumberGuessingGame/NumberGuessingGame.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {b3e230c9-a303-4c68-8691-8ab0822925c3} 17 | NumberGuessingGame 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | v143 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v143 31 | true 32 | Unicode 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Level3 50 | true 51 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | 54 | 55 | Console 56 | true 57 | main 58 | 59 | 60 | 61 | 62 | Level3 63 | true 64 | true 65 | true 66 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 67 | true 68 | 69 | 70 | Console 71 | true 72 | true 73 | true 74 | main 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Episode14/NumberGuessingGame/NumberGuessingGame.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Episode14/NumberGuessingGame/main.asm: -------------------------------------------------------------------------------- 1 | includelib ucrt.lib 2 | includelib legacy_stdio_definitions.lib 3 | 4 | EXTERN printf: PROC 5 | EXTERN scanf: PROC 6 | EXTERN srand: PROC 7 | EXTERN rand: PROC 8 | 9 | 10 | .DATA 11 | StrAskNumber DB "Guess the number (between 0 and %d): ", 0 12 | StrGreaterThan DB "Nope, try a higher number!", 10, 0 13 | StrLessThan DB "Nope, try a lower number!", 10, 0 14 | StrCorrect DB "You guessed the number!", 10, 0 15 | ScanfFmtString DB "%d", 0 ; Scanf input format string (%d reads an integer value) 16 | ScanfOutput DQ 0 ; Scanf output integer value is stored here 17 | MaxNumber DQ 15 ; The number to guess is between 0 and MaxNumber 18 | ; Make sure MaxNumber is: (a power of 2) - 1 (7, 15, 31, etc) 19 | RandomNumber DQ 0 ; The number to be guessed 20 | 21 | 22 | .CODE 23 | 24 | main PROC 25 | 26 | call getRandomNumber 27 | 28 | startAskNumber: 29 | lea rcx, StrAskNumber 30 | mov rdx, [MaxNumber] 31 | call print 32 | call scanfInteger 33 | cmp eax, 1 ; Expect 1 integer to be succesfully read by scanf 34 | jne exit ; If not, simply exit program. Alternative is to flush the buffer that contains 35 | ; illegal characters at this point and then jump back to startAskNumber 36 | 37 | ; Make sure the user input is in the valid range 0 to MaxNumber 38 | ; No need to check to negative values here, the values are unsigned so negative input values are seen 39 | ; as high positive values 40 | mov rax, [MaxNumber] 41 | cmp rax, [ScanfOutput] 42 | jl startAskNumber 43 | 44 | ; Compare the user input to the number to be guessed 45 | mov rax, [RandomNumber] 46 | cmp rax, [ScanfOutput] 47 | jg greaterThan 48 | jl lessThan 49 | je equal 50 | greaterThan: 51 | lea rcx, StrGreaterThan ; Number to be guessed is greater than user input 52 | call print 53 | jmp startAskNumber 54 | lessThan: 55 | lea rcx, StrLessThan ; Number to be guessed is less than user input 56 | call print 57 | jmp startAskNumber 58 | equal: 59 | lea rcx, StrCorrect ; Number was guessed, print message and exit program 60 | call print 61 | exit: 62 | mov rax, 0 63 | ret 64 | main ENDP 65 | 66 | 67 | scanfInteger PROC 68 | sub rsp, 20h ; Allocate stack space for function arguments 69 | lea rcx, ScanfFmtString 70 | lea rdx, ScanfOutput 71 | call scanf 72 | add rsp, 20h ; Restore the stack 73 | ret 74 | scanfInteger ENDP 75 | 76 | 77 | print PROC 78 | sub rsp, 20h ; Allocate stack space for function arguments 79 | call printf 80 | add rsp, 20h ; Restore the stack 81 | ret 82 | print ENDP 83 | 84 | 85 | getRandomNumber PROC 86 | sub rsp, 20h ; Allocate stack space for function arguments 87 | mov rcx, rsp ; use rsp register as random seed 88 | call srand 89 | call rand ; random number will be stored in rax 90 | and rax, QWORD PTR [MaxNumber] 91 | mov RandomNumber, rax 92 | add rsp, 20h ; Restore the stack 93 | ret 94 | getRandomNumber ENDP 95 | 96 | 97 | END 98 | -------------------------------------------------------------------------------- /Episode15/CreateWindow/CreateWindow.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {a5dd5ff2-d454-456e-b80a-7e77eafb4433} 17 | CreateWindow 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | v143 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v143 31 | true 32 | Unicode 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Level3 50 | true 51 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | 54 | 55 | Windows 56 | true 57 | main 58 | 59 | 60 | 61 | 62 | Level3 63 | true 64 | true 65 | true 66 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 67 | true 68 | 69 | 70 | Windows 71 | true 72 | true 73 | true 74 | main 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /Episode15/CreateWindow/CreateWindow.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Episode15/CreateWindow/main.asm: -------------------------------------------------------------------------------- 1 | includelib user32.lib 2 | 3 | extern GetModuleHandleW:PROC 4 | extern LoadCursorW:PROC 5 | extern LoadIconW:PROC 6 | extern RegisterClassExW:PROC 7 | extern CreateWindowExW:PROC 8 | extern ShowWindow:PROC 9 | extern UpdateWindow:PROC 10 | extern DefWindowProcW:PROC 11 | extern PostQuitMessage:PROC 12 | extern GetMessageW:PROC 13 | extern TranslateMessage:PROC 14 | extern DispatchMessageW:PROC 15 | 16 | 17 | include windows.inc 18 | 19 | 20 | .DATA 21 | className DW 'M','y',' ','C','l','a','s','s', 0 22 | windowName DW 'M','y',' ','W','i','n','d','o','w', 0 23 | hInstance QWORD 0 24 | hWndClass QWORD 0 25 | hWindow QWORD 0 26 | message MSG<> 27 | wc WNDCLASSEXW<> 28 | 29 | 30 | ; window size 31 | windowWidth equ 1024 32 | windowHeight equ 768 33 | 34 | 35 | .CODE 36 | main PROC 37 | 38 | call RegisterWindowClass 39 | cmp rax, 0 40 | je exit 41 | 42 | call CreateWindow 43 | cmp rax, 0 44 | je exit 45 | 46 | call ShowAndUpdateWindow 47 | 48 | sub rsp, 28h 49 | messageLoop: 50 | 51 | ; retrieve a message (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmessage) 52 | lea rcx, message 53 | mov rdx, 0 54 | mov r8, 0 55 | mov r9, 0 56 | call GetMessageW 57 | cmp eax, 0 58 | je exit 59 | 60 | ; translate the message (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-translatemessage) 61 | lea rcx, message 62 | call TranslateMessage 63 | 64 | ; dispatch message (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-dispatchmessage) 65 | lea rcx, message 66 | call DispatchMessageW 67 | 68 | jmp messageLoop 69 | 70 | exit: 71 | add rsp, 28h 72 | xor rax, rax 73 | ret 74 | main ENDP 75 | 76 | 77 | RegisterWindowClass PROC 78 | sub rsp, 20h 79 | 80 | ; Get ModuleHandle (https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulehandlew) 81 | mov rcx, 0 82 | call GetModuleHandleW 83 | mov hInstance, rax 84 | 85 | ; Load cursor (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadcursorw) 86 | xor ecx, ecx ; set hInstance to 0 87 | mov edx, IDC_ARROW ; to allow passing of predefined system cursor to load here 88 | call LoadCursorW 89 | mov wc.hCursor, rax 90 | 91 | ; Load icon (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadiconw) 92 | xor ecx, ecx ; set hInstance to 0 93 | mov edx, IDI_SHIELD ; to allow passing of predefined system cursor to load here 94 | call LoadIconW 95 | mov wc.hIconSm, rax 96 | mov wc.hIcon, rax 97 | 98 | ; Register the windows class (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registerclassexw) 99 | mov wc.cbSize, sizeof WNDCLASSEXW 100 | mov wc.style, CS_HREDRAW or CS_VREDRAW 101 | lea rax, WinProc 102 | mov wc.lpfnWndProc, rax 103 | mov wc.cbClsExtra, 0 104 | mov wc.cbWndExtra, 0 105 | mov rax, [hInstance] 106 | mov wc.hInstance, rax 107 | mov wc.hbrBackground, COLOR_HOTLIGHT + 1 108 | mov wc.lpszMenuName, 0 109 | lea rax, className 110 | mov wc.lpszClassName, rax 111 | lea rcx, wc 112 | call RegisterClassExW 113 | mov hWndClass, rax 114 | 115 | add rsp, 20h 116 | ret 117 | RegisterWindowClass ENDP 118 | 119 | 120 | 121 | CreateWindow PROC 122 | 123 | ; Create the window (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-createwindowexa) 124 | push 0 125 | push hInstance 126 | push 0 127 | push 0 128 | push windowHeight 129 | push windowWidth 130 | push CW_USEDEFAULT 131 | push CW_USEDEFAULT 132 | 133 | sub rsp, 20h 134 | xor ecx, ecx 135 | lea rdx, className 136 | lea r8, windowName 137 | mov r9d, WS_OVERLAPPEDWINDOW 138 | call CreateWindowExW 139 | cmp rax, 0 140 | je exit 141 | mov hWindow, rax 142 | 143 | exit: 144 | add rsp, 60h 145 | ret 146 | CreateWindow ENDP 147 | 148 | 149 | ShowAndUpdateWindow PROC 150 | sub rsp, 20h 151 | 152 | ; Show the window (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow) 153 | mov rcx, [hWindow] 154 | mov rdx, SW_SHOWDEFAULT 155 | call ShowWindow 156 | 157 | ; Update the window (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-updatewindow) 158 | mov rcx, [hWindow] 159 | call UpdateWindow 160 | 161 | add rsp, 20h 162 | ShowAndUpdateWindow ENDP 163 | 164 | 165 | ; Window procedure 166 | WinProc PROC hWin:QWORD, uMsg:DWORD, wParam:QWORD, lParam:QWORD 167 | 168 | ; hWin in RCX 169 | ; uMsg in EDX 170 | ; wParam in R8 171 | ; lParam in R9 172 | 173 | ; Check the message uMsg (is in edx) 174 | cmp edx, WM_CREATE 175 | je handleCreateMsg 176 | cmp edx, WM_PAINT 177 | je handlePaintMsg 178 | cmp edx, WM_DESTROY 179 | je handleDestroyMsg 180 | cmp edx, WM_SIZE 181 | je handleResizeMsg 182 | 183 | ; default handler (called with input params hWin,uMsg,wParam and lParam still in registers rcx,edx,r8 and r9) 184 | sub rsp, 20h 185 | call DefWindowProcW ; (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-defwindowprocw) 186 | add rsp, 20h 187 | ret 188 | 189 | handleCreateMsg: 190 | xor rax, rax 191 | ret 192 | 193 | handlePaintMsg: 194 | xor rax, rax 195 | ret 196 | 197 | handleDestroyMsg: ;(https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-postquitmessage) 198 | sub rsp, 20h 199 | mov rcx, 0 ; exit with exitcode 0 200 | call PostQuitMessage 201 | add rsp, 20h 202 | xor rax, rax 203 | ret 204 | 205 | handleResizeMsg: 206 | xor rax, rax 207 | ret 208 | 209 | WinProc ENDP 210 | 211 | 212 | END 213 | -------------------------------------------------------------------------------- /Episode15/CreateWindow/windows.inc: -------------------------------------------------------------------------------- 1 | ; windows.inc - Custom include file 2 | 3 | 4 | ; Some icons (https://learn.microsoft.com/en-us/windows/win32/menurc/about-icons): 5 | IDI_APPLICATION equ 32512 6 | IDI_HAND equ 32513 7 | IDI_QUESTION equ 32514 8 | IDI_EXCLAMATION equ 32515 9 | IDI_ASTERISK equ 32516 10 | IDI_WINLOGO equ 32517 11 | IDI_SHIELD equ 32518 12 | 13 | 14 | ; Some cursors (https://learn.microsoft.com/en-us/windows/win32/menurc/about-cursors): 15 | IDC_ARROW equ 32512 16 | IDC_CROSS equ 32515 17 | IDC_WAIT equ 32514 18 | 19 | 20 | ; Windows API Constants 21 | CW_USEDEFAULT equ 80000000h 22 | 23 | 24 | ; Window messages 25 | WM_CREATE equ 1 26 | WM_DESTROY equ 2 27 | WM_SIZE equ 5 28 | WM_PAINT equ 15 29 | 30 | 31 | ; Window Styles (https://learn.microsoft.com/en-us/windows/win32/winmsg/window-styles) 32 | WS_OVERLAPPEDWINDOW equ 0CF0000h 33 | 34 | 35 | ; Class Styles (https://learn.microsoft.com/en-us/windows/win32/winmsg/window-class-styles) 36 | CS_HREDRAW equ 2 37 | CS_VREDRAW equ 1 38 | 39 | 40 | ; ShowWindow parameters (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow) 41 | SW_SHOWDEFAULT equ 10 42 | 43 | 44 | ; Colors (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsyscolor) 45 | COLOR_WINDOW equ 5 46 | COLOR_HOTLIGHT equ 26 47 | 48 | 49 | 50 | ; 51 | ; Windows API Structures 52 | ; 53 | 54 | WNDCLASSEXW STRUCT ; (https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-wndclassexw) 55 | cbSize DWORD ? 56 | style DWORD ? 57 | lpfnWndProc QWORD ? 58 | cbClsExtra DWORD ? 59 | cbWndExtra DWORD ? 60 | hInstance QWORD ? 61 | hIcon QWORD ? 62 | hCursor QWORD ? 63 | hbrBackground QWORD ? 64 | lpszMenuName QWORD ? 65 | lpszClassName QWORD ? 66 | hIconSm QWORD ? 67 | WNDCLASSEXW ENDS 68 | 69 | 70 | POINT STRUCT ; (https://learn.microsoft.com/en-us/windows/win32/api/windef/ns-windef-point) 71 | x QWORD ? 72 | y QWORD ? 73 | POINT ENDS 74 | 75 | 76 | MSG STRUCT ; (https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-msg) 77 | hwnd QWORD ? 78 | message DWORD ? 79 | wParam QWORD ? 80 | lParam QWORD ? 81 | time DWORD ? 82 | pt POINT <> 83 | lPrivate DWORD ? 84 | MSG ENDS 85 | -------------------------------------------------------------------------------- /Episode16/16_BasicFloatingPointsSSE/16_BasicFloatingPointsSSE.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {d95a104f-5a90-4a76-9518-e28a13062be7} 17 | _16_BasicFloatingPointsSSE 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | v143 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v143 31 | true 32 | Unicode 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Level3 50 | true 51 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | 54 | 55 | Console 56 | true 57 | main 58 | 59 | 60 | 61 | 62 | Level3 63 | true 64 | true 65 | true 66 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 67 | true 68 | 69 | 70 | Console 71 | true 72 | true 73 | true 74 | main 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Episode16/16_BasicFloatingPointsSSE/16_BasicFloatingPointsSSE.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Episode16/16_BasicFloatingPointsSSE/main.asm: -------------------------------------------------------------------------------- 1 | 2 | .DATA 3 | 4 | ; single data 5 | floatA REAL4 1.1 ; float is a 32 bit floating point 6 | floatB REAL4 2.2 7 | floatRes REAL4 0.0 8 | doubleA REAL8 3.0 ; double is a 64 bit floating point 9 | doubleB REAL8 0.9 10 | doubleRes REAL8 0.0 11 | 12 | 13 | ALIGN 16 ; the vectors must be on 16 byte aligned memory addresses 14 | 15 | ; vector of 4 fp32 elements (SSE register is 128 bits wide, so can store 4 elements of 32 bits) 16 | floatVectorA REAL4 1.1, 2.2, 3.3, 4.4 17 | floatVectorB REAL4 4.0, 3.0, 2.0, 1.0 18 | floatVectorRes REAL4 0.0, 0.0, 0.0, 0.0 19 | 20 | ; vector of 2 fp64 elements (SSE register is 128 bits wide, so can store 2 elements of 64 bits) 21 | doubleVectorA REAL8 2.0, 3.5 22 | doubleVectorB REAL8 1.0, 2.0 23 | doubleVectorRes REAL8 0.0, 0.0 24 | 25 | 26 | .CODE 27 | 28 | main PROC 29 | 30 | ; SISD: 31 | 32 | ; subtraction of fp32 (single precision) 33 | movss xmm0, DWORD PTR [floatB] ; Load fp32 value into xmm0 (value 2.2) 34 | movss xmm1, DWORD PTR [floatA] ; Load fp32 value into xmm1 (value 1.1) 35 | subss xmm0, xmm1 ; Subtract xmm1 from xmm0 36 | movss DWORD PTR [floatRes], xmm0 ; Store the result 37 | 38 | ; division of fp64 (double precision) 39 | movsd xmm0, QWORD PTR [doubleA] ; Load fp64 value into xmm0 (value 3.0) 40 | movsd xmm1, QWORD PTR [doubleB] ; Load fp64 value into xmm1 (value 0.9) 41 | divsd xmm0, xmm1 ; Divide xmm0 by xmm1 42 | movsd QWORD PTR [doubleRes], xmm0 ; Store the result 43 | 44 | 45 | ; SIMD: 46 | 47 | ; addition of two vectors of 4 fp32 elements 48 | movaps xmm0, XMMWORD PTR [floatVectorA] ; Load the first vector into xmm0 (1.1, 2.2, 3.3, 4.4) 49 | movaps xmm1, XMMWORD PTR [floatVectorB] ; Load the second vector into xmm1 (4.0, 3.0, 2.0, 1.0) 50 | addps xmm0, xmm1 ; Add xmm1 to xmm0 (vector of 4 fp32 elements) 51 | movaps XMMWORD PTR [floatVectorRes], xmm0 ; Store the result 52 | 53 | ; multiplication of two vectors of 2 fp64 elements 54 | movapd xmm0, XMMWORD PTR [doubleVectorA] ; Load the first vector into xmm0 (2.0, 3.5) 55 | movapd xmm1, XMMWORD PTR [doubleVectorB] ; Load the second vector into xmm1 (1.0, 2.0) 56 | mulpd xmm0, xmm1 ; Multiply xmm0 with xmm1 (vector of 2 doubles) 57 | movapd XMMWORD PTR [doubleVectorRes], xmm0 ; Store the result 58 | 59 | 60 | mov eax, 0 61 | ret 62 | main ENDP 63 | 64 | 65 | END 66 | -------------------------------------------------------------------------------- /Episode2/Registers+MOV/Registers+MOV.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {a1259a23-9513-4bc9-955c-8460c98a84af} 17 | Registers_MOV 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | v143 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v143 31 | true 32 | Unicode 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Level3 50 | true 51 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | 54 | 55 | Console 56 | true 57 | 58 | 59 | 60 | 61 | Level3 62 | true 63 | true 64 | true 65 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 66 | true 67 | 68 | 69 | Console 70 | true 71 | true 72 | true 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Episode2/Registers+MOV/Registers+MOV.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Episode2/Registers+MOV/main.cpp: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | 3 | 4 | extern "C" void Example(); 5 | 6 | 7 | 8 | int main() 9 | { 10 | Example(); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /Episode2/Registers+MOV/registers+MOV.asm: -------------------------------------------------------------------------------- 1 | .CODE 2 | 3 | 4 | ; <------ 5 | ; mov , 6 | ; 7 | ; mov , 8 | ; mov , 9 | ; mov , 10 | ; mov , 11 | 12 | 13 | 14 | Example PROC 15 | 16 | mov r8, 0 ; clear 17 | mov r8b, 11h ; move 8 bits 18 | mov r8w, 2222h ; move 16 bits 19 | mov r8d, 33333333h ; move 32 bits 20 | mov r8, 4444444444444444h ; move 64 bits 21 | mov rax, r8 ; move from register to register 22 | 23 | mov rax, 0 ; clear 24 | mov al, 11h ; move into lower 8 bits of 16 bit register 25 | mov ah, 22h ; move into higher 8 bits of 16 bit register 26 | mov ax, 3333h ; move 16 bits 27 | mov eax, 44444444h ; move 32 bits 28 | mov rax, 5555555555555555h ; move 64 bits 29 | 30 | mov r8, 0FFFFFFFFFFFFFFFFh ; initialize 31 | mov r8b, 11h ; move 8 bits 32 | mov r8w, 2222h ; move 16 bits 33 | mov r8d, 33333333h ; !!! storing in the lower 32 bits will clear the top 32 bits !!! 34 | 35 | ret 36 | Example ENDP 37 | 38 | 39 | END 40 | -------------------------------------------------------------------------------- /Episode3/Directives/Directives.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {58e5588c-dc09-4951-b8b0-3ef2babd38f4} 17 | Directives 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | v143 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v143 31 | true 32 | Unicode 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Level3 50 | true 51 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | 54 | 55 | Console 56 | true 57 | main 58 | 59 | 60 | 61 | 62 | Level3 63 | true 64 | true 65 | true 66 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 67 | true 68 | 69 | 70 | Console 71 | true 72 | true 73 | true 74 | main 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Episode3/Directives/Directives.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Episode3/Directives/main.asm: -------------------------------------------------------------------------------- 1 | ;INCLUDELIB ucrt.lib 2 | ;INCLUDELIB legacy_stdio_definitions.lib 3 | 4 | 5 | ;EXTERN printf: PROC 6 | 7 | 8 | 9 | .DATA 10 | MyData DWORD 42 11 | 12 | 13 | .CODE 14 | main PROC 15 | 16 | call SomeProc 17 | 18 | mov eax, 0 19 | ret 20 | main ENDP 21 | 22 | 23 | SomeProc PROC 24 | mov eax, MyData 25 | ret 26 | SomeProc ENDP 27 | 28 | 29 | END 30 | -------------------------------------------------------------------------------- /Episode4/Add_Sub_Inc_Dec/Add_Sub_Inc_Dec.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {49e26c62-f111-4c69-ac6a-784b219b9ade} 17 | Add_Sub_Inc_Dec 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | v143 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v143 31 | true 32 | Unicode 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Level3 50 | true 51 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | 54 | 55 | Console 56 | true 57 | main 58 | 59 | 60 | 61 | 62 | Level3 63 | true 64 | true 65 | true 66 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 67 | true 68 | 69 | 70 | Console 71 | true 72 | true 73 | true 74 | main 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Episode4/Add_Sub_Inc_Dec/Add_Sub_Inc_Dec.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Episode4/Add_Sub_Inc_Dec/main.asm: -------------------------------------------------------------------------------- 1 | 2 | .DATA 3 | MyData QWORD 42 4 | 5 | 6 | .CODE 7 | main PROC 8 | 9 | mov rax, 0 10 | 11 | ; add/sub , 12 | 13 | add rax, 5 14 | add rax, 2 15 | sub rax, 3 16 | sub rax, 4 17 | 18 | ; add/sub , 19 | 20 | mov rax, 5 21 | mov rbx, 2 22 | add rax, rbx 23 | sub rax, rbx 24 | 25 | ; add , 26 | ; add , 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 53 | ; dec 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 73 | -------------------------------------------------------------------------------- /Episode5/Flags/Flags.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {03695492-74ff-4903-be0b-6b46cfaba571} 17 | Flags 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | v143 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v143 31 | true 32 | Unicode 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Level3 50 | true 51 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | 54 | 55 | Console 56 | true 57 | main 58 | 59 | 60 | 61 | 62 | Level3 63 | true 64 | true 65 | true 66 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 67 | true 68 | 69 | 70 | Console 71 | true 72 | true 73 | true 74 | main 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Episode5/Flags/Flags.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Episode5/Flags/main.asm: -------------------------------------------------------------------------------- 1 | 2 | .CODE 3 | main PROC 4 | 5 | mov rax, 0 6 | 7 | ; Carry flag 8 | 9 | mov al, 255 10 | add al, 1 ; overflow, carry flag set 11 | 12 | mov al, 20 13 | add al, 1 ; carry flag not set 14 | 15 | stc ; set carry flag 16 | clc ; clear carry flag 17 | 18 | 19 | ; Zero flag 20 | 21 | mov rax, 1 22 | dec rax ; zero flag set 23 | 24 | mov rax, 5 25 | dec rax ; zero flag not set 26 | 27 | 28 | ; Sign flag 29 | 30 | mov rax, 2 31 | sub rax, 3 ; sign flag set 32 | 33 | mov rax, 5 34 | sub rax, 3 ; sign flag not set 35 | 36 | 37 | ; Overflow flag 38 | 39 | mov al, 127 40 | add al, 1 ; overflow flag set 41 | 42 | mov al, -127 43 | sub al, 1 ; overflow flag cleared 44 | sub al, 1 ; overflow flag set 45 | 46 | 47 | mov rax, 0 48 | ret 49 | main ENDP 50 | 51 | 52 | END 53 | -------------------------------------------------------------------------------- /Episode6/ConditionalJumps/ConditionalJumps.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {4dd40142-837d-4461-ba3f-0a805a2a057a} 17 | ConditionalJumps 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | v143 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v143 31 | true 32 | Unicode 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Level3 50 | true 51 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | 54 | 55 | Console 56 | true 57 | main 58 | 59 | 60 | 61 | 62 | Level3 63 | true 64 | true 65 | true 66 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 67 | true 68 | 69 | 70 | Console 71 | true 72 | true 73 | true 74 | main 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Episode6/ConditionalJumps/ConditionalJumps.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Episode6/ConditionalJumps/main.asm: -------------------------------------------------------------------------------- 1 | .CODE 2 | 3 | main PROC 4 | mov eax, 0 5 | 6 | ; Carry flag conditional jumps 7 | 8 | call CarryFlagSet 9 | call CarryFlagNotSet 10 | 11 | ; Zero flag conditional jumps 12 | 13 | call ZeroFlagSet 14 | call ZeroFlagNotSet 15 | 16 | ; Sign flag conditional jumps 17 | 18 | call SignFlagSet 19 | call SignFlagNotSet 20 | 21 | ; Overflow flag conditional jumps 22 | 23 | call OverflowFlagSet 24 | call OverflowFlagNotSet 25 | 26 | ; unconditional jump 27 | 28 | call UnconditionalJump 29 | 30 | mov eax, 0 31 | ret 32 | main ENDP 33 | 34 | 35 | CarryFlagSet PROC 36 | mov al, 255 37 | add al, 1 38 | jc Carry1 39 | jnc NoCarry1 40 | Carry1: 41 | ret 42 | NoCarry1: 43 | ret 44 | CarryFlagSet ENDP 45 | 46 | 47 | CarryFlagNotSet PROC 48 | mov al, 200 49 | add al, 1 50 | jc Carry2 51 | jnc NoCarry2 52 | Carry2: 53 | ret 54 | NoCarry2: 55 | ret 56 | CarryFlagNotSet ENDP 57 | 58 | 59 | ZeroFlagSet PROC 60 | mov rax, 1 61 | dec rax 62 | jz Zero1 63 | jnz NoZero1 64 | Zero1: 65 | ret 66 | NoZero1: 67 | ret 68 | ZeroFlagSet ENDP 69 | 70 | 71 | ZeroFlagNotSet PROC 72 | mov rax, 5 73 | dec rax 74 | jz Zero2 75 | jnz NoZero2 76 | Zero2: 77 | ret 78 | NoZero2: 79 | ret 80 | ZeroFlagNotSet ENDP 81 | 82 | 83 | SignFlagSet PROC 84 | mov rax, 1 85 | sub rax, 3 86 | js Sign1 87 | jns NoSign1 88 | Sign1: 89 | ret 90 | NoSign1: 91 | ret 92 | SignFlagSet ENDP 93 | 94 | 95 | SignFlagNotSet PROC 96 | mov rax, 6 97 | sub rax, 3 98 | js Sign2 99 | jns NoSign2 100 | Sign2: 101 | ret 102 | NoSign2: 103 | ret 104 | SignFlagNotSet ENDP 105 | 106 | 107 | OverflowFlagSet PROC 108 | mov al, 127 109 | add al, 1 110 | jo Overflow1 111 | jno NoOverflow1 112 | Overflow1: 113 | ret 114 | NoOverflow1: 115 | ret 116 | OverflowFlagSet ENDP 117 | 118 | 119 | OverflowFlagNotSet PROC 120 | mov al, 120 121 | add al, 1 122 | jo Overflow2 123 | jno NoOverflow2 124 | Overflow2: 125 | ret 126 | NoOverflow2: 127 | ret 128 | OverflowFlagNotSet ENDP 129 | 130 | 131 | UnconditionalJump PROC 132 | mov rax, 3 133 | decrement: 134 | dec rax 135 | jz exit 136 | jmp decrement 137 | ; jnz decrement ; this would better (instead of jz + jmp) 138 | exit: 139 | ret 140 | UnconditionalJump ENDP 141 | 142 | 143 | END 144 | -------------------------------------------------------------------------------- /Episode7/CmpInstruction/CmpInstruction.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {b1ed6ea7-dd8f-4f43-b429-4eb53f83041e} 17 | CmpInstruction 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | v143 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v143 31 | true 32 | Unicode 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Level3 50 | true 51 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | 54 | 55 | Console 56 | true 57 | main 58 | 59 | 60 | 61 | 62 | Level3 63 | true 64 | true 65 | true 66 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 67 | true 68 | 69 | 70 | Console 71 | true 72 | true 73 | true 74 | main 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Episode7/CmpInstruction/CmpInstruction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Episode7/CmpInstruction/main.asm: -------------------------------------------------------------------------------- 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 123 | -------------------------------------------------------------------------------- /Episode8/DebuggingAssemblyCode/DebuggingAssemblyCode.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {99ac3a86-a531-4d77-92f9-461b12dc9b9c} 17 | DebuggingAssemblyCode 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | v143 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v143 31 | true 32 | Unicode 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Level3 50 | true 51 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | 54 | 55 | Console 56 | true 57 | main 58 | 59 | 60 | 61 | 62 | Level3 63 | true 64 | true 65 | true 66 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 67 | true 68 | 69 | 70 | Console 71 | true 72 | true 73 | true 74 | main 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Episode8/DebuggingAssemblyCode/DebuggingAssemblyCode.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Episode8/DebuggingAssemblyCode/main.asm: -------------------------------------------------------------------------------- 1 | 2 | .DATA 3 | string BYTE "This is a string.", 10, 0 4 | data QWORD 7 5 | 6 | 7 | .CODE 8 | main PROC 9 | 10 | call Proc1 11 | call Proc2 12 | 13 | mov rax, 0 14 | ret 15 | main ENDP 16 | 17 | 18 | Proc1 PROC 19 | mov rax, 6 20 | ret 21 | Proc1 ENDP 22 | 23 | 24 | Proc2 PROC 25 | mov rax, 7 26 | ret 27 | Proc2 ENDP 28 | 29 | 30 | END 31 | -------------------------------------------------------------------------------- /Episode9/Stack/Stack.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {9d66960b-9a65-4ebc-a634-54069b572d11} 17 | Stack 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | v143 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v143 31 | true 32 | Unicode 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Level3 50 | true 51 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | 54 | 55 | Console 56 | true 57 | main 58 | 59 | 60 | 61 | 62 | Level3 63 | true 64 | true 65 | true 66 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 67 | true 68 | 69 | 70 | Console 71 | true 72 | true 73 | true 74 | main 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Episode9/Stack/Stack.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Episode9/Stack/main.asm: -------------------------------------------------------------------------------- 1 | 2 | .CODE 3 | main PROC 4 | 5 | mov rcx, 4444444444444444h 6 | mov rdx, 5555555555555555h 7 | 8 | ; push register values 9 | push rcx 10 | push rdx 11 | pop rcx ; last-in-first-out (LIFO) -> this swaps the data in rcx and rdx!! 12 | pop rdx 13 | 14 | 15 | ; push immediate values (But no 64 bit values allowed! You can first move those into a register) 16 | push 33333333h 17 | push 22222222h 18 | pop rcx 19 | pop rdx 20 | 21 | 22 | ; Can push 16/64 bit registers only (pushing 32bit registers is not supported) 23 | mov cx, 7777h 24 | mov rdx, 8888888888888888h 25 | push cx 26 | push rdx 27 | pop rdx 28 | pop cx 29 | 30 | call myProc 31 | 32 | call myPrint 33 | 34 | mov rax, 0 35 | ret 36 | main ENDP 37 | 38 | 39 | myProc PROC 40 | ret 41 | myProc ENDP 42 | 43 | 44 | myPrint PROC 45 | 46 | sub rsp, 20h ; 16-byte align the stack pointer, and reserve stack space for parameters 47 | ; 32 bytes (shadow space) 48 | 49 | ; lea rcx, fmtStr ; printf argument 1 50 | ; mov rdx, rax ; printf argument 2 51 | ; call printf 52 | 53 | add rsp, 20h ; restore stack pointer 54 | 55 | ret 56 | myPrint ENDP 57 | 58 | 59 | END 60 | --------------------------------------------------------------------------------