www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

index.html (4163B)


      1 <!DOCTYPE html>
      2 <html>
      3 	<head>
      4 		<title>banna - ramblings</title>
      5 		<meta name="viewport" content="width=device-width, initial-scale=1">
      6 		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      7 		<link rel="stylesheet" href="/styles/style.css" />
      8 		<link rel="stylesheet" href="/styles/look.css" />
      9 		<link rel="stylesheet" href="/styles/codetheme.css" />
     10 		<script src="/scripts/highlight.js"></script>
     11 		<script>hljs.initHighlightingOnLoad();</script>
     12 	</head>
     13 
     14 	<body>
     15 		<div id="sidebar">
     16 			<div id="logo">
     17 				<a href="/">
     18 					<img src="/banna.png" alt="banna.tech" height="45" width="201" />
     19 				</a>
     20 			</div>
     21 			<div id="nav">
     22 				<a class="current" href="/post">blog</a>
     23 				<a class="" href="/things">things</a>
     24 				<a class="" href="/about">about</a>
     25 			</div>
     26 		</div>
     27 
     28 		<div id="wrapper">
     29 			<div id="content">
     30 <div class="post">
     31     <a href="/post/ramblings_on_the_toy_language_part_1" class="link"><h1 class="header">Ramblings on the Toy Language Part 1</h1></a>
     32     <span class="date">Posted on February, 21 2016</span>
     33     <div class="content">
     34 <p>Since the slow beginning of my senior year, I've been slowly laying out the foundations of my toy language's VM. Much like how you would implement a real machine, or any functioning system, is the fact that it can be interpreted as smaller, individual components that work together. Once you have a rough layout of the individual components and how they interact, you can implement unit tests on each component you make and ensure their behavior via comprehensive tests. Of course, certain components are more reusable than others. For this installment, I'm going to be talking about the instruction interpreter. </p>
     35 <h2>The Instruction Interpreter</h2>
     36 <p>This is the unit that takes a series of bytes and giving them a meaning to the machine. Instructions are single-byte opcodes, with varying length arguements depending on the opcodes definition. For example, a binary addition operator such as ADD, has 0 parameters, thus the instruction is exactly 1 byte in length. On the other hand, operators such as GOTO require an address parameter. This makes its length 1 byte for the opcode, and the length of how many bytes it takes to represent an address. For example, the mnemonic way to write the expression is as follows:</p>
     37 <pre><code>GOTO 0x04
     38 </code></pre>
     39 <p>The above instruction implies that the address space 'width' in bytes is 1, so this instruction would take <code>1 (opcode length) +  1 (arguement length) = 2 bytes</code>. This width implication must be defined pre-execution during the initialization of the interpreter.</p>
     40 <p>The instruction interpreter would have to lookup the metadata associated with the particular instruction to correctly load the correct values into references in memory. Much like how you read a book and remember important 'keyed' bits of information that chain together a story, the instruction interpreter allows the program to interpret the words of the story to be put into memory; but more on memory later. There's a few more important points that we must cover here.</p>
     41 <p>Once this is done, the instructions must be traverseable by address. This will be required by the 'Program Counter'. A program counter is a unit that keeps track of the current instruction being interpreted. It must increment/decrement, and branch to arbitrary locations in memory, invoked by instructions like <code>GOTO</code>.</p>
     42 <p>On top of the instruction interpreter, the logic that actually implements the definition of every single opcode must be present. Along with the logic, there are many interfaces it must communicate with that implement architecture-specific functions and external library calls.</p>
     43 <p><img alt="Helpful diagram" src="//i.banna.tech/180blog.png" /></p>
     44 <h2>Conclusion</h2>
     45 <p>That's one small part of the big picture. The instruction interpreter covers a critical &amp; fundamental part of the problem of getting a machine to compute. Further iterations of these posts rambling about components will continue when I get the time to type out my thoughts.</p>
     46     </div>
     47 </div>
     48 
     49 
     50 			</div>
     51 		</div>
     52 	</body>
     53 </html>