- enhancement: New "Hello GAS" and "GAS and C" templates for linux and win64.
This commit is contained in:
parent
25d0f5b782
commit
6068f70d61
3
NEWS.md
3
NEWS.md
|
@ -23,7 +23,8 @@ Red Panda C++ Version 2.12
|
||||||
- fix: Can't parse enum values.
|
- fix: Can't parse enum values.
|
||||||
- fix: Can't correctly show enum values in the class browser.
|
- fix: Can't correctly show enum values in the class browser.
|
||||||
- fix: Can't correctly create project, if template's encoding setting is not valid.
|
- fix: Can't correctly create project, if template's encoding setting is not valid.
|
||||||
- enhancement: Add "embed assembly" template.
|
- enhancement: New "embed assembly" template.
|
||||||
|
- enhancement: New "Hello GAS" and "GAS and C" templates for linux and win64.
|
||||||
|
|
||||||
Red Panda C++ Version 2.11
|
Red Panda C++ Version 2.11
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ const QSet<QString> ASMSyntaxer::ATTDirectives {
|
||||||
".endif",".equ",".equiv",".eqy",
|
".endif",".equ",".equiv",".eqy",
|
||||||
".err",".error",".exitm",".extern",
|
".err",".error",".exitm",".extern",
|
||||||
".fail",".file",".fill", ".float",
|
".fail",".file",".fill", ".float",
|
||||||
".func",".global",".gnu",".hidden",
|
".func",".globl",".global",".gnu",".hidden",
|
||||||
".hword",".ident",".if", ".incbin",
|
".hword",".ident",".if", ".incbin",
|
||||||
".inclue", ".int", ".internal", ".intel_syntax",".irp",
|
".inclue", ".int", ".internal", ".intel_syntax",".irp",
|
||||||
".irpc",".lcomm",".lflags",".line",".linkonce",
|
".irpc",".lcomm",".lflags",".line",".linkonce",
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
|
@ -0,0 +1,27 @@
|
||||||
|
[Template]
|
||||||
|
Ver = 3
|
||||||
|
Name = GAS & C
|
||||||
|
Category = Assembly
|
||||||
|
Description = C and GAS mixing programming demo
|
||||||
|
Name[zh_CN] = GAS与C
|
||||||
|
Category[zh_CN] = 汇编
|
||||||
|
Description[zh_CN] = C和GAS汇编混合编程示例
|
||||||
|
Icon = app.ico
|
||||||
|
|
||||||
|
|
||||||
|
[Project]
|
||||||
|
Type = 1
|
||||||
|
IsCpp = true
|
||||||
|
Encoding = UTF-8
|
||||||
|
ClassBrowserType = 0
|
||||||
|
UnitCount = 2
|
||||||
|
|
||||||
|
|
||||||
|
[Unit0]
|
||||||
|
Source = utils.s
|
||||||
|
Target = utils.s
|
||||||
|
|
||||||
|
|
||||||
|
[Unit1]
|
||||||
|
Cpp = main.cpp
|
||||||
|
CppName = main.cpp
|
|
@ -0,0 +1,26 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
.text
|
||||||
|
.globl maxofthree
|
||||||
|
.globl add3
|
||||||
|
maxofthree:
|
||||||
|
mov %edi, %eax # result (rax) initially holds x
|
||||||
|
cmp %esi, %eax # is x less than y?
|
||||||
|
cmovl %esi, %eax # if so, set result to y
|
||||||
|
cmp %edx, %eax # is max(x,y) less than z?
|
||||||
|
cmovl %edx, %eax # if so, set result to z
|
||||||
|
ret # the max will be in rax
|
||||||
|
add3:
|
||||||
|
mov %edi, %eax
|
||||||
|
add %esi, %eax
|
||||||
|
add %edx, %eax
|
||||||
|
ret
|
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
|
@ -0,0 +1,22 @@
|
||||||
|
[Template]
|
||||||
|
Ver = 3
|
||||||
|
Name = Hello GAS
|
||||||
|
Category = Assembly
|
||||||
|
Description = A simple GNU as program
|
||||||
|
Name[zh_CN] = GAS你好
|
||||||
|
Category[zh_CN] = 汇编
|
||||||
|
Description[zh_CN] = 简单的GNU汇编程序示例
|
||||||
|
Icon = app.ico
|
||||||
|
|
||||||
|
|
||||||
|
[Project]
|
||||||
|
Type = 1
|
||||||
|
IsCpp = true
|
||||||
|
Encoding = UTF-8
|
||||||
|
ClassBrowserType = 0
|
||||||
|
UnitCount = 1
|
||||||
|
|
||||||
|
|
||||||
|
[Unit0]
|
||||||
|
Source = main.s
|
||||||
|
Target = main.s
|
|
@ -0,0 +1,24 @@
|
||||||
|
.text
|
||||||
|
.globl main
|
||||||
|
.extern printf
|
||||||
|
|
||||||
|
main:
|
||||||
|
# AMD64 Calling convention:
|
||||||
|
# - The first six parameters are passed in the rsi, rbi, rdx, rdx, r8, and r9 registers.
|
||||||
|
# - Any additional arguments are passed on the stack.
|
||||||
|
# - An return value is returned in the rax register.
|
||||||
|
# see https://en.wikipedia.org/wiki/X86_calling_conventions#x86-64_calling_conventions
|
||||||
|
|
||||||
|
leaq fmt(%rip), %rdi # first parameter
|
||||||
|
leaq msg(%rip), %rsi # second parameter
|
||||||
|
mov $0, %eax
|
||||||
|
call printf
|
||||||
|
|
||||||
|
xor %eax,%eax # set 0 as exit code
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
msg:
|
||||||
|
.asciz "Hello world\n" # asciz puts a 0 byte at the end
|
||||||
|
fmt:
|
||||||
|
.asciz "%s" # asciz puts a 0 byte at the end
|
|
@ -1,6 +1,6 @@
|
||||||
.global maxofthree
|
|
||||||
.global add3
|
|
||||||
.text
|
.text
|
||||||
|
.globl maxofthree
|
||||||
|
.globl add3
|
||||||
maxofthree:
|
maxofthree:
|
||||||
mov %ecx, %eax # result (rax) initially holds x
|
mov %ecx, %eax # result (rax) initially holds x
|
||||||
cmp %edx, %eax # is x less than y?
|
cmp %edx, %eax # is x less than y?
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
.global main
|
.text
|
||||||
|
.globl main
|
||||||
.text:
|
|
||||||
main:
|
main:
|
||||||
# Microsoft X86_64 Calling convention:
|
# 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 integer or pointer parameters are passed in the rcx, rdx, r8, and r9 registers.
|
||||||
|
|
Loading…
Reference in New Issue