[Mod] VM16 CPU/Computer [vm16]

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

[Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

VM16 CPU/Computer

A CPU/computer simulation (virtual machine) with programming environment

VM16 is the basis for mods like PDP-13, but comes with its own small demo CPU/computer.

Image

On client side Minetest 5.4+ is recommended (font=mono)
  • Develop ASM or C-like programs
  • Debug/execute your code with ingame debugger
  • Read input values from switch blocks
  • Output values on colored lamps or as an ASCII string in the menu
  • Lua API to adapt vm16 to other mods
  • Two types of server and programmer blocks (16 and 32 bit textures)
Manuals are on GitHub Wiki
Download and install from GitHub
YT-Video (outdated)

License

Copyright (C) 2019-2022 Joe
Code: Licensed under the GNU AGPL version 3 or later. See LICENSE.txt
Textures: CC BY-SA 3.0

Dependencies

Optional: default, basic_materials for the demo CPU (recipes)
Last edited by joe7575 on Wed Mar 23, 2022 11:32, edited 5 times in total.
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
jp
Banned
Posts: 947
Joined: Wed Dec 18, 2013 09:03
GitHub: kilbith
Location: France

Re: [Mod] VM16 CPU/Computer [vm16]

by jp » Post

You can have syntax highlighting with the `hypertext` formspec element.

Very nice mod and I give five stars to your code.

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: [Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

jp wrote:
Sun Feb 20, 2022 17:22
You can have syntax highlighting with the `hypertext` formspec element.
Unfortunately, this is not possible inside a textarea[...] field, I guess
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
Desour
Member
Posts: 1519
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: Desour
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: [Mod] VM16 CPU/Computer [vm16]

by Desour » Post

Great!
(I haven't tested it much, nor looked much at the code.)
rip-relative addressing doesn't seem to work nicely with labels. Ie. jmp +mylabel jumps to PC + location of mylabel, not PC + location of mylabel - current location. (Also, why not a syntax like this: jmp PC+mylabel?)
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: [Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

DS-minetest wrote:
Tue Feb 22, 2022 00:59
rip-relative addressing doesn't seem to work nicely with labels. Ie. jmp +mylabel jumps to PC + location of mylabel, not PC + location of mylabel - current location.
Thanks for the hint, the bug is fixed with the new version 2.5
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: [Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: [Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

v2.6 is available with breakpoint support and further CPU improvements
Spoiler
Image
  • The turquoise line is the position with the next instruction to be executed
  • The yellow address (000A) is the breakpoint
Hint: Because of the breakpoint support, v2.6 is currently not compatible with the PDP-13 Mod!
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: [Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

(Almost) High Level Language for Minetest (work in progress)
  • C like language (so far the only data type is a machine word )
  • Other language flavors are also possible
  • Symbolic debugger with breakpoints and variables
The idea is to provide a PLC like "programming station" which contains compiler, debugger, file system, and so on. That means, the target controller can be a simple node that just runs the code.


Todo:
  • Many tests and improvement
  • A server block with the file system (can be shared by several programming stations)
  • A controller API, to be able to use the programming station from other mods
  • PLC like "functional blocks"
  • Functional plug-ins for other applications like the signs bot
Any further ideas?
Attachments
vm16_debugger.png
vm16_debugger.png (45.3 KiB) Viewed 4361 times
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
jwmhjwmh
Developer
Posts: 125
Joined: Sun Jul 18, 2021 14:10
GitHub: TurkeyMcMac

Re: [Mod] VM16 CPU/Computer [vm16]

by jwmhjwmh » Post

This mod looks cool. Would it be possible to integrate it with Mesecons?

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: [Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

jwmhjwmh wrote:
Tue Mar 15, 2022 23:48
This mod looks cool. Would it be possible to integrate it with Mesecons?
Yes, sure.
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: [Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

Update

Version 3.3 is available in GitHub:
- Mod completely restructured
- Programmer block (notebook) with the development environment (compiler, debugger, file browser) added
- File server block added
- Demo CPU/controller adapted to the programmer
- Many compiler and debugger improvements

The mod itself has no dependencies and can be integrated in almost all games, only the demo CPU with the I/O blocks come with recipes based on default and basic_materials.

Due to the programmer with its small API, a VM16 integration in other mods should be quite simple.
Attachments
screenshot_20220319_224427.png
screenshot_20220319_224427.png (178.4 KiB) Viewed 4195 times
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: [Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

Update
  • The Assembler mode is reactivated again. The controller/CPU can now be programmed in assembler and in a C-like language.
  • More classic looking blocks with 16x16 textures are added for programmer and server. These can be used alternatively.
Attachments
screenshot_20220321_185043.png
screenshot_20220321_185043.png (100.37 KiB) Viewed 4118 times
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
jp
Banned
Posts: 947
Joined: Wed Dec 18, 2013 09:03
GitHub: kilbith
Location: France

Re: [Mod] VM16 CPU/Computer [vm16]

by jp » Post

joe7575 wrote:
Mon Feb 21, 2022 19:30
jp wrote:
Sun Feb 20, 2022 17:22
You can have syntax highlighting with the `hypertext` formspec element.
Unfortunately, this is not possible inside a textarea[...] field, I guess
There's some misunderstanding here. hypertext is a powerful alternative to textarea, it is not meant to be used inside textarea.

hypertext is, actually, a textarea on steroids.

You could propose various code color schemes with hypertext, such like in a conventional text editor.

(hint: I'm the co-author of hypertext)

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: [Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

jp wrote:
Mon Mar 21, 2022 18:48
joe7575 wrote:
Mon Feb 21, 2022 19:30
jp wrote:
Sun Feb 20, 2022 17:22
You can have syntax highlighting with the `hypertext` formspec element.
Unfortunately, this is not possible inside a textarea[...] field, I guess
There's some misunderstanding here. hypertext is a powerful alternative to textarea, it is not meant to be used inside textarea.

hypertext is, actually, a textarea on steroids.

You could propose various code color schemes with hypertext, such like in a conventional text editor.

(hint: I'm the co-author of hypertext)
You mean this hypertext?
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
Blockhead
Moderator
Posts: 2105
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: [Mod] VM16 CPU/Computer [vm16]

by Blockhead » Post

jp wrote:
Mon Mar 21, 2022 18:48
joe7575 wrote:
Mon Mar 21, 2022 19:27
(hint: I'm the co-author of hypertext)
You mean this hypertext?
Maybe, maybe JP co-authored it with Tim Berners-Lee :P

So i'm not completely off-topic: what kind of ISA and ASM syntax is used in the mod?
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: [Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

Blockhead wrote:
Tue Mar 22, 2022 01:38
So i'm not completely off-topic: what kind of ISA and ASM syntax is used in the mod?
The assembler follows the Intel syntax. See manual.

But what is ISA? I only know ISA bus :)
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
Blockhead
Moderator
Posts: 2105
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: [Mod] VM16 CPU/Computer [vm16]

by Blockhead » Post

joe7575 wrote:
Tue Mar 22, 2022 07:22
But what is ISA? I only know ISA bus :)
Instruction set architecture (ISA), as in the collection of valid instructions and associated registers, like Intel x86, amd64 extensions. Can also be broken down into a 'base level' and extensions like x86's SSE, AVX etc. amd64 is the 64-bit extensions to x86, (sometimes generically called x86_64).

Though since you mentioned ISA it's worth asking if there is a bus standard for your architecture as well, comparable to ISA/PCI?
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: [Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

Ah, ok.
The CPU is a self made 16 bit VM without any template. It is as simple as possible. Simple to implement and simple to be programmed in assembler.
Though since you mentioned ISA it's worth asking if there is a bus standard for your architecture as well, comparable to ISA/PCI?
It has no bus standard but a simple Lua API:

Code: Select all

-- Called for each 'input' instruction. Function returns the input value.
on_input = function(pos, address) ... end,

-- Called for each 'output' instruction.
on_output = function(pos, address, val1, val2) ... end,

-- Called for each 'system' instruction.
on_system = function(pos, address, val1, val2) ... end,
See API
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: [Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

Update

Inline assembler added to compiler and debugger.
Attachments
screenshot_20220322_214922.png
screenshot_20220322_214922.png (43.27 KiB) Viewed 4013 times
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: [Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

Update

Compiler now supports:
  • one-dimensional arrays
  • pointers
  • strings and chars
  • constants
This largely completes the range of functions.
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: [Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

Update

New features and changes:
  • Import of C and ASM files added for larger programs
  • Further C examples added to the file server
  • Standard library function added (stdio, mem, string, math)
  • Started to write a "Language Reference" manual on GitHub
  • Improve debugger with step-in and step-out buttons
  • Improve debugger with variable and memory watch window
  • Many further improvements and bug fixes
Attachments
screenshot_20220405_220359.png
screenshot_20220405_220359.png (60.6 KiB) Viewed 3766 times
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: [Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

Update

vm16 is now in a usable condition. Further improvements are planned.
The second mod, which uses vm16 is Beduino
A video to Beduino is on YT
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: [Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

Update
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
joe7575
Member
Posts: 864
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: [Mod] VM16 CPU/Computer [vm16]

by joe7575 » Post

Update

Following Compiler features added:
  • <= and >= operators
  • constant expressions and static constants
  • sizeof operator
  • function-local arrays
  • octal numbers
  • '&' reference operator
Further improvement on debugger, VM, and Compiler Language Reference
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

User avatar
mainspirit
Member
Posts: 18
Joined: Fri Mar 17, 2023 16:33
In-game: mainspirit

Re: [Mod] VM16 CPU/Computer [vm16]

by mainspirit » Post

Hello, we are faced with the fact that when using any Slavic language, ru, ua, instead of letters - dots. Is it possible to fix it somehow? Thank you.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 8 guests