diff --git a/.gitignore b/.gitignore
index 31c4c57..65a9050 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,10 @@
.vs
.git
x64/
+Debug/
+Release/
build/
+*.obj
*.a
*.o
*.exe
diff --git a/msvc/interpreter.vcxproj b/msvc/interpreter.vcxproj
new file mode 100644
index 0000000..c66cfa2
--- /dev/null
+++ b/msvc/interpreter.vcxproj
@@ -0,0 +1,162 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 16.0
+ Win32Proj
+ {6045f9d7-3a5e-406a-9949-7abbb3bcbecc}
+ interpreter
+ 10.0
+
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ $(SolutionDir)$(Configuration);$(LibraryPath)
+
+
+ false
+ $(SolutionDir)$(Configuration);$(LibraryPath)
+
+
+ true
+ $(SolutionDir)$(Platform)\$(Configuration);$(LibraryPath)
+
+
+ false
+ $(SolutionDir)$(Platform)\$(Configuration);$(LibraryPath)
+
+
+
+ Level3
+ true
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ stdc17
+
+
+ Console
+ true
+ pasm.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ true
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ stdc17
+
+
+ Console
+ true
+ true
+ true
+ pasm.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ true
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ stdc17
+
+
+ Console
+ true
+ pasm.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ stdc17
+
+
+ Console
+ true
+ true
+ true
+ pasm.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/msvc/interpreter.vcxproj.filters b/msvc/interpreter.vcxproj.filters
new file mode 100644
index 0000000..b2279f4
--- /dev/null
+++ b/msvc/interpreter.vcxproj.filters
@@ -0,0 +1,21 @@
+
+
+
+
+ {0f80f205-555c-4eb0-a71b-b969588b3645}
+
+
+ {9c88e442-602b-4f35-be88-ef1b60670bb7}
+
+
+
+
+ interpreter
+
+
+
+
+ include
+
+
+
\ No newline at end of file
diff --git a/msvc/interpreter.vcxproj.user b/msvc/interpreter.vcxproj.user
new file mode 100644
index 0000000..88a5509
--- /dev/null
+++ b/msvc/interpreter.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/msvc/pasm.sln b/msvc/pasm.sln
new file mode 100644
index 0000000..d25f95d
--- /dev/null
+++ b/msvc/pasm.sln
@@ -0,0 +1,41 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.1.32407.343
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pasm", "pasm.vcxproj", "{6365D58B-DF8C-46B2-A93D-78D988A34FE8}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "interpreter", "interpreter.vcxproj", "{6045F9D7-3A5E-406A-9949-7ABBB3BCBECC}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Debug|x64.ActiveCfg = Debug|x64
+ {6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Debug|x64.Build.0 = Debug|x64
+ {6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Debug|x86.ActiveCfg = Debug|Win32
+ {6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Debug|x86.Build.0 = Debug|Win32
+ {6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Release|x64.ActiveCfg = Release|x64
+ {6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Release|x64.Build.0 = Release|x64
+ {6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Release|x86.ActiveCfg = Release|Win32
+ {6365D58B-DF8C-46B2-A93D-78D988A34FE8}.Release|x86.Build.0 = Release|Win32
+ {6045F9D7-3A5E-406A-9949-7ABBB3BCBECC}.Debug|x64.ActiveCfg = Debug|x64
+ {6045F9D7-3A5E-406A-9949-7ABBB3BCBECC}.Debug|x64.Build.0 = Debug|x64
+ {6045F9D7-3A5E-406A-9949-7ABBB3BCBECC}.Debug|x86.ActiveCfg = Debug|Win32
+ {6045F9D7-3A5E-406A-9949-7ABBB3BCBECC}.Debug|x86.Build.0 = Debug|Win32
+ {6045F9D7-3A5E-406A-9949-7ABBB3BCBECC}.Release|x64.ActiveCfg = Release|x64
+ {6045F9D7-3A5E-406A-9949-7ABBB3BCBECC}.Release|x64.Build.0 = Release|x64
+ {6045F9D7-3A5E-406A-9949-7ABBB3BCBECC}.Release|x86.ActiveCfg = Release|Win32
+ {6045F9D7-3A5E-406A-9949-7ABBB3BCBECC}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {1BAB47BA-9B83-4A9D-BA2D-A3E99F5D5EBD}
+ EndGlobalSection
+EndGlobal
diff --git a/msvc/pasm.vcxproj b/msvc/pasm.vcxproj
new file mode 100644
index 0000000..80a111c
--- /dev/null
+++ b/msvc/pasm.vcxproj
@@ -0,0 +1,181 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 16.0
+ Win32Proj
+ {6365d58b-df8c-46b2-a93d-78d988a34fe8}
+ pasm
+ 10.0
+
+
+
+ StaticLibrary
+ true
+ v143
+ Unicode
+
+
+ StaticLibrary
+ false
+ v143
+ true
+ Unicode
+
+
+ StaticLibrary
+ true
+ v143
+ Unicode
+
+
+ StaticLibrary
+ false
+ v143
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ false
+
+
+ true
+
+
+ false
+
+
+
+ Level3
+ true
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
+ true
+ stdc17
+
+
+ Console
+ true
+
+
+ pasm_run_script
+
+
+
+
+ Level3
+ true
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
+ true
+ stdc17
+ MinSpace
+ Size
+ None
+
+
+ Console
+ true
+ true
+ true
+
+
+ pasm_run_script
+
+
+
+
+ Level3
+ true
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
+ true
+ stdc17
+
+
+ Console
+ true
+
+
+ pasm_run_script
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
+ true
+ stdc17
+ MinSpace
+ Size
+ None
+
+
+ Console
+ true
+ true
+ true
+
+
+ pasm_run_script
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/msvc/pasm.vcxproj.filters b/msvc/pasm.vcxproj.filters
new file mode 100644
index 0000000..24bbf44
--- /dev/null
+++ b/msvc/pasm.vcxproj.filters
@@ -0,0 +1,46 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ pasm
+
+
+ pasm
+
+
+ pasm
+
+
+ pasm
+
+
+ pasm
+
+
+ pasm
+
+
+
+
+ pasm
+
+
+ pasm
+
+
+ pasm
+
+
+ pasm
+
+
+ pasm
+
+
+
\ No newline at end of file
diff --git a/msvc/pasm.vcxproj.user b/msvc/pasm.vcxproj.user
new file mode 100644
index 0000000..88a5509
--- /dev/null
+++ b/msvc/pasm.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/api.c b/src/api.c
index 15b23e0..9e35933 100644
--- a/src/api.c
+++ b/src/api.c
@@ -16,8 +16,13 @@ void api_put() {
if (mode != 1 && mode != 2) return;
int f = fstream;
+#ifdef _WIN32
+ if (f == _fileno(stderr))
+ f = _fileno(stdout);
+#else
if (f == fileno(stderr))
- f = fileno(stdout);
+ f = fileno(stdout);
+#endif
if (mode == 1) {
char c = state->STACK[state->STACK_IDX--];
diff --git a/src/file_utils.c b/src/file_utils.c
index 3c25578..369b304 100644
--- a/src/file_utils.c
+++ b/src/file_utils.c
@@ -24,7 +24,11 @@ int read_script(const char *filename, char ***buf, size_t *lines) {
if (line[length - 1] == '\n') {
line[length - 1] = '\0';
}
- char *line_copy = strdup(line);
+#ifdef _WIN32
+ char *line_copy = _strdup(line);
+#else
+ char *line_copy = strdup(line);
+#endif
char **temp = realloc(*buf, (line_count + 1) * sizeof(char*));
if (temp == NULL) {
dprintf(fstream, "Error allocating memory.\n");
diff --git a/src/instructions.c b/src/instructions.c
index 70f11b7..6280d43 100644
--- a/src/instructions.c
+++ b/src/instructions.c
@@ -196,7 +196,7 @@ void _sqrt() {
return;
}
- *get_reg(state->args->arg1) = sqrt(get_value(state->args->arg1));
+ *get_reg(state->args->arg1) = (int)sqrt(get_value(state->args->arg1));
}
void neg() {
diff --git a/src/interpreter_states.c b/src/interpreter_states.c
index 7918866..ab28f78 100644
--- a/src/interpreter_states.c
+++ b/src/interpreter_states.c
@@ -85,7 +85,11 @@ LABEL_ERR add_label(char *label, int line) {
if (strcmp(label, state->labels[i]) == 0)
return LABEL_ALREADY_EXISTS;
+#ifdef _WIN32
+ char *line_copy = _strdup(label);
+#else
char *line_copy = strdup(label);
+#endif
if (line_copy == NULL) {
dprintf(fstream, "Error allocating memory.\n");
return LABEL_ERROR;
@@ -125,7 +129,11 @@ int parse_arguments(char *line) {
strcpy(state->args->arg1, "");
strcpy(state->args->arg2, "");
+#ifdef _WIN32
+ char *line_cpy = _strdup(line);
+#else
char *line_cpy = strdup(line);
+#endif
char *ptr = strstr(line_cpy, " ");
char *arg = 0;
if (!ptr) {
diff --git a/src/pasm.c b/src/pasm.c
index 3d4ff66..ac1e563 100644
--- a/src/pasm.c
+++ b/src/pasm.c
@@ -90,7 +90,11 @@ int pasm_run_script(const char *filename, char **file, size_t lines, int _fstrea
for (state->curr_line = 0; state->curr_line < (int)lines && get_exit_state() == 0 ; ++state->curr_line) {
if (pasm_debug_mode && found_main)
debug_input(file[state->curr_line]);
+#ifdef _WIN32
+ char* line = _strdup(file[state->curr_line]);
+#else
char *line = strdup(file[state->curr_line]);
+#endif
if (line[0] == ';' || line[0] == '\0') {
free(line);
continue;