diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4a3a44e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/spider-tests.code-workspace diff --git a/calling-convention/calling-convention.ipynb b/calling-convention/calling-convention.ipynb new file mode 100644 index 0000000..3a4fe35 --- /dev/null +++ b/calling-convention/calling-convention.ipynb @@ -0,0 +1,144 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "1c7a11d9", + "metadata": {}, + "source": [ + "This test will test (lol) the calling convention in Spider.\n", + "As defined, it will use the CPU as a python object.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b9c572cd", + "metadata": {}, + "outputs": [], + "source": [ + "# The state of the spider vm in a simple\n", + "# python object abstraction\n", + "spider_vm = {\n", + " 'regs':{\n", + " 'RA':0,\n", + " 'RB':0,\n", + " 'RC':0,\n", + " 'RD':0,\n", + " 'RX':0,\n", + " 'RY':0,\n", + " 'R0':0,\n", + " 'R1':0,\n", + " 'R2':0,\n", + " 'R3':0,\n", + " 'R4':0,\n", + " 'R5':0,\n", + " 'R6':0,\n", + " 'R7':0,\n", + " 'R8':0,\n", + " 'R9':0,\n", + " 'RF':0,\n", + " 'RI':0,\n", + " 'RS':0,\n", + " 'RZ':0,\n", + " 'RE':0,\n", + " 'RH':0,\n", + " 'RV':0,\n", + " 'RM':0,\n", + " },\n", + " 'stack': [],\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a1ddd324", + "metadata": {}, + "outputs": [], + "source": [ + "# Input parameters, measured as bits\n", + "# For simplicity\n", + "# 1 boolean -> 1 bit\n", + "# 1 byte -> 8 bits\n", + "input_params = [ {'name':'asd','size':8} ]\n", + "\n", + "# Define the return types here\n", + "ouput_return = [ {'name':'ret1','size':8} ]" + ] + }, + { + "cell_type": "markdown", + "id": "bbe2c356", + "metadata": {}, + "source": [ + "Now, on this function it will perform the tasks of ordering the registers and stack based on the parameters." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "02a2ad1a", + "metadata": {}, + "outputs": [], + "source": [ + "# TODO!!!\n", + "def do_function_call(input_params:list, output_return:list):\n", + " pass" + ] + }, + { + "cell_type": "markdown", + "id": "ac6440ca", + "metadata": {}, + "source": [ + "Now, unwind the stack and stuff to make sure the machine goes back to its previous state BEFORE the function" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d2e4ce44", + "metadata": {}, + "outputs": [], + "source": [ + "# TODO !!!\n", + "def undo_function_call(input_params:list, output_return:list):\n", + " pass" + ] + }, + { + "cell_type": "markdown", + "id": "5397697f", + "metadata": {}, + "source": [ + "VERY GOOD\n", + "Now check the state of the machine before and after\n", + "\n", + "Try different combinations: One function call, multiple function calls, recursive calls, etc." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b58fbf72", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2860c30b", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}