Skip to content

Commit

Permalink
feat: FrameBunch / __main__
Browse files Browse the repository at this point in the history
Add FrameBunch, spare clean up
  • Loading branch information
squillero committed Aug 24, 2024
1 parent d8ea1d7 commit 1933177
Show file tree
Hide file tree
Showing 90 changed files with 827 additions and 787 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[![PyPI - Version](https://img.shields.io/pypi/v/byron?label=pypi)](https://pypi.org/project/byron/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/byron?label=downloads)](https://pypi.org/project/byron/)

> Build on [MicroGP](https://cad-polito-it.github.io/byron/history) technology
> Built on [MicroGP](https://cad-polito-it.github.io/byron/history) technology
Byron is a source code [fuzzer](https://en.wikipedia.org/wiki/Fuzzing) designed to support assembly and high-level languages. It starts by generating a set of random programs, which are then iteratively improved by an [evolutionary algorithm](https://cad-polito-it.github.io/byron/evolution). Internally, it encodes candidate solutions as [typed](https://rcor.me/papers/typed-graph-theory.pdf), [directed](https://en.wikipedia.org/wiki/Graph_(discrete_mathematics)#Directed_graph) [multigraphs](https://en.wikipedia.org/wiki/Multigraph), and can effectively handle complex, realistic structures containing local and global variables, conditional and looping statements, and subroutines.

Expand Down
2 changes: 1 addition & 1 deletion _experiments/i.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"{inst} {reg}, 0x{imm:04x}",
inst=byron.f.choice_parameter(["add", "sub", "and", "or", "xor"]),
reg=byron.f.choice_parameter(["ax", "bx", "cx", "dx"]),
imm=byron.f.integer_parameter(0, 2**16),
imm=byron.f.integer_parameter(0, 2 ** 16),
)

section_proc = byron.f.sequence(
Expand Down
2 changes: 1 addition & 1 deletion _experiments/mut1.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# byron.rrandom.seed(42)

register = byron.f.choice_parameter(["ah", "bh", "ch", "dh", "al", "bl", "cl", "dl"])
word = byron.f.integer_parameter(0, 2**16)
word = byron.f.integer_parameter(0, 2 ** 16)
int_op = byron.f.choice_parameter(["add", "sub", "and", "or", "xor"])
inst = byron.f.macro("{op} {r}, 0x{v:02x}", op=int_op, r=register, v=word)

Expand Down
4 changes: 2 additions & 2 deletions _experiments/t.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

reg8 = byron.f.choice_parameter(['ah', 'bh', 'ch', 'dh', 'al', 'bl', 'cl', 'dl'])
reg16 = byron.f.choice_parameter(['ax', 'bx', 'cx', 'dx'])
int8 = byron.f.integer_parameter(0, 2**8)
int16 = byron.f.integer_parameter(0, 2**16)
int8 = byron.f.integer_parameter(0, 2 ** 8)
int16 = byron.f.integer_parameter(0, 2 ** 16)

opcodes2 = byron.f.choice_parameter(['mov', 'add', 'sub', 'or', 'and'])
opcodes1 = byron.f.choice_parameter(['not', 'neg', 'inc', 'dec'])
Expand Down
2 changes: 1 addition & 1 deletion _experiments/t2.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
byron.rrandom.seed(42)

register = byron.f.choice_parameter(["ah", "bh", "ch", "dh", "al", "bl", "cl", "dl"])
byte = byron.f.integer_parameter(0, 2**8)
byte = byron.f.integer_parameter(0, 2 ** 8)
# test_10 = byron.f.integer_parameter(1, 10)
# test_byte = byron.f.integer_parameter(0, 255)
# test_byte = byron.f.integer_parameter(2, 65536 + 1)
Expand Down
2 changes: 2 additions & 0 deletions examples/classics/knapsack.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
MAX_WEIGHT = 50
WEIGHTS = [31, 10, 20, 19, 4, 3, 6]
VALUES = [70, 20, 39, 37, 7, 5, 10]


# max value: 107


Expand Down
2 changes: 2 additions & 0 deletions examples/classics/onemax.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def fitness(genotype):


def main():
byron.welcome()

macro = byron.f.macro('{v}', v=byron.f.array_parameter('01', NUM_BITS + 1))
top_frame = byron.f.sequence([macro])

Expand Down
5 changes: 3 additions & 2 deletions examples/gcc/library_arm64.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@

COMMENT = ';'


# Hacked as a blind monkey using <https://godbolt.org/>


def define_frame():
register = byron.f.choice_parameter([f"x{n}" for n in range(4)])
int8 = byron.f.integer_parameter(0, 2**8)
int16 = byron.f.integer_parameter(0, 2**16)
int8 = byron.f.integer_parameter(0, 2 ** 8)
int16 = byron.f.integer_parameter(0, 2 ** 16)

# operations_rrr = byron.f.choice_parameter(['add', 'sub', 'and', 'eon', 'eor'])
operations_rrr = byron.f.choice_parameter(['add', 'sub'])
Expand Down
2 changes: 1 addition & 1 deletion examples/gcc/library_x86_64.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def define_frame():
"""
)

op = byron.f.macro(" movl ${val:#x}, %eax", val=byron.f.integer_parameter(0, 2**32))
op = byron.f.macro(" movl ${val:#x}, %eax", val=byron.f.integer_parameter(0, 2 ** 32))

core = byron.framework.bunch(op, size=(10, 50 + 1))
return byron.framework.sequence([prologue, core, epilogue])
2 changes: 1 addition & 1 deletion examples/golang/golang.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def framework():
# 'version', 'system', 'machine', 'python', and 'networkx'
# To get all information use the macro 'byron.f.Info'

int64 = byron.f.integer_parameter(0, 2**64)
int64 = byron.f.integer_parameter(0, 2 ** 64)
math_op = byron.f.choice_parameter(['+', '-', '*', '/', '&', '^', '|'])
variable = byron.f.macro('var {_node} uint64', _label='')
# variable.force_parent('prologue')
Expand Down
2 changes: 1 addition & 1 deletion examples/mips/library_mips.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

def define_frame():
register = byron.f.choice_parameter([f"${x}" for x in range(4, 27)])
int8 = byron.f.integer_parameter(0, 2**8)
int8 = byron.f.integer_parameter(0, 2 ** 8)

operations_rrr = byron.f.choice_parameter(['add', 'sub', 'addu', 'subu'])
operations_rri = byron.f.choice_parameter(['addi', 'addiu'])
Expand Down
Loading

0 comments on commit 1933177

Please sign in to comment.