ilo
dz / forth / konilo / iloSummary
A study of the C implementation of the ilo virtual machine for Konilo.
Node Tree
- push
- read_block
- save_image
- save_ip
- symmetric
- top
- write_block
- block_common
- global_vars
- instructions
- macros
- mains
- pop
Nodes
top | |
content | Top node, linked with a corresponding zet node. |
2024-04-03 09:47:07 My goal here is understanding this system enough to figure out how to do custom I/O operations. My hope is to be able to send bytes to a virtual machine, similar to what I've been doing with Uxn and GestVM.
2024-04-03 09:47:52 I really want to get to a point where Konilo forth can write bytes. From there, I'll set up some kind of messaging protocol that allows me to communicate with the sndkit/mnolth API.
macros | |
content | a set of single-letter macros. reminds me of abbreviations found in the kona codebase |
children | macro_C, macro_I, macro_T, macro_V |
macro_T | |
content | T: global. top of datastack (sp). |
parents | macro_N, sp, macros, ds |
global_vars | |
content | Global variables |
children | as, rom, blocks, ds, ip, rp, memory, misc_global_vars, sp |
sp | |
content | sp stack pointer variable |
children | macro_N (uses stack pointer), macro_T |
parents | global_vars, load_image_desc |
ip | |
content | ip instruction pointer |
parents | execute_desc, global_vars, load_image_desc |
memory | |
content | m memory |
parents | global_vars, load_image_desc |
macro_N | |
content | N: global. next on data stack. (sp - 1) |
children | macro_T (related) |
parents | ds, sp |
macro_R | |
content | R: top of address stack. (rp) |
parents | rp, as |
ds | |
content | ds: data stack global. integer array size 33. |
children | macro_N, macro_T |
parents | global_vars |
as | |
content | as: address stack. int array size 257 |
children | macro_R |
parents | global_vars |
rp | |
content | rp: address stack pointer. |
children | macro_R |
parents | global_vars, load_image_desc |
remarks | wonder what the "r" stands for? My best guess is that it means "return", as in "return stack pointer". |
macro_V | |
content | V: macro for "void" |
parents | macros |
macro_I | |
content | I: macro for "int" |
parents | macros |
macro_C | |
content | C: macro for "char" |
parents | macros |
blocks | |
content | blocks: name of blocks file (ilo.blocks). |
parents | global_vars |
rom | |
content | rom: name of image (ilo.rom) |
parents | global_vars |
misc_global_vars | |
content | "the other variables are used by the various functions for misc. purposes" |
parents | global_vars |
push | |
content | push() function. takes in one integer value as arg. |
pop | |
content | pop() function. returns int. |
load_image | |
content | load_image() |
children | load_image_desc (description) |
parents | main_desc |
save_image | |
content | save_image() |
block_common | |
content | block_common() |
read_block | |
content | read_block() |
write_block | |
content | write_block() |
save_ip | |
content | save_ip() |
symmetric | |
content | symmetric |
instructions | |
content | instructions |
process | |
content | process() |
children | process_desc (description), io |
parents | process_bundle_desc |
process_bundle | |
content | process_bundle() |
children | process_bundle_desc (description) |
parents | execute_desc |
execute | |
content | execute() |
children | execute_desc (description) |
parents | main_desc |
mains | |
content | main functions (STDLIB vs NOSTDLIB) |
children | main_with_stdlib |
main_with_stdlib | |
content | main() (with standard library) |
children | main_desc (description) |
parents | mains |
main_desc | |
content | Set the blocks/rom global variables, load image, execute the image. |
children | execute, load_image |
parents | main_with_stdlib |
load_image_desc | |
content | Open the file to =f=, read into =m=, zero out =ip=, =sp=, =rp=. |
children | ip, rp, memory, sp |
parents | load_image |
execute_desc | |
content | This is a while loop that runs =process_bundle()= until it goes beyond the memory bounds (65536), moving the instruction pointer one step each time. At first I thought this could be rewritten as a for loop, but then I realized that the instruction pointer can move around. |
children | process_bundle, ip |
parents | execute |
process_bundle_desc | |
content | Takes in a 32-bit opcode instruction, and breaks it up into 4 bytes, and handled by 4 calls to =process=. My guess is byte order matters, it goes from LSB to MSB. |
children | process |
parents | process_bundle |
process_desc | |
content | Just a big case switch that handles all the instructions. I *think* io() is the IO instruction, which I'm most interested in figuring out. |
parents | process |
io | |
content | io() |
children | io_desc (description) |
parents | process |
io_desc | |
content | This io instruction takes in an argument, and does from a number of io commands. ioa() is probably closest thing I'm looking for, which seems to write to standard output |
children | ioa |
parents | io |
ioa | |
content | ioa() |
parents | io_desc |
2024-04-03 09:57:55 A version of the ioa instruction could be modified to be pass a byte on to a virtual device somehow. In addition to this instruction, there would also need to be begin/end instructions. I believe you could simply add new io subroutines to the ilo vm interpreter: ioi, ioj, iok.