Moved my testing and utility programs to tool folder...

This commit is contained in:
xolatile
2024-07-08 05:05:55 -04:00
parent 75ea0eaec2
commit f7cd79e4ad
6 changed files with 0 additions and 0 deletions

19
tool/heyo.asm Normal file
View File

@ -0,0 +1,19 @@
format ELF64 executable 3
segment readable executable
entry $
mov eax, 1
mov edi, 1
mov esi, heyo
mov edx, 12
syscall
mov eax, 60
mov edi, 0
syscall
segment readable writable
heyo: db "heyo world!", 10

21
tool/heyo_object.asm Normal file
View File

@ -0,0 +1,21 @@
format ELF64
public _start
section '.text' executable
_start:
mov eax, 1
mov edi, 1
mov esi, heyo
mov edx, 12
syscall
mov eax, 60
mov edi, 0
syscall
section '.data' writable
heyo: db "heyo world!", 10

38
tool/qfat.c Normal file
View File

@ -0,0 +1,38 @@
/* Ignore this file, it's for my autistic way of testing. -- xolatile */
#include <xolatile/xtandard.c>
int main (int argc, char * * argv) {
int file, i;
file = file_open ("qfat.asm", O_RDWR | O_CREAT | O_TRUNC);
file_echo (file, "format ELF64 executable 3\n");
file_echo (file, "segment readable executable\n");
file_echo (file, "entry $\n");
file_echo (file, "x0:\n");
file_echo (file, "nop\n");
for (i = 1; i < argc; ++i) {
if (i == 3) {
file_echo (file, ", ");
} else {
file_echo (file, " ");
}
file_echo (file, argv [i]);
}
file_echo (file, "\nnop\n");
file_echo (file, "segment readable writable\n");
file_echo (file, "x1: db 11h\n");
file_echo (file, "x2: dw 1122h\n");
file_echo (file, "x4: dd 11223344h\n");
file_echo (file, "x8: dq 1122334455667788h\n");
file = file_close (file);
execute ("fasm qfat.asm qfat.obj && xop qfat.obj && rm qfat.asm qfat.obj");
return (log_success);
}

198
tool/test.asm Normal file
View File

@ -0,0 +1,198 @@
format ELF64 executable 3
segment readable executable
entry $
nop
nop
nop
add rcx, r9
add rcx, [x8]
add rcx, 11223344h
add [x8], rcx
add qword[x8], 11223344h
or ecx, r9d
or ecx, [x4]
or ecx, 11223344h
or [x4], ecx
or dword[x4], 11223344h
adc cx, r9w
adc cx, [x2]
adc cx, 1122h
adc [x2], cx
adc word[x2], 1122h
sbb cl, r9b
sbb cl, [x1]
sbb cl, 11h
sbb [x1], cl
sbb byte[x1], 11h
;~add rcx r9 | ADD D64 REG R1 REG R9
;~4C 01 C9 | 4C 01 C9
;~add rcx [x8] | ADD D64 REG R1 MEM 0
;~48 03 0D E1 11 00 00 | 48 03 0D FF FF FF FF
;~add rcx 11223344h | ADD D64 REG R1 IMM 0X11223344U
;~48 81 C1 44 33 22 11 | 48 81 C2 44 33 22 11
;~^^ ^^
;~add [x8] rcx | ADD D64 MEM 0 REG R9
;~48 01 0D D3 11 00 00 | 4C 01 0D FF FF FF FF
;~^^ ^^
;~add [x8] 11223344h | ADD D64 MEM 0 IMM 0X11223344U
;~48 81 05 C8 11 00 00 44 33 22 11 | 48 81 05 FF FF FF FF 44 33 22 11
nop
nop
nop
xor rcx, r9
xor rcx, [x8]
xor rcx, 11223344h
xor [x8], rcx
xor qword[x8], 11223344h
xor ecx, r9d
xor ecx, [x4]
xor ecx, 11223344h
xor [x4], ecx
xor dword[x4], 11223344h
xor cx, r9w
xor cx, [x2]
xor cx, 1122h
xor [x2], cx
xor word[x2], 1122h
xor cl, r9b
xor cl, [x1]
xor cl, 11h
xor [x1], cl
xor byte[x1], 11h
nop
nop
nop
xor rcx, r9
xor rcx, [x8]
xor rcx, 11223344h
xor [x8], rcx
xor qword[x8], 11223344h
xor ecx, r9d
xor ecx, [x4]
xor ecx, 11223344h
xor [x4], ecx
xor dword[x4], 11223344h
xor cx, r9w
xor cx, [x2]
xor cx, 1122h
xor [x2], cx
xor word[x2], 1122h
xor cl, r9b
xor cl, [x1]
xor cl, 11h
xor [x1], cl
xor byte[x1], 11h
nop
nop
nop
inc rcx
inc qword[x8]
inc ecx
inc dword[x4]
inc cx
inc word[x2]
inc cl
inc byte[x1]
nop
nop
nop
div r9
div qword[x8]
div r9d
div dword[x4]
div r9w
div word[x2]
div r9b
div byte[x1]
nop
nop
nop
ret
leave
lock
hlt
nop
nop
nop
sysenter
sysexit
syscall
sysret
pause
cpuid
;~nop
;~nop
;~nop
;~jo fff
;~jno fff
;~jb fff
;~jae fff
;~je fff
;~jne fff
;~jbe fff
;~ja fff
;~js fff
;~jns fff
;~jpe fff
;~jpo fff
;~jl fff
;~jge fff
;~jle fff
;~jg fff
;~nop
;~nop
;~nop
;~cmovo rax, rcx
;~cmovno rax, rcx
;~cmovb rax, rcx
;~cmovae rax, rcx
;~cmove rax, rcx
;~cmovne rax, rcx
;~cmovbe rax, rcx
;~cmova rax, rcx
;~cmovs rax, rcx
;~cmovns rax, rcx
;~cmovpe rax, rcx
;~cmovpo rax, rcx
;~cmovl rax, rcx
;~cmovge rax, rcx
;~cmovle rax, rcx
;~cmovg rax, rcx
nop
nop
nop
;mov
;jmp
nop
nop
nop
segment readable writable
x1: db 011h
x2: dw 01122h
x4: dd 011223344h
x8: dq 01122334455667788h

46
tool/test.c Normal file
View File

@ -0,0 +1,46 @@
#include <stdio.h>
#include <stdlib.h>
#include "../source/assembler.h"
#include "../source/assembler.c"
static unsigned int array [] = {
ADD, D64, REG, R1, REG, R9,
ADD, D64, REG, R1, MEM, 0,
ADD, D64, REG, R1, IMM, 0X11223344U,
ADD, D64, MEM, 0, REG, R9,
ADD, D64, MEM, 0, IMM, 0X11223344U,
OR, D32, REG, R1, REG, R9,
OR, D32, REG, R1, MEM, 0,
OR, D32, REG, R1, IMM, 0X11223344U,
OR, D32, MEM, 0, REG, R9,
OR, D32, MEM, 0, IMM, 0X11223344U,
ADC, D16, REG, R1, REG, R9,
ADC, D16, REG, R1, MEM, 0,
ADC, D16, REG, R1, IMM, 0X11223344U,
ADC, D16, MEM, 0, REG, R9,
ADC, D16, MEM, 0, IMM, 0X11223344U,
SBB, D8, REG, R1, REG, R9,
SBB, D8, REG, R1, MEM, 0,
SBB, D8, REG, R1, IMM, 0X11223344U,
SBB, D8, MEM, 0, REG, R9,
SBB, D8, MEM, 0, IMM, 0X11223344U
};
int main (void) {
unsigned int index;
token_array = malloc (144UL * sizeof (* token_array));
assemble ((unsigned int) (sizeof (array) / sizeof (array [0])), array);
printf ("> %u\n", token_count);
for (index = 0; index < token_count; ++index) {
printf ("%02X ", token_array [index]);
}
free (token_array);
return (0);
}

43
tool/xfat.c Normal file
View File

@ -0,0 +1,43 @@
/* Ignore this file, it's for my autistic way of testing. -- xolatile */
#include <xolatile/xtandard.c>
#define header \
"#include <stdio.h>\n" \
"#include <stdlib.h>\n" \
"#include \"../source/assembler.h\"\n" \
"#include \"../source/assembler.c\"\n" \
"static unsigned int array [] = { "
#define footer \
"};\n" \
"int main (void) {\n" \
" unsigned int index;\n" \
" token_array = malloc (144UL * sizeof (* token_array));\n" \
" assemble ((unsigned int) (sizeof (array) / sizeof (array [0])), array);\n" \
" for (index = 0; index < token_count; ++index)\n" \
" printf (\"%02X \", token_array [index]);\n" \
" free (token_array);\n" \
" return (0);\n" \
"}\n"
int main (int argc, char * * argv) {
int file, i;
file = file_open ("x.c", O_RDWR | O_CREAT | O_TRUNC);
file_echo (file, header);
for (i = 1; i < argc; ++i) {
file_echo (file, argv [i]);
file_echo (file, ", ");
}
file_echo (file, footer);
file = file_close (file);
execute ("cat x.c && gcc x.c && ./a.out && echo -- && rm a.out x.c");
return (log_success);
}