Calling convention - Output explanation

This commit is contained in:
2026-03-04 18:30:32 -06:00
parent bad91d3b19
commit 6268b356aa
3 changed files with 52 additions and 28 deletions

View File

@@ -1,3 +1,3 @@
# lopez-repo # lopez-repo
Spider Internship Spider Internship

View File

@@ -1,27 +1,27 @@
# Spider Programming Language # Spider Programming Language
Spider is a lightweight scripting language designed to be simple to build, Spider is a lightweight scripting language designed to be simple to build,
easy to embed, and straightforward to learn. easy to embed, and straightforward to learn.
## Why Spider? ## Why Spider?
Most modern scripting languages have become increasingly complex over time. Most modern scripting languages have become increasingly complex over time.
Spider was created to solve three main problems: Spider was created to solve three main problems:
- **Hard to embed:** Languages like Lua have verbose APIs and JavaScript - **Hard to embed:** Languages like Lua have verbose APIs and JavaScript
interpreters are massive projects that take hours to compile. interpreters are massive projects that take hours to compile.
- **Poor interoperability:** Python and Lua make it complicated to communicate - **Poor interoperability:** Python and Lua make it complicated to communicate
between the script and the host application. between the script and the host application.
- **Outdated syntax:** Spider aims for a clean, modern syntax without - **Outdated syntax:** Spider aims for a clean, modern syntax without
requiring keywords like `end` or relying on indentation for structure. requiring keywords like `end` or relying on indentation for structure.
## How it works ## How it works
Spider compiles down to bytecode that runs on the Spider Virtual Machine (VM). Spider compiles down to bytecode that runs on the Spider Virtual Machine (VM).
The VM is written in C and can be compiled with a single Makefile, making it The VM is written in C and can be compiled with a single Makefile, making it
easy to port to any platform, including microcontrollers like the ATmega328p. easy to port to any platform, including microcontrollers like the ATmega328p.
## Current Status ## Current Status
Currently in early development. The VM architecture, instruction set, Currently in early development. The VM architecture, instruction set,
register table, and calling convention have been defined and are being tested. register table, and calling convention have been defined and are being tested.

View File

@@ -0,0 +1,24 @@
# Calling Convention — Output Explanation
This document explains the output of the calling convention algorithm
implemented in `calling-convention.ipynb`, tested across 3 scenarios.
---
## TEST 1: A single 1-byte argument
**Function signature:** `result = func(x)` where `x` is 8 bits (1 byte)
**Output:**
```
===== TEST 1: a 1 byte argument =====
=== State after do_function_call ===
Registers used: ['RA']
Stack: [{'type': 'caller_saved', 'reg': 'R0', 'value': 0}, {'type': 'caller_saved', 'reg': 'R1', 'value': 0}, {'type': 'caller_saved', 'reg': 'R2', 'value': 0}, {'type': 'caller_saved', 'reg': 'R3', 'value': 0}]
RS points to: 4
=== State after undo_function_call ===
Clean stack: []
RS: 0
Collected result: {'result': {'type': 'result', 'value': 42}}