[GSoC] apps/brainfuck: add Brainfuck interpreter #357

Open
dannydod wants to merge 3 commits from dannydod/kolibrios:brainfuck-interpreter into main
First-time contributor

Brainfuck interpreter with interactive REPL interface for KolibriOS.

Features

  • Console-based REPL with interactive commands
  • Use Jump table dispatch for execution
  • RLE preprocessing as optimization
  • Buffered output to minimize redraw
  • File loading support via run <filepath> command
  • REPL commands: help, run, clear, reset, exit
  • Two implementation: bf_shell_interp.asm, bf_console_interp.asm

This is my first contribution to KolibriOS for GSOC 2026
WASM runtime project preparation

Brainfuck interpreter with interactive REPL interface for KolibriOS. ## Features - Console-based REPL with interactive commands - Use Jump table dispatch for execution - RLE preprocessing as optimization - Buffered output to minimize redraw - File loading support via `run <filepath>` command - REPL commands: help, run, clear, reset, exit - Two implementation: bf_shell_interp.asm, bf_console_interp.asm This is my first contribution to KolibriOS for GSOC 2026 WASM runtime project preparation
Owner

@dunkaist Do you know if this is part of GSOC, is there a mentor here?

@dunkaist Do you know if this is part of GSOC, is there a mentor here?
Owner

@dunkaist Do you know if this is part of GSOC, is there a mentor here?

This is a test task for GSoC, yes. The main project is WASM runtime. I have given feedback in a private conversation to remove the binary and split BF logic into a separate file from bf_*_interp.asm

> @dunkaist Do you know if this is part of GSOC, is there a mentor here? This is a test task for GSoC, yes. The main project is WASM runtime. I have given feedback in a private conversation to remove the binary and split BF logic into a separate file from bf_*_interp.asm
mxlgv added GSoC and removed
Status
Need More Info
labels 2026-03-11 11:46:01 +00:00
mxlgv requested review from Burer 2026-03-14 16:56:58 +00:00
mxlgv requested review from dunkaist 2026-03-14 16:56:59 +00:00
mxlgv requested review from mxlgv 2026-03-14 16:57:00 +00:00
Owner

@dannydod
What license is this software distributed under?

@dannydod What license is this software distributed under?
dunkaist reviewed 2026-03-14 18:52:42 +00:00
@@ -0,0 +188,4 @@
test eax, eax
jz .display_help
stdcall string.cmp, buffer_data, reset_cmd, 5
Owner

This should be 6, I believe. Magic numbers should be avoided. Could you, please, turn this series of stdcall, test, jz to a table of strings and pointers to the corresponding functions? I've seen you used a jump table, therefore pointers to functions shouldn't be a problem for you

This should be 6, I believe. Magic numbers should be avoided. Could you, please, turn this series of stdcall, test, jz to a table of strings and pointers to the corresponding functions? I've seen you used a jump table, therefore pointers to functions shouldn't be a problem for you
Author
First-time contributor

Hi Ivan, thanks for the review. I would fix refactor the command test, and move all initialized data to after the code.

Hi Ivan, thanks for the review. I would fix refactor the command test, and move all initialized data to after the code.
dunkaist marked this conversation as resolved
dunkaist reviewed 2026-03-14 18:59:29 +00:00
@@ -0,0 +26,4 @@
; data definitions
prompt db "BF:> ", 0
Owner

Please, keep code and data separated. You define data both at the start and at the end of the program. In KolibriOS, we usually keep all the data at the end. You can put initialized data after code just before I_END

Please, keep code and data separated. You define data both at the start and at the end of the program. In KolibriOS, we usually keep all the data at the end. You can put initialized data after code just before I_END
Author
First-time contributor

@mxlgv MIT license. I'll add a LICENSE file in the next commit. Or is there any specific license you would recommend for contributed programs?

@mxlgv MIT license. I'll add a LICENSE file in the next commit. Or is there any specific license you would recommend for contributed programs?
Owner

@mxlgv MIT license. I'll add a LICENSE file in the next commit. Or is there any specific license you would recommend for contributed programs?

If it is port - license of original code should be kept.
If it is written by yourself from scratch - it's totally up to you, but we would recommend GPL-2.0-only, same as KolibriOS kernel code is distributed.

> @mxlgv MIT license. I'll add a LICENSE file in the next commit. Or is there any specific license you would recommend for contributed programs? If it is port - license of original code should be kept. If it is written by yourself from scratch - it's totally up to you, but we would recommend GPL-2.0-only, same as KolibriOS kernel code is distributed.
dannydod added 3 commits 2026-03-19 13:53:40 +00:00
Console-based REPL Implementation
- Use Jump table dispatch for execution
- RLE preprocessing as optimization
- Buffered output to minimize redraw
- File loading support via run command
- Add REPL commands: help, run, clear, reset, exit
- Two implementation: bf_shell_interp.asm, bf_console_interp.asm

This is my first contribution to KolibriOS for GSOC 2026
 WASM runtime project preparation
- Extract shared interpreter logic into bf_core.inc
- Console and shell files now only contain interface code
- Use macros (bf_write, bf_getc, write) for interface-specific I/O
- Remove binary file from repository

Addresses Ivan's review feedback from PR #357.
Refactor: change command dispatch to use a table and move data to I_END
Build system / Check kernel codestyle (pull_request) Successful in 40s
Build system / Build (pull_request) Successful in 11m54s
84e83c8926
dannydod force-pushed brainfuck-interpreter from 39ea7b4196 to 84e83c8926 2026-03-19 13:53:40 +00:00 Compare
dunkaist approved these changes 2026-03-23 23:35:57 +00:00
mxlgv requested changes 2026-03-27 01:50:52 +00:00
mxlgv left a comment
Owner

I recommend using the mcall macro and constants from KOSfunc.inc

I recommend using the `mcall` macro and constants from `KOSfunc.inc`
@@ -0,0 +1,110 @@
format binary as ""
Owner

I recommend adding headers like these to your files:

; SPDX-License-Identifier: GPL-2.0-only 
; Reshare - Shared Resources Daemon
;
; Copyright (C) 2026 KolibriOS Team
I recommend adding headers like these to your files: ```asm ; SPDX-License-Identifier: GPL-2.0-only ; Reshare - Shared Resources Daemon ; ; Copyright (C) 2026 KolibriOS Team ```
@@ -0,0 +13,4 @@
dd parameters
dd 00
parameters rb 1024
Owner

This increases the size of the binary by a kilobyte

This increases the size of the binary by a kilobyte
@@ -0,0 +83,4 @@
int 0x40
I_END:
; data definitions
err1 db "Missing parenthesis match",0
Owner

Declaring initialized data after the end of the program image looks wrong

Declaring initialized data after the end of the program image looks wrong
Burer changed title from Add Brainfuck Interpreter to [GSoC] Add Brainfuck Interpreter 2026-04-26 13:30:14 +00:00
Burer changed title from [GSoC] Add Brainfuck Interpreter to [GSoC] apps/brainfuck: add Brainfuck interpreter 2026-06-07 16:57:04 +00:00
All checks were successful
Build system / Check kernel codestyle (pull_request) Successful in 40s
Required
Details
Build system / Build (pull_request) Successful in 11m54s
Required
Details
Checking for merge conflicts…
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u http://git.kolibrios.org/dannydod/kolibrios brainfuck-interpreter:dannydod-brainfuck-interpreter
git checkout dannydod-brainfuck-interpreter
Sign in to join this conversation.
No Reviewers
4 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: KolibriOS/kolibrios#357