From 26880aba618ec5aab600170f1d695d34ee742068 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 19 May 2020 23:12:09 +0800 Subject: add gas tests --- tests/projects/asm/fasm/src/main.S | 28 ++++++++++++++++++++++++++++ tests/projects/asm/fasm/xmake.lua | 3 +++ tests/projects/asm/gas/src/main.S | 9 +++++++++ tests/projects/asm/gas/xmake.lua | 3 +++ tests/projects/asm/nasm/src/main.S | 21 +++++++++++++++++++++ tests/projects/asm/nasm/xmake.lua | 3 +++ tests/projects/asm/yasm/src/main.S | 20 ++++++++++++++++++++ tests/projects/asm/yasm/xmake.lua | 3 +++ tests/projects/fasm/src/main.S | 28 ---------------------------- tests/projects/fasm/xmake.lua | 3 --- tests/projects/nasm/src/main.S | 21 --------------------- tests/projects/nasm/xmake.lua | 3 --- tests/projects/yasm/src/main.S | 20 -------------------- tests/projects/yasm/xmake.lua | 3 --- 14 files changed, 90 insertions(+), 78 deletions(-) create mode 100644 tests/projects/asm/fasm/src/main.S create mode 100644 tests/projects/asm/fasm/xmake.lua create mode 100644 tests/projects/asm/gas/src/main.S create mode 100644 tests/projects/asm/gas/xmake.lua create mode 100644 tests/projects/asm/nasm/src/main.S create mode 100644 tests/projects/asm/nasm/xmake.lua create mode 100644 tests/projects/asm/yasm/src/main.S create mode 100644 tests/projects/asm/yasm/xmake.lua delete mode 100644 tests/projects/fasm/src/main.S delete mode 100644 tests/projects/fasm/xmake.lua delete mode 100644 tests/projects/nasm/src/main.S delete mode 100644 tests/projects/nasm/xmake.lua delete mode 100644 tests/projects/yasm/src/main.S delete mode 100644 tests/projects/yasm/xmake.lua diff --git a/tests/projects/asm/fasm/src/main.S b/tests/projects/asm/fasm/src/main.S new file mode 100644 index 000000000..90f4b88b4 --- /dev/null +++ b/tests/projects/asm/fasm/src/main.S @@ -0,0 +1,28 @@ +format MZ + +entry main:start ; program entry point +stack 100h ; stack size + +segment main ; main program segment + + start: + mov ax,text + mov ds,ax + + mov dx,hello + call extra:write_text + + mov ax,4C00h + int 21h + +segment text + + hello db 'Hello world!',24h + +segment extra + + write_text: + mov ah,9 + int 21h + retf + diff --git a/tests/projects/asm/fasm/xmake.lua b/tests/projects/asm/fasm/xmake.lua new file mode 100644 index 000000000..f728b2ca1 --- /dev/null +++ b/tests/projects/asm/fasm/xmake.lua @@ -0,0 +1,3 @@ +target("test") + set_kind("binary") + add_files("src/*.S") diff --git a/tests/projects/asm/gas/src/main.S b/tests/projects/asm/gas/src/main.S new file mode 100644 index 000000000..9c242f4a1 --- /dev/null +++ b/tests/projects/asm/gas/src/main.S @@ -0,0 +1,9 @@ + .global main + + .text +main: # This is called by C library's startup code + mov $message, %rdi # First integer (or pointer) parameter in %rdi + call puts # puts(message) + ret # Return to C library code +message: + .asciz "Hola, mundo" # asciz puts a 0 byte at the end diff --git a/tests/projects/asm/gas/xmake.lua b/tests/projects/asm/gas/xmake.lua new file mode 100644 index 000000000..f728b2ca1 --- /dev/null +++ b/tests/projects/asm/gas/xmake.lua @@ -0,0 +1,3 @@ +target("test") + set_kind("binary") + add_files("src/*.S") diff --git a/tests/projects/asm/nasm/src/main.S b/tests/projects/asm/nasm/src/main.S new file mode 100644 index 000000000..5b3a93699 --- /dev/null +++ b/tests/projects/asm/nasm/src/main.S @@ -0,0 +1,21 @@ +global _main + + +section .text + +_main: + mov rax, 0x2000004 ; write + mov rdi, 1 ; stdout + mov rsi, msg + mov rdx, msg.len + syscall + + mov rax, 0x2000001 ; exit + mov rdi, 0 + syscall + + +section .data + +msg: db "hello xmake!", 10 +.len: equ $ - msg diff --git a/tests/projects/asm/nasm/xmake.lua b/tests/projects/asm/nasm/xmake.lua new file mode 100644 index 000000000..f728b2ca1 --- /dev/null +++ b/tests/projects/asm/nasm/xmake.lua @@ -0,0 +1,3 @@ +target("test") + set_kind("binary") + add_files("src/*.S") diff --git a/tests/projects/asm/yasm/src/main.S b/tests/projects/asm/yasm/src/main.S new file mode 100644 index 000000000..800722a44 --- /dev/null +++ b/tests/projects/asm/yasm/src/main.S @@ -0,0 +1,20 @@ +bits 64 + +extern _puts + +section .data + +message: + db 'hello xmake!', 0 + +section .text + +global _main +_main: + push rbp + mov rbp, rsp + lea rdi, [rel message] + call _puts + xor rax, rax + pop rbp + ret diff --git a/tests/projects/asm/yasm/xmake.lua b/tests/projects/asm/yasm/xmake.lua new file mode 100644 index 000000000..f728b2ca1 --- /dev/null +++ b/tests/projects/asm/yasm/xmake.lua @@ -0,0 +1,3 @@ +target("test") + set_kind("binary") + add_files("src/*.S") diff --git a/tests/projects/fasm/src/main.S b/tests/projects/fasm/src/main.S deleted file mode 100644 index 90f4b88b4..000000000 --- a/tests/projects/fasm/src/main.S +++ /dev/null @@ -1,28 +0,0 @@ -format MZ - -entry main:start ; program entry point -stack 100h ; stack size - -segment main ; main program segment - - start: - mov ax,text - mov ds,ax - - mov dx,hello - call extra:write_text - - mov ax,4C00h - int 21h - -segment text - - hello db 'Hello world!',24h - -segment extra - - write_text: - mov ah,9 - int 21h - retf - diff --git a/tests/projects/fasm/xmake.lua b/tests/projects/fasm/xmake.lua deleted file mode 100644 index f728b2ca1..000000000 --- a/tests/projects/fasm/xmake.lua +++ /dev/null @@ -1,3 +0,0 @@ -target("test") - set_kind("binary") - add_files("src/*.S") diff --git a/tests/projects/nasm/src/main.S b/tests/projects/nasm/src/main.S deleted file mode 100644 index 5b3a93699..000000000 --- a/tests/projects/nasm/src/main.S +++ /dev/null @@ -1,21 +0,0 @@ -global _main - - -section .text - -_main: - mov rax, 0x2000004 ; write - mov rdi, 1 ; stdout - mov rsi, msg - mov rdx, msg.len - syscall - - mov rax, 0x2000001 ; exit - mov rdi, 0 - syscall - - -section .data - -msg: db "hello xmake!", 10 -.len: equ $ - msg diff --git a/tests/projects/nasm/xmake.lua b/tests/projects/nasm/xmake.lua deleted file mode 100644 index f728b2ca1..000000000 --- a/tests/projects/nasm/xmake.lua +++ /dev/null @@ -1,3 +0,0 @@ -target("test") - set_kind("binary") - add_files("src/*.S") diff --git a/tests/projects/yasm/src/main.S b/tests/projects/yasm/src/main.S deleted file mode 100644 index 800722a44..000000000 --- a/tests/projects/yasm/src/main.S +++ /dev/null @@ -1,20 +0,0 @@ -bits 64 - -extern _puts - -section .data - -message: - db 'hello xmake!', 0 - -section .text - -global _main -_main: - push rbp - mov rbp, rsp - lea rdi, [rel message] - call _puts - xor rax, rax - pop rbp - ret diff --git a/tests/projects/yasm/xmake.lua b/tests/projects/yasm/xmake.lua deleted file mode 100644 index f728b2ca1..000000000 --- a/tests/projects/yasm/xmake.lua +++ /dev/null @@ -1,3 +0,0 @@ -target("test") - set_kind("binary") - add_files("src/*.S") -- cgit v1.3.1