<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bitsy Interpreter Manual</title>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
background-color: #f9f9f9;
margin: 0;
padding: 0;
}
header {
background: #333;
color: #fff;
padding: 10px 20px;
text-align: center;
}
main {
padding: 20px;
}
code {
background: #eee;
padding: 2px 4px;
font-family: Consolas, monospace;
border-radius: 3px;
font-weight: bold;
color: black;
}
pre {
background: #eee;
padding: 10px;
overflow: auto;
border-radius: 5px;
}
</style>
</head>
<body>
<header>
<h1>Bitsy Interpreter Manual</h1>
</header>
<main>
<section>
<h2>Introduction</h2>
<p>The Bitsy interpreter is a lightweight procedural scripting engine for simple programs. This document serves as a guide to its usage, syntax, and features.</p>
</section>
<section>
<h2>Usage</h2>
<p>The interpreter expects input from a file and produces output to a file. Run the program as follows:</p>
<pre>bitsy.exe < script.in > script.out</pre>
</section>
<section>
<h2>Key Features</h2>
<ul>
<li>Supported keywords: <code>IF</code>, <code>JMP</code>, <code>RET</code>, <code>PRN</code>.</li>
<li>Built-in variables: <code>B</code> through <code>Z</code>.</li>
<li>Variable <code>A</code> is reserved for arrays and not available for general use.</li>
<li>Basic arithmetic and logical operations are supported.</li>
</ul>
</section>
<section>
<h2>Syntax</h2>
<h3>Labels</h3>
<p>Labels are defined using a period (<code>.</code>) followed by the label name. For example:</p>
<pre>.LABEL_NAME</pre>
<h3>Conditional Statements</h3>
<p>The <code>IF</code> keyword is used for conditional logic. Syntax:</p>
<pre>IF <VAR1> <OPERATOR> <VAR2> <ACTION></pre>
<p>Supported operators: <code><</code>, <code>=</code>.</p>
<p>Example:</p>
<pre>IF B < 10 JMP .NEXT_LABEL</pre>
<h3>Jump</h3>
<p>The <code>JMP</code> keyword transfers control to a label. Syntax:</p>
<pre>JMP .LABEL_NAME</pre>
<h3>Return</h3>
<p>The <code>RET</code> keyword returns control to the previous location saved on the stack.</p>
<h3>Print</h3>
<p>The <code>PRN</code> keyword outputs the value of a variable or its ASCII representation. Example:</p>
<pre>PRN B</pre>
</section>
<h3>Tracing</h3> <p>The <code>TRC</code> command enables trace mode, which displays the program's internal state after execution. This is useful for debugging and understanding program flow.</p> </section>
<section> <h2>Comments</h2> <p>Comments start with a semicolon (<code>;</code>). Everything after the semicolon on a line is ignored by the interpreter. Example:</p> <pre>; This is a comment
<br> B = 5 ; Set variable B to 5</pre> </section>
<section> <h2>Mathematical Operations</h2> <p>The interpreter supports the following mathematical operations:</p> <ul> <li><code>+</code>: Addition</li> <li><code>!</code>: One's complement (bitwise NOT) when applied to a variable</li> </ul> <p>Examples:</p>
<pre>B = 5 + 3 ; Adds 5 and 3, storing the result in B
<br>B = B ! ; Applies bitwise NOT to B</pre> </section>
<section>
<h2>Built-in Variables</h2>
<p>The interpreter provides the following built-in variables:</p>
<ul>
<li><code>B</code> to <code>Q</code>: Store integer values.</li>
<li><code>R</code>: Stores a random number between 0 and the value of <code>R</code>.</li>
<li><code>S</code> to <code>Z</code>: Store ASCII character codes.</li>
</ul>
</section>
<section>
<h2>Error Handling</h2>
<p>The interpreter stops execution upon encountering an error and displays an error message along with the problematic line of code. Enable tracing with the <code>TRC</code> command to debug effectively.</p>
</section>
<section>
<h2>Example Program</h2>
<p>The following program demonstrates a simple counter:</p>
<pre>
TRC
B = 0
.START
B = B + 1
PRN B T
.IF B < 10 JMP .START
</pre>
</section>
</main>
</body>
</html>