From 410cb50b18275188c6f206f469355b9baebe8a5e Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 22 Feb 2023 13:38:31 +0800 Subject: [PATCH] remove nasm templates - fix: "Generate assembly" menu item is wrongly enabled for new GNU assembly files --- RedPandaIDE/mainwindow.cpp | 2 +- .../templates-win64/GAS_C/info.template | 4 +- .../templates-win64/Hello_GAS/info.template | 2 +- .../templates-win64/Hello_NASM/app.ico | Bin 4286 -> 0 bytes .../templates-win64/Hello_NASM/info.template | 22 ---------- .../templates-win64/Hello_NASM/main.asm | 26 ------------ .../windows/templates-win64/NASM_C/app.ico | Bin 4286 -> 0 bytes .../templates-win64/NASM_C/info.template | 27 ------------ .../windows/templates-win64/NASM_C/main.cpp | 26 ------------ .../windows/templates-win64/NASM_C/utils.asm | 15 ------- .../windows/templates/GLFW/GLFW_main.cpp.txt | 40 +++++++----------- .../windows/templates/GLFW/GLFW_shader.h.txt | 18 ++++---- platform/windows/templates/GLFW/info.template | 4 +- 13 files changed, 31 insertions(+), 155 deletions(-) delete mode 100644 platform/windows/templates-win64/Hello_NASM/app.ico delete mode 100644 platform/windows/templates-win64/Hello_NASM/info.template delete mode 100644 platform/windows/templates-win64/Hello_NASM/main.asm delete mode 100644 platform/windows/templates-win64/NASM_C/app.ico delete mode 100644 platform/windows/templates-win64/NASM_C/info.template delete mode 100644 platform/windows/templates-win64/NASM_C/main.cpp delete mode 100644 platform/windows/templates-win64/NASM_C/utils.asm diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 5237d80e..dbae1acd 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -691,7 +691,7 @@ void MainWindow::updateCompileActions(const Editor *e) if (!e->inProject()) { FileType fileType = getFileType(e->filename()); if (fileType == FileType::CSource - || fileType == FileType::CppSource || e->isNew()) { + || fileType == FileType::CppSource) { canGenerateAssembly = true; canCompile = true; canRun = true; diff --git a/platform/windows/templates-win64/GAS_C/info.template b/platform/windows/templates-win64/GAS_C/info.template index c5191189..22b19b75 100644 --- a/platform/windows/templates-win64/GAS_C/info.template +++ b/platform/windows/templates-win64/GAS_C/info.template @@ -2,10 +2,10 @@ Ver = 3 Name = GAS & C Category = Assembly -Description = C and GAS mixing programming demo +Description = C and GNU assembly mixing programming demo Name[zh_CN] = GAS与C Category[zh_CN] = 汇编 -Description[zh_CN] = C和GAS汇编混合编程示例 +Description[zh_CN] = C和GNU汇编混合编程示例 Icon = app.ico diff --git a/platform/windows/templates-win64/Hello_GAS/info.template b/platform/windows/templates-win64/Hello_GAS/info.template index 472b9e51..9c0e518e 100644 --- a/platform/windows/templates-win64/Hello_GAS/info.template +++ b/platform/windows/templates-win64/Hello_GAS/info.template @@ -2,7 +2,7 @@ Ver = 3 Name = Hello GAS Category = Assembly -Description = A simple GNU as program +Description = A simple GNU assembly program Name[zh_CN] = GAS你好 Category[zh_CN] = 汇编 Description[zh_CN] = 简单的GNU汇编程序示例 diff --git a/platform/windows/templates-win64/Hello_NASM/app.ico b/platform/windows/templates-win64/Hello_NASM/app.ico deleted file mode 100644 index b41b95cff98de368e922083427797994ba9ea523..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4286 zcmchaFKpXD6vnUWq{0PFV{6$m77Yb$3M^}3s9~U?K|9INFfgDbQa}R@O*57;!_dIM zNCUmS-^DMzoMI>Lq+a#mjBHQhD-$nZUzFjO9mZBVby`EjK*G`B-E2-w`{5p-# ztP6gg=X-283Gd@WYo2IEvlV*wI*k&@WCvhH0yr= z`LL$e;eyTBWB!wmoBfh_mBN9w@pV3*6YhF^IH<_n zI!wQPk5}!Dv-PZqZi5d`m9{+Kbik$ZpFKI{zm8GtP`5c78XLG!=dM15&$zAZONblV zZ;FY;;S@d`DIs2+-G;|f&i^TV`nA+y*0rC*? z3GolOczF?G9sq6iqV-#O?i0Rv`jolP~IO^I)e4bBsn5DEw z$=H1}SVPAsZm4}+t#c2Zk1rU4pUWE&PHVv&#)-U}3%3UNehKk?n{n90ju`OPZuJM$i{}?uXq5p1tzVlx>(bl#w7vc9&9X4xnCizXsS=s5_ zruo8-MyZ@ZxdV#az1iq%EADsKk(m3wuqJ22mr@RWG?q7Fl-Ya9{c+ImkFBfYkKSoM zo?m}7=2GNB_0z6?@npW=JeqHJqVMRZy-8-$k33g0`ye)Q_4sRc^;h)ErO5Bu$Cp3P N4=-P2%^xBU{{StjsdxYY diff --git a/platform/windows/templates-win64/Hello_NASM/info.template b/platform/windows/templates-win64/Hello_NASM/info.template deleted file mode 100644 index b3222130..00000000 --- a/platform/windows/templates-win64/Hello_NASM/info.template +++ /dev/null @@ -1,22 +0,0 @@ -[Template] -Ver = 3 -Name = Hello NASM -Category = NASM -Description = A simple nasm program -Name[zh_CN] = NASM你好 -Category[zh_CN] = NASM -Description[zh_CN] = 简单的NASM汇编程序示例 -Icon = app.ico - - -[Project] -Type = 1 -IsCpp = true -Encoding = UTF-8 -ClassBrowserType = 0 -UnitCount = 1 - - -[Unit0] -Source = main.asm -Target = main.asm diff --git a/platform/windows/templates-win64/Hello_NASM/main.asm b/platform/windows/templates-win64/Hello_NASM/main.asm deleted file mode 100644 index 5830e25a..00000000 --- a/platform/windows/templates-win64/Hello_NASM/main.asm +++ /dev/null @@ -1,26 +0,0 @@ -extern printf -extern exit -global main - -section .data ; Data section, initialized variables -msg: db "Hello world", 0 ; C string needs 0 -fmt: db "%s", 10, 0 ; The printf format, "\n",'0' - -section .text: -main: - ; Microsoft X86_64 Calling convention: - ; - The first four integer or pointer parameters are passed in the rcx, rdx, r8, and r9 registers. - ; - The first four floating-point parameters are passed in the first four SSE registers, xmm0-xmm3. - ; - The caller reserves space on the stack for arguments passed in registers. The called function can use this space to spill the contents of registers to the stack. - ; - Any additional arguments are passed on the stack. - ; - An integer or pointer return value is returned in the rax register, while a floating-point return value is returned in xmm0. - ; see https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/x64-architecture - - sub rsp, 32 ; reserve stack space for call - lea rcx, [rel fmt] ; first parameter - lea rdx, [rel msg] ; secodng parameter - call printf - add rsp,32 ; restore stack - - mov eax,0 ; exit code - ret \ No newline at end of file diff --git a/platform/windows/templates-win64/NASM_C/app.ico b/platform/windows/templates-win64/NASM_C/app.ico deleted file mode 100644 index b41b95cff98de368e922083427797994ba9ea523..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4286 zcmchaFKpXD6vnUWq{0PFV{6$m77Yb$3M^}3s9~U?K|9INFfgDbQa}R@O*57;!_dIM zNCUmS-^DMzoMI>Lq+a#mjBHQhD-$nZUzFjO9mZBVby`EjK*G`B-E2-w`{5p-# ztP6gg=X-283Gd@WYo2IEvlV*wI*k&@WCvhH0yr= z`LL$e;eyTBWB!wmoBfh_mBN9w@pV3*6YhF^IH<_n zI!wQPk5}!Dv-PZqZi5d`m9{+Kbik$ZpFKI{zm8GtP`5c78XLG!=dM15&$zAZONblV zZ;FY;;S@d`DIs2+-G;|f&i^TV`nA+y*0rC*? z3GolOczF?G9sq6iqV-#O?i0Rv`jolP~IO^I)e4bBsn5DEw z$=H1}SVPAsZm4}+t#c2Zk1rU4pUWE&PHVv&#)-U}3%3UNehKk?n{n90ju`OPZuJM$i{}?uXq5p1tzVlx>(bl#w7vc9&9X4xnCizXsS=s5_ zruo8-MyZ@ZxdV#az1iq%EADsKk(m3wuqJ22mr@RWG?q7Fl-Ya9{c+ImkFBfYkKSoM zo?m}7=2GNB_0z6?@npW=JeqHJqVMRZy-8-$k33g0`ye)Q_4sRc^;h)ErO5Bu$Cp3P N4=-P2%^xBU{{StjsdxYY diff --git a/platform/windows/templates-win64/NASM_C/info.template b/platform/windows/templates-win64/NASM_C/info.template deleted file mode 100644 index f419ab71..00000000 --- a/platform/windows/templates-win64/NASM_C/info.template +++ /dev/null @@ -1,27 +0,0 @@ -[Template] -Ver = 3 -Name = NASM & C -Category = NASM -Description = C and NASM mixing programming demo -Name[zh_CN] = NASM与C -Category[zh_CN] = NASM -Description[zh_CN] = C和NASM汇编混合编程示例 -Icon = app.ico - - -[Project] -Type = 1 -IsCpp = true -Encoding = UTF-8 -ClassBrowserType = 0 -UnitCount = 2 - - -[Unit0] -Source = utils.asm -Target = utils.asm - - -[Unit1] -Cpp = main.cpp -CppName = main.cpp diff --git a/platform/windows/templates-win64/NASM_C/main.cpp b/platform/windows/templates-win64/NASM_C/main.cpp deleted file mode 100644 index a7a84be5..00000000 --- a/platform/windows/templates-win64/NASM_C/main.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include - -#ifdef __cplusplus -#define ASM_FUNC extern "C" -#else -#define ASM_FUNC -#endif - -ASM_FUNC int maxofthree(int, int, int); -ASM_FUNC int add3(int, int, int); - -int main() { - printf("%d\n", add3(1, -4, -7)); - printf("%d\n", add3(1, 2, 3)); - printf("%d\n", add3(2, -6, 1)); - - printf("------\n"); - - printf("%d\n", maxofthree(1, -4, -7)); - printf("%d\n", maxofthree(2, -6, 1)); - printf("%d\n", maxofthree(2, 3, 1)); - printf("%d\n", maxofthree(-2, 4, 3)); - printf("%d\n", maxofthree(2, -6, 5)); - printf("%d\n", maxofthree(2, 4, 6)); - return 0; -} diff --git a/platform/windows/templates-win64/NASM_C/utils.asm b/platform/windows/templates-win64/NASM_C/utils.asm deleted file mode 100644 index 603869c5..00000000 --- a/platform/windows/templates-win64/NASM_C/utils.asm +++ /dev/null @@ -1,15 +0,0 @@ -global maxofthree -global add3 -section .text -maxofthree: - mov eax, ecx ; result (rax) initially holds x - cmp eax, edx ; is x less than y? - cmovl eax, edx ; if so, set result to y - cmp eax, r8d ; is max(x,y) less than z? - cmovl eax, r8d ; if so, set result to z - ret ; the max will be in rax -add3: - mov eax, ecx - add eax, edx - add eax, r8d - ret diff --git a/platform/windows/templates/GLFW/GLFW_main.cpp.txt b/platform/windows/templates/GLFW/GLFW_main.cpp.txt index 3d5cfdae..6aeb5582 100644 --- a/platform/windows/templates/GLFW/GLFW_main.cpp.txt +++ b/platform/windows/templates/GLFW/GLFW_main.cpp.txt @@ -40,56 +40,46 @@ int main() glViewport(0, 0, WIDTH, HEIGHT); - //ȡshaderļ룬shader.h Shader ourShader("shader.vs", "shader.frag"); - - // һά飬ÿһԣǰλԣɫ GLfloat vertices[] = { // Positions // Colors 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, // Bottom Right -0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, // Bottom Left 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 1.0f // Top }; - GLuint VBO, VAO;//㻺壬ڹ - glGenVertexArrays(1, &VAO);//飬һһ޶ʶ - glGenBuffers(1, &VBO);//㻺壬һһ޶ʶ + GLuint VBO, VAO; + glGenVertexArrays(1, &VAO); + glGenBuffers(1, &VBO); - glBindVertexArray(VAO);//󶨶 - glBindBuffer(GL_ARRAY_BUFFER, VBO);//󶨶㻺 - //ָԴΪverticesĸԿιݣGL_STATIC_DRWAı + glBindVertexArray(VAO); + glBindBuffer(GL_ARRAY_BUFFER, VBO); + glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); - // ָԵĽʽδӶ㻺ȡӦĶԺӦɫԡ˵ɫ֪ȥĸԷɫ - //ÿһԣ2֣һλԣɫԣÿһλúɫ - - //ɫʹlayout(location = 0)positionԵλֵ(Location)˵һԷ - //λԵάȣͣ:Ƿ׼壬λԵֽڳȣڻеƫʼλ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), (GLvoid*)0); - glEnableVertexAttribArray(0);//0ΪĬǽõ + glEnableVertexAttribArray(0); - // һӦɫеlayout (location = 1) in vec3 color;˵ɫԵƫverticesһ glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), (GLvoid*)(3 * sizeof(GLfloat))); - glEnableVertexAttribArray(1);//1. + glEnableVertexAttribArray(1); + + glBindVertexArray(0); - //(Vertex Array Object, VAO)ĺôǣöָʱֻҪĴִһΣ֮ٻʱֻҪӦVAOˡѭеİٽ - glBindVertexArray(0); // VAO // Game loop while (!glfwWindowShouldClose(window)) { - // ¼ӦĻصĵkey_callback glfwPollEvents(); // Render // Clear the colorbuffer - glClearColor(0.2f, 0.3f, 0.3f, 1.0f);//Ⱦɫ̨ - glClear(GL_COLOR_BUFFER_BIT);//ǰ̨ + glClearColor(0.2f, 0.3f, 0.3f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); // Draw the triangle - ourShader.Use();//ɫ - glBindVertexArray(VAO);//ÿѭã󶨺VAO + ourShader.Use(); + glBindVertexArray(VAO); glDrawArrays(GL_TRIANGLES, 0, 3); - glBindVertexArray(0);// + glBindVertexArray(0); // Swap the screen buffers glfwSwapBuffers(window); diff --git a/platform/windows/templates/GLFW/GLFW_shader.h.txt b/platform/windows/templates/GLFW/GLFW_shader.h.txt index 01387630..b4382129 100644 --- a/platform/windows/templates/GLFW/GLFW_shader.h.txt +++ b/platform/windows/templates/GLFW/GLFW_shader.h.txt @@ -50,18 +50,18 @@ public: GLint success; GLchar infoLog[512]; // Vertex Shader - vertex = glCreateShader(GL_VERTEX_SHADER);//ɫ - glShaderSource(vertex, 1, &vShaderCode, NULL);//ָԴ - glCompileShader(vertex);//ɫ + vertex = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vertex, 1, &vShaderCode, NULL); + glCompileShader(vertex); // Print compile errors if any - glGetShaderiv(vertex, GL_COMPILE_STATUS, &success);//鿴Ƿɹ + glGetShaderiv(vertex, GL_COMPILE_STATUS, &success); if (!success) { glGetShaderInfoLog(vertex, 512, NULL, infoLog); std::cout << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << std::endl; } // Fragment Shader - fragment = glCreateShader(GL_FRAGMENT_SHADER);//Ƭɫ + fragment = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(fragment, 1, &fShaderCode, NULL); glCompileShader(fragment); // Print compile errors if any @@ -72,10 +72,10 @@ public: std::cout << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog << std::endl; } // Shader Program - this->Program = glCreateProgram();//ɫ - glAttachShader(this->Program, vertex);//ɫ - glAttachShader(this->Program, fragment);//Ƭɫ - glLinkProgram(this->Program);//ӱ + this->Program = glCreateProgram(); + glAttachShader(this->Program, vertex); + glAttachShader(this->Program, fragment); + glLinkProgram(this->Program); // Print linking errors if any glGetProgramiv(this->Program, GL_LINK_STATUS, &success); if (!success) diff --git a/platform/windows/templates/GLFW/info.template b/platform/windows/templates/GLFW/info.template index e577055e..e2b8f603 100644 --- a/platform/windows/templates/GLFW/info.template +++ b/platform/windows/templates/GLFW/info.template @@ -10,10 +10,12 @@ Category[zh_CN]=3D [Unit0] CppName=main.cpp Cpp=GLFW_main.cpp.txt +Cpp[zh_CN]=GLFW_main_zh_CN.cpp [Unit1] CppName=shader.h Cpp=GLFW_shader.h.txt +Cpp[zh_CN]=GLFW_shader_zh_CN.h [Unit2] CppName=shader.frag @@ -32,7 +34,7 @@ CppCompiler= Linker=-lglfw3 -lglew32 -lopengl32 -lwinmm -lgdi32_@@__@@_ CompilerSettings=0000000000110000000001000 CompilerSet=1 -UseUTF8=0 +Encoding = UTF-8 StaticLink=1 AddCharset=1 IncludeVersionInfo=0