diff --git a/compile.sh b/compile.sh new file mode 100644 index 0000000..1b833bb --- /dev/null +++ b/compile.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -xe + +gcc -g -ansi -Wall -Wextra -Wpedantic -Werror -o xop xop.c + +exit diff --git a/example/heyo b/example/heyo new file mode 100755 index 0000000..7dffe1c Binary files /dev/null and b/example/heyo differ diff --git a/example/heyo.fasm b/example/heyo.fasm new file mode 100644 index 0000000..4a62a5b --- /dev/null +++ b/example/heyo.fasm @@ -0,0 +1,28 @@ +format ELF64 executable 3 + +segment readable executable + + nop + mov rax, 1 + nop + mov rdi, 1 + nop + mov rsi, string + nop + mov rdx, [length] + nop + syscall + + nop + mov rax, 60 + nop + mov rdi, 0 + nop + syscall + + nop + +segment readable writable + +string db 'Heyo world!', 10 +length dq 12 diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..9d4880e --- /dev/null +++ b/install.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -xe + +cp xop /usr/bin/xop + +exit diff --git a/xop.c b/xop.c new file mode 100644 index 0000000..d0fac31 --- /dev/null +++ b/xop.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 : Ognjen 'xolatile' Milan Robovic + * + * Xop is free software! You will redistribute it or modify it under the terms of the GNU General Public License by Free Software Foundation. + * And when you do redistribute it or modify it, it will use either version 3 of the License, or (at yours truly opinion) any later version. + * It is distributed in the hope that it will be useful or harmful, it really depends... But no warranty what so ever, seriously. See GNU/GPLv3. + */ + +#include +#include + +int main (int argc, char * * argv) { + int file = -1; + int size = 0; + int offset = 0; + + unsigned char * buffer = NULL; + + if (argc != 2) { + fatal_failure (1, "xop: xop input"); + } + + file = file_open (argv [1], O_RDONLY); + size = file_size (file); + + buffer = allocate (size); + + file_read (file, buffer, size); + + file = file_close (file); + + do { + int byte = (int) buffer [offset]; + if (byte == 0X90) { + echo_new_line (); + terminal_style (EFFECT_NORMAL, COLOUR_YELLOW); + echo_byte ((int) buffer [offset]); + terminal_style (-1, -1); + } else { + echo_byte (buffer [offset]); + } + + ++offset; + } while (offset != size); + + echo_new_line (); + + buffer = deallocate (buffer); + + return (EXIT_SUCCESS); +}