Cleaned up mess I have made in the toolshed...

This commit is contained in:
xolatile 2024-11-15 03:48:05 -05:00
parent d746cc3586
commit 9c51800d37
17 changed files with 10 additions and 10002 deletions

View File

@ -1,5 +1,4 @@
#include "assembler.h"
#include "debug.h"
#include <stdlib.h>
@ -22,56 +21,6 @@
#define SHIFT_BEGIN (ROL)
#define SHIFT_END (SAR)
#if DEBUG == 1
static const char * size_name [] = {
"d8", "d16", "d32", "d64"
};
static const char * type_name [] = {
"rel", "reg", "mem", "imm"
};
static const char * data_name [] = {
"asmdirmem", "asmdirrel", "asmdirimm", "asmdirrep",
"add", "or", "adc", "sbb",
"and", "sub", "xor", "cmp",
"inc", "dec", "not", "neg",
"mul", "imul", "div", "idiv",
"fadd", "fmul", "fcom", "fcomp",
"fsub", "fsubr", "fdiv", "fdivr",
"rol", "ror", "rcl", "rcr",
"sal", "shr", "shl", "sar",
"nop", "retn", "retf", "leave",
"popf", "pushf",
"syscall", "cpuid", "fnop", "fchs",
"fabs", "ftst", "fxam", "fld1",
"fldl2t", "fldl2e", "fldpi", "fldlg2",
"fldln2", "fldz", "f2xm1", "fyl2x",
"fptan", "fpatan", "fxtract", "fprem1",
"fdecstp", "fincstp", "fprem", "fyl2xp1",
"fsqrt", "fsincos", "frndint", "fscale",
"fsin", "fcos",
"enter", "call", "in", "out",
"jmp", "mov", "pop", "push",
"jo", "jno", "jb", "jae",
"je", "jne", "jbe", "ja",
"js", "jns", "jpe", "jpo",
"jl", "jge", "jle", "jg",
"cmovo", "cmovno", "cmovb", "cmovae",
"cmove", "cmovne", "cmovbe", "cmova",
"cmovs", "cmovns", "cmovpe", "cmovpo",
"cmovl", "cmovge", "cmovle", "cmovg",
"seto", "setno", "setb", "setae",
"sete", "setne", "setbe", "seta",
"sets", "setns", "setpe", "setpo",
"setl", "setge", "setle", "setg",
"bswap", "bsf", "bsr", "loop",
"loope", "loopne"
};
#endif
static unsigned int empty_count = 1;
static unsigned int empty_holes = 1;
static unsigned int * empty_array = NULL;
@ -111,8 +60,6 @@ static void inset_memory (int when, unsigned int size, unsigned int data, unsign
static unsigned int store_relative (unsigned int * array) {
unsigned int relative = array [1];
debug_printf ("> %s %u", data_name [array [0]], array [1]);
empty_array [empty_holes] = text_sector_size;
empty_imbue [empty_holes] = relative;
@ -124,8 +71,6 @@ static unsigned int store_relative (unsigned int * array) {
static unsigned int store_memory (unsigned int * array) {
unsigned int memory = array [1];
debug_printf ("> %s %u", data_name [array [0]], array [1]);
empty_store [memory] = text_sector_size;
++empty_count;
@ -138,8 +83,6 @@ static unsigned int store_immediate (unsigned int * array) {
size = array [1],
amount = array [2];
debug_printf ("> %s %s %u", data_name [array [0]], size_name [array [1]], array [2]);
for (index = 0; index < amount; ++index) {
inset_immediate (1, size, array [3 + index]);
}
@ -195,8 +138,6 @@ static unsigned int build_double (unsigned int * array) {
from = array [4],
source = array [5];
debug_printf ("> %s %s %s %u %s %u", data_name [array [0]], size_name [array [1]], type_name [array [2]], array [3], type_name [array [4]], array [5]);
short_prefix (size);
long_prefix (size, to, destination, from, source);
@ -230,8 +171,6 @@ static unsigned int build_single (unsigned int * array) {
to = array [2],
destination = array [3];
debug_printf ("> %s %s %s %u", data_name [array [0]], size_name [array [1]], type_name [array [2]], array [3]);
short_prefix (size);
long_prefix (size, to, destination, 0, 0);
@ -256,8 +195,6 @@ static unsigned int build_static_1 (unsigned int * array) {
0x90, 0xc3, 0xcb, 0xc9, 0x9d, 0x9c
};
debug_printf ("> %s", data_name [array [0]]);
inset (1, data [operation - STATIC_1_BEGIN]);
return (0);
@ -273,8 +210,6 @@ static unsigned int build_static_2 (unsigned int * array) {
0xfad9, 0xfbd9, 0xfcd9, 0xfdd9, 0xfed9, 0xffd9
};
debug_printf ("> %s", data_name [array [0]]);
inset_immediate (1, D16, data [operation - STATIC_2_BEGIN]);
return (0);
@ -285,8 +220,6 @@ static unsigned int build_jump_if (unsigned int * array) {
size = array [1],
location = array [3];
debug_printf ("> %s %s rel %u", data_name [array [0]], size_name [array [1]], array [3]);
inset (far (location) && (size == D32), 0x0f);
inset (far (location), 0x80 + operation - JUMP_IF_BEGIN);
@ -305,8 +238,6 @@ static unsigned int build_move_if (unsigned int * array) {
from = array [4],
source = array [5];
debug_printf ("> %s %s %s %u %s %u", data_name [array [0]], size_name [array [1]], type_name [array [2]], array [3], type_name [array [4]], array [5]);
short_prefix (size);
long_prefix (size, to, destination, from, source);
@ -325,8 +256,6 @@ static unsigned int build_set_if (unsigned int * array) {
to = array [2],
destination = array [3];
debug_printf ("> %s d8 %s %u", data_name [array [0]], type_name [array [2]], array [3]);
inset ((to == REG) && (front (destination)), 0x40);
inset ((to == REG) && (upper (destination)), 0x41);
@ -346,8 +275,6 @@ static unsigned int build_jump (unsigned int * array) {
to = array [2],
destination = array [3];
debug_printf ("> %s %s %s %u", data_name [array [0]], size_name [array [1]], type_name [array [2]], array [3]);
inset ((to == REG) && upper (destination), 0X41);
inset (to == REL, 0xe9 + 0x02 * (size == D8));
@ -370,8 +297,6 @@ static unsigned int build_move (unsigned int * array) {
source = array [5],
extension = array [6];
debug_printf ("> %s %s %s %u %s %u %u", data_name [array [0]], size_name [array [1]], type_name [array [2]], array [3], type_name [array [4]], array [5], (size == D64) ? array [6] : 0);
short_prefix (size);
long_prefix (size, to, destination, from, source);
@ -408,8 +333,6 @@ static unsigned int build_call (unsigned int * array) {
unsigned int from = array [1],
source = array [2];
debug_printf ("> %s %s %u", data_name [array [0]], type_name [array [1]], array [2]);
inset ((from == REG) && (upper (source)), 0x41);
inset (from == REL, 0xe8);
@ -426,8 +349,6 @@ static unsigned int build_enter (unsigned int * array) {
unsigned int dynamic_storage = array [1],
nesting_level = array [2];
debug_printf ("> %s %u %u", data_name [array [0]], array [1], array [2]);
inset (1, 0xc8);
inset_immediate (1, D16, dynamic_storage);
@ -442,8 +363,6 @@ static unsigned int build_float (unsigned int * array) {
from = array [2],
source = array [3];
debug_printf ("> %s %s %s %u", data_name [array [0]], size_name [array [1]], type_name [array [2]], array [3]);
inset (from == MEM, 0xd8 + 0x04 * (size == D64));
modify_memory (operation, 0, from);
@ -460,8 +379,6 @@ static unsigned int build_shift (unsigned int * array) {
destination = array [3],
offset = array [5];
debug_printf ("> %s %s %s %u imm %u", data_name [array [0]], size_name [array [1]], type_name [array [2]], array [3], array [5]);
short_prefix (size);
long_prefix (size, to, destination, 0, 0);
@ -483,8 +400,6 @@ static unsigned int build_in_out (unsigned int * array) {
type = array [2],
port = array [3];
debug_printf ("> %s %s %s %u", data_name [array [0]], size_name [array [1]], type_name [array [2]], array [3]);
short_prefix (size);
inset (1, 0xe4 + 0x01 * (size != D8) + 0x02 * (move != OUT) + 0x08 * (type == REG));
@ -499,8 +414,6 @@ static unsigned int build_pop (unsigned int * array) {
to = array [2],
destination = array [3];
debug_printf ("> %s %s %s %u", data_name [array [0]], size_name [array [1]], type_name [array [2]], array [3]);
short_prefix (size);
inset ((to == REG) && (upper (destination)), 0x41);
@ -519,8 +432,6 @@ static unsigned int build_push (unsigned int * array) {
from = array [2],
source = array [3];
debug_printf ("> %s %s %s %u", data_name [array [0]], size_name [array [1]], type_name [array [2]], array [3]);
short_prefix (size);
inset ((from == REG) && (upper (source)), 0x41);
@ -540,8 +451,6 @@ static unsigned int build_swap (unsigned int * array) {
unsigned int size = array [1],
destination = array [3];
debug_printf ("> %s %s reg %u", data_name [array [0]], size_name [array [1]], array [3]);
long_prefix (size, REG, destination, 0, 0);
inset (1, 0x0f);
@ -556,8 +465,6 @@ static unsigned int build_bit_scan (unsigned int * array) {
from = array [4],
source = array [5];
debug_printf ("> %s %s reg %u %s %u", data_name [array [0]], size_name [array [1]], array [3], type_name [array [4]], array [5]);
short_prefix (size);
long_prefix (size, REG, destination, from, source);
@ -576,8 +483,6 @@ static unsigned int build_bit_scan (unsigned int * array) {
static unsigned int build_loop (unsigned int * array) {
unsigned int location = array [3];
debug_printf ("> %s d8 rel %u", data_name [array [0]], array [3]);
inset (array [0] == LOOPNE, 0xe0);
inset (array [0] == LOOPE, 0xe1);
inset (array [0] == LOOP, 0xe2);
@ -630,20 +535,7 @@ int assemble (unsigned int count, unsigned int * array) {
empty_store = calloc (1024UL, sizeof (* empty_store));
for (index = 0; index < count; ++index) {
unsigned int check_at;
unsigned int byte;
#if DEBUG == 1
inset (array [index] > ASMDIRREP, 0x90);
#endif
check_at = text_sector_size;
index += build_instruction [array [index]] (& array [index]);
for (byte = check_at; byte < text_sector_size; ++byte) {
debug_printf ("%02X ", text_sector_byte [byte]);
}
}
text_entry_point = empty_store [0];

View File

@ -1,6 +1,5 @@
#include "assembler.h"
#include "unix.h"
#include "debug.h"
#include <string.h>
@ -45,8 +44,6 @@ void elf_main_header(unsigned char has_program,
elf_main_header_byte[18] = (for_x86_64) ? 0x3e : 0x00;
memcpy(& elf_main_header_byte[24], & enter, sizeof(enter));
debug_printf("UNX -- ELF64 main header\n");
}
void elf_text_sector(unsigned long text_size,
@ -55,8 +52,6 @@ void elf_text_sector(unsigned long text_size,
memcpy(& elf_text_sector_byte[32], & text, sizeof(text));
memcpy(& elf_text_sector_byte[40], & text, sizeof(text));
debug_printf("UNX -- ELF64 text sector\n");
}
void elf_data_sector(unsigned long text_size,
@ -70,6 +65,4 @@ void elf_data_sector(unsigned long text_size,
memcpy(& elf_data_sector_byte[24], & move, sizeof(move));
memcpy(& elf_data_sector_byte[32], & data, sizeof(data));
memcpy(& elf_data_sector_byte[40], & data, sizeof(data));
debug_printf("UNX -- ELF64 data sector\n");
}

View File

@ -1,80 +0,0 @@
#include <stdio.h>
static char * fa [] = {
"add", "or", "adc", "sbb", "and", "sub", "xor", "cmp"
};
static char * faa [] = {
"inc", "dec", "not", "neg", "mul", "imul", "div", "idiv"
};
static char * fr [] = {
"al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil",
"r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b",
"ax", "cx", "dx", "bx", "sp", "bp", "si", "di",
"r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w",
"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi",
"r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d",
"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
};
static char * fm [] = {
"byte[b]", "word[w]", "dword[d]", "qword[q]",
};
static char * fi [] = {
"11h", "1122h", "11223344h", "11223344h"
};
int main (void) {
int a, w, t, d, f, s;
printf ("format ELF64 executable 3\n");
printf ("segment readable executable\n");
printf ("entry $\n");
printf ("nop\n");
printf ("nop\n");
printf ("nop\n");
// INR REG REG
for (a = 0; a < (int) (sizeof (fa) / sizeof (* fa)); ++a) {
for (w = 0; w < 4; ++w) {
for (d = 0; d < 16; ++d) {
for (s = 0; s < 16; ++s) {
printf ("nop\n");
printf ("%s %s, %s\n", fa [a], fr [d + 16 * w], fr [s + 16 * w]);
}
}
}
}
// INR REG IMM
for (a = 0; a < (int) (sizeof (fa) / sizeof (* fa)); ++a) {
for (d = 0; d < 64; ++d) {
printf ("nop\n");
printf ("%s %s, %s\n", fa [a], fr [d], fi [d / 16]);
}
}
// INI REG
for (a = 0; a < (int) (sizeof (faa) / sizeof (* faa)); ++a) {
for (w = 0; w < 4; ++w) {
for (d = 0; d < 16; ++d) {
printf ("nop\n");
printf ("%s %s\n", faa [a], fr [d + 16 * w]);
}
}
}
printf ("nop\n");
printf ("nop\n");
printf ("nop\n");
printf ("segment readable writable\n");
printf ("b: db 0\n");
printf ("w: dw 0\n");
printf ("d: dd 0\n");
printf ("q: dq 0\n");
return (0);
}

View File

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

View File

@ -1,72 +0,0 @@
format ELF64
public _start
section '.text' executable
_start:
fff:
nop
mov eax, 1
nop
mov edi, 1
nop
mov esi, heyo
nop
mov edx, 12
nop
syscall
nop
nop
nop
mov rax, 1122334455667788h
nop
mov rcx, 1122334455667788h
nop
mov rdx, 1122334455667788h
nop
mov rbx, 1122334455667788h
nop
mov rsp, 1122334455667788h
nop
mov rbp, 1122334455667788h
nop
mov rsi, 1122334455667788h
nop
mov rdi, 1122334455667788h
nop
mov r8, 1122334455667788h
nop
mov r9, 1122334455667788h
nop
mov r10, 1122334455667788h
nop
mov r11, 1122334455667788h
nop
mov r12, 1122334455667788h
nop
mov r13, 1122334455667788h
nop
mov r14, 1122334455667788h
nop
mov r15, 1122334455667788h
nop
nop
nop
mov eax, 60
nop
mov edi, 0
nop
syscall
nop
jmp fff
nop
nop
nop
section '.data' writable
heyo: db "heyo world!", 10

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +0,0 @@
; @BAKE fasm $@ $*.out
format ELF64 executable 3
segment readable executable
entry $
redo:
mov eax, 1
mov edi, 1
mov esi, heyo
mov edx, 4
syscall
jmp redo
segment readable writable
heyo: db "heyo", 4

View File

@ -1,17 +0,0 @@
#!/bin/bash
set -xe
gcc -o flatten flatten.c
gcc -o xlatten xlatten.c
./flatten > flatten.asm
./xlatten > include.txt
fasm flatten.asm flatten.exe
./nop flatten.exe > flatten.txt
gcc -o test test.c
./test > xlatten.txt
exit

View File

@ -1,27 +0,0 @@
format ELF64 executable 3
; fasm multiply.asm multiply
; chmod +x multiply
; ./multiply
; echo $?
; > 24
segment readable executable
entry $
mov eax, [a]
mov ecx, [b]
mul ecx
mov [c], eax
; exit (c);
mov eax, 60
mov edi, [c]
syscall
segment readable writable
a: dd 4
b: dd 6
c: dd 0; Expecting 24.

View File

@ -1,39 +0,0 @@
#include <xolatile/xtandard.c>
int main (int argc, char * * argv) {
int file = -1;
int size = 0;
int offset = 0;
unsigned char * buffer = NULL;
file = file_open (argv [1], O_RDONLY);
size = file_size (argv [1]);
buffer = allocate (size);
file_read (file, buffer, size);
file = file_close (file);
offset = 64 + 2 * 56 + 3;
do {
int byte = (int) buffer [offset];
if (byte == 0X90) {
echo ("\n");
echo_byte ((int) buffer [offset]);
} else {
echo_byte (buffer [offset]);
}
++offset;
} while (offset != size);
echo ("\n");
buffer = deallocate (buffer);
return (EXIT_SUCCESS);
}

View File

@ -1,6 +1,4 @@
/* Ignore this file, it's for my autistic way of testing. -- xolatile */
#include <xolatile/xtandard.c>
#include <xolatile/xtandard.h>
int main (int argc, char * * argv) {
int file, i;

View File

@ -1,223 +0,0 @@
format ELF64 executable 3
segment readable executable
entry $
nop
nop
nop
fff:
nop
add rcx, r9
nop
add rcx, [x8]
nop
add rcx, 11223344h
nop
add [x8], rcx
nop
add qword[x8], 11223344h
nop
or ecx, r9d
nop
or ecx, [x4]
nop
or ecx, 11223344h
nop
or [x4], ecx
nop
or dword[x4], 11223344h
nop
adc cx, r9w
nop
adc cx, [x2]
nop
adc cx, 1122h
nop
adc [x2], cx
nop
adc word[x2], 1122h
nop
sbb cl, r9b
nop
sbb cl, [x1]
nop
sbb cl, 11h
nop
sbb [x1], cl
nop
sbb byte[x1], 11h
nop
and rcx, r9
nop
and rcx, [x8]
nop
and rcx, 11223344h
nop
and [x8], rcx
nop
and qword[x8], 11223344h
nop
sub ecx, r9d
nop
sub ecx, [x4]
nop
sub ecx, 11223344h
nop
sub [x4], ecx
nop
sub dword[x4], 11223344h
nop
xor cx, r9w
nop
xor cx, [x2]
nop
xor cx, 1122h
nop
xor [x2], cx
nop
xor word[x2], 1122h
nop
cmp cl, r9b
nop
cmp cl, [x1]
nop
cmp cl, 11h
nop
cmp [x1], cl
nop
cmp byte[x1], 11h
nop
inc rcx
nop
inc qword[x8]
nop
inc ecx
nop
inc dword[x4]
nop
inc cx
nop
inc word[x2]
nop
inc cl
nop
inc byte[x1]
nop
div r9
nop
div qword[x8]
nop
div r9d
nop
div dword[x4]
nop
div r9w
nop
div word[x2]
nop
div r9b
nop
div byte[x1]
nop
ret
nop
leave
nop
lock
nop
hlt
nop
sysenter
nop
sysexit
nop
syscall
nop
sysret
nop
pause
nop
cpuid
nop
jo fff
nop
jno fff
nop
jb fff
nop
jae fff
nop
je fff
nop
jne fff
nop
jbe fff
nop
ja fff
nop
js fff
nop
jns fff
nop
jpe fff
nop
jpo fff
nop
jl fff
nop
jge fff
nop
jle fff
nop
jg fff
nop
cmovo rax, rcx
nop
cmovno rax, rcx
nop
cmovb rax, rcx
nop
cmovae rax, rcx
nop
cmove rax, rcx
nop
cmovne rax, rcx
nop
cmovbe rax, rcx
nop
cmova rax, rcx
nop
cmovs rax, rcx
nop
cmovns rax, rcx
nop
cmovpe rax, rcx
nop
cmovpo rax, rcx
nop
cmovl rax, rcx
nop
cmovge rax, rcx
nop
cmovle rax, rcx
nop
cmovg rax, rcx
;~;mov
;~;jmp
nop
nop
nop
nop
segment readable writable
x1: db 011h
x2: dw 01122h
x4: dd 011223344h
x8: dq 01122334455667788h

View File

@ -1,25 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include "../source/assembler.h"
#include "../source/assembler.c"
static unsigned int array [] = {
#include "include.txt"
};
int main (void) {
unsigned int index;
text_sector_byte = malloc (1024UL * 1024UL * sizeof (* text_sector_byte));
assemble ((unsigned int) (sizeof (array) / sizeof (array [0])), array);
for (index = 0; index < text_sector_size; ++index) {
printf ("%c%02X", (text_sector_byte [index] == 0x90) ? '\n' : ' ', text_sector_byte [index]);
}
free (text_sector_byte);
return (0);
}

View File

@ -1,10 +0,0 @@
#!/bin/bash
set -xe
#~diff -y -W 40 --ignore-trailing-space --ignore-blank-lines --suppress-common-lines --color=always flatten.txt xlatten.txt
#~diff -y -W 40 --ignore-trailing-space --ignore-blank-lines --color=always flatten.txt xlatten.txt
#~diff -y flatten.txt xlatten.txt
diff flatten.txt xlatten.txt
exit

View File

@ -1,68 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include "../source/assembler.h"
#include "../source/assembler.c"
#include "../source/unix.h"
#include "../source/unix.c"
static unsigned int array [] = {
NOP, MOV, D32, REG, R0, IMM, 1,
NOP, MOV, D32, REG, R7, IMM, 1,
NOP, MOV, D32, REG, R6, REL, 0,
NOP, MOV, D32, REG, R2, IMM, 12,
NOP, SYSCALL,
NOP, MOV, D32, REG, R0, IMM, 1,
NOP, MOV, D32, REG, R7, IMM, 1,
NOP, MOV, D32, REG, R6, REL, 1,
NOP, MOV, D32, REG, R2, IMM, 20,
NOP, SYSCALL,
NOP, CALL, REL, 3,
NOP, MOV, D32, REG, R0, IMM, 1,
NOP, MOV, D32, REG, R7, IMM, 1,
NOP, MOV, D32, REG, R6, REL, 2,
NOP, MOV, D32, REG, R2, IMM, 12,
NOP, SYSCALL,
NOP, MOV, D32, REG, R0, IMM, 60,
NOP, MOV, D32, REG, R7, IMM, 60,
NOP, SYSCALL,
ASMDIRMEM, 3,
NOP, MOV, D32, REG, R0, IMM, 1,
NOP, MOV, D32, REG, R7, IMM, 1,
NOP, MOV, D32, REG, R6, REL, 0,
NOP, MOV, D32, REG, R2, IMM, 12,
NOP, SYSCALL,
NOP, RETN,
NOP,
ASMDIRMEM, 0,
ASMDIRIMM, D8, 12, 72, 101, 121, 111, 32, 119, 111, 114, 108, 100, 33, 10,
ASMDIRMEM, 1,
ASMDIRIMM, D8, 20, 67, 121, 97, 97, 32, 102, 117, 99, 107, 105, 110,
103, 32, 119, 111, 114, 108, 100, 33, 10,
ASMDIRMEM, 2,
ASMDIRIMM, D8, 12, 77, 101, 109, 101, 32, 119, 111, 114, 108, 100, 33, 10
};
int main (void) {
FILE * file = NULL;
file = fopen ("run_me_please", "w+");
assemble ((unsigned int) (sizeof (array) / sizeof (array [0])), array);
elf_main_header (1, 1, 1, 0);
elf_text_sector (text_sector_size);
elf_data_sector (text_sector_size, 36+8);
fwrite (elf_main_header_byte, 1UL, ELF_MAIN_HEADER_SIZE, file);
fwrite (elf_text_sector_byte, 1UL, ELF_TEXT_SECTOR_SIZE, file);
fwrite (elf_data_sector_byte, 1UL, ELF_DATA_SECTOR_SIZE, file);
printf ("> %u\n", (unsigned int) (sizeof (array) / sizeof (array [0])));
fwrite (text_sector_byte, 1UL, (size_t) text_sector_size, file);
fclose (file);
return (0);
}

View File

@ -1,21 +1,21 @@
/* Ignore this file, it's for my autistic way of testing. -- xolatile */
#include <xolatile/xtandard.h>
#include <xolatile/xtandard.c>
#define header \
"#include <stdio.h>\n" \
"#include <stdlib.h>\n" \
"#include \"../source/assembler.h\"\n" \
"#include \"../source/assembler.c\"\n" \
#define header \
"#include <stdio.h>\n" \
"#include <stdlib.h>\n" \
"#include \"/home/xolatile/Git/eaxcc/source/assembler.h\"\n" /* LNAO L: */ \
"#include \"/home/xolatile/Git/eaxcc/source/assembler.c\"\n" /* LNAO L: */ \
"static unsigned int array [] = { "
#define footer \
"};\n" \
"int main (void) {\n" \
" unsigned int index;\n" \
" text_sector_byte = calloc (1024ul, 1ul);\n" \
" assemble ((unsigned int) (sizeof (array) / sizeof (array [0])), array);\n" \
" for (index = 0; index < text_sector_size; ++index)\n" \
" printf (\"%02X \", text_sector_byte [index]);\n" \
" free (text_sector_byte);\n" \
" return (0);\n" \
"}\n"
@ -35,7 +35,7 @@ int main (int argc, char * * argv) {
file = file_close (file);
execute ("gcc x.c && ./a.out && echo -- && rm a.out x.c");
execute ("gcc -g x.c && ./a.out && echo -- && rm a.out x.c");
return (log_success);
}

View File

@ -1,54 +0,0 @@
#include <stdio.h>
static char * fw [] = {
"D8", "D16", "D32", "D64"
};
static char * fa [] = {
"ADD", "OR", "ADC", "SBB", "AND", "SUB", "XOR", "CMP"
};
static char * faa [] = {
"INC", "DEC", "NOT", "NEG", "UMUL", "IMUL", "UDIV", "IDIV"
};
static char * fr [] = {
"REG, R0", "REG, R1", "REG, R2", "REG, R3", "REG, R4", "REG, R5", "REG, R6", "REG, R7",
"REG, R8", "REG, R9", "REG, R10", "REG, R11", "REG, R12", "REG, R13", "REG, R14", "REG, R15"
};
static char * fi [] = {
"IMM, 0x11", "IMM, 0x1122", "IMM, 0x11223344", "IMM, 0x11223344"
};
int main (void) {
int a, w, t, d, f, s;
for (a = 0; a < (int) (sizeof (fa) / sizeof (* fa)); ++a) {
for (w = 0; w < 4; ++w) {
for (d = 0; d < 16; ++d) {
for (s = 0; s < 16; ++s) {
printf ("NOP, %s, %s, %s, %s,\n", fa [a], fw [w], fr [d], fr [s]);
}
}
}
}
for (a = 0; a < (int) (sizeof (fa) / sizeof (* fa)); ++a) {
for (w = 0; w < 4; ++w) {
for (d = 0; d < 16; ++d) {
printf ("NOP, %s, %s, %s, %s,\n", fa [a], fw [w], fr [d], fi [w]);
}
}
}
for (a = 0; a < (int) (sizeof (faa) / sizeof (* faa)); ++a) {
for (w = 0; w < 4; ++w) {
for (d = 0; d < 16; ++d) {
printf ("NOP, %s, %s, %s,\n", faa [a], fw [w], fr [d]);
}
}
}
return (0);
}