mirror of
https://github.com/engineer-man/piston.git
synced 2025-05-15 16:16:28 +02:00
add nasm and nasm64
This commit is contained in:
parent
bc80269ce2
commit
d258bed574
10 changed files with 108 additions and 99 deletions
54
runtimes/nasm-nasm64.nix
Normal file
54
runtimes/nasm-nasm64.nix
Normal file
|
@ -0,0 +1,54 @@
|
|||
{pkgs, piston, ...}:
|
||||
let
|
||||
pkg = pkgs.nasm;
|
||||
binutils = pkgs.binutils;
|
||||
in piston.mkRuntime {
|
||||
language = "nasm64";
|
||||
version = pkg.version;
|
||||
runtime = "nasm";
|
||||
|
||||
aliases = [
|
||||
"asm64"
|
||||
];
|
||||
|
||||
compile = ''
|
||||
${pkg}/bin/nasm -f elf64 -o binary.o "$@"
|
||||
${binutils}/bin/ld -m elf_x86_64 binary.o -o binary
|
||||
'';
|
||||
|
||||
run = ''
|
||||
shift
|
||||
./binary "$@"
|
||||
'';
|
||||
|
||||
tests = [
|
||||
(piston.mkTest {
|
||||
files = {
|
||||
"test.asm64" = ''
|
||||
SECTION .data
|
||||
good: db "OK", 10
|
||||
txtlen: equ $ - good
|
||||
|
||||
SECTION .text
|
||||
GLOBAL _start
|
||||
|
||||
_start:
|
||||
;sys_write
|
||||
mov rax, 1
|
||||
mov rdi, 1
|
||||
mov rsi, good
|
||||
mov rdx, txtlen
|
||||
syscall
|
||||
;sys_exit
|
||||
mov rax, 60
|
||||
mov rdi, 0
|
||||
syscall
|
||||
'';
|
||||
};
|
||||
args = [];
|
||||
stdin = "";
|
||||
packages = [];
|
||||
main = "test.asm64";
|
||||
})
|
||||
];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue