Language Model - luciantin/Racket_Lang GitHub Wiki

Language design

FMlang is a 3DOF programming language that only once imposes the direction of code execution.

Program code should be written in multiple "pages" (although it is not necessary).

An instruction pointer starts executing commands at page 0 on x = 0 y = 0 , the first command on the page that is declared as the start page, from there it moves from left to right by incrementing x by one until it reaches a stop command or a command that changes the direction of movement of the instruction pointer at which the instruction pointer changes the direction of code execution.

The instruction pointer executes any command that it points to and continues to the next one, it does this until it reaches a stop command.

The language consists of :

  • 6 commands for changing the direction of code execution
  • 7 commands for changing memory pointers (A & B)
  • 5 commands for controlling the flow of a program
  • 6 commands for I/O
  • 10 commands for changing the value of memory
  • 3 commands for page and row declaration
  • 3 other commands (halting execution and no operation)

Memory

Program's memory consists of an "infinite" list in which every element is set to 0, the values of the list are accessed through two pointers, A and B. At the start of the program A and B point to the middle of the list, to the same element of the list.

slk


Flow control

  • Movement direction of the instruction pointer is controlled with 6 commands, the instruction pointer moves in 3 coordinates, once a direction is set the instruction pointer will move in that direction until a new direction is set or a stop command is executed.

  • To change the flow of a program without changing the execution direction a check command is used, all check commands won't execute the next command if the check is false and will continue with execution in the execution direction the instruction pointer was set to. If the check command is true then it won't skip the next command.


Example of instruction execution

Program prints integers from 10 to 0

https://raw.githubusercontent.com/luciantin/Racket_Lang/master/slike/Tut1-wiki-slk/Png-out/1out.gif

  • At the start of the program the instruction pointer is lowered by one page where it adds 1 to A ten times

  • After filling the elem at which A points to, the IP is sent up a page where it reaches a check command [CAZ]

  • Each time IP gets to the check command it skips the next command (page up [PUP]), outputs the value at A as an integer [OIA], subtracts one from A [SOA], drops to the row underneath [RDW], travels to the left [RLF] and then it is sent up a row [RUP] and to the right [RRT] where it checks again ....

  • This is a basic loop on a single page; because the IP keeps its direction a multi-page loop can be made which instead of skipping the next instruction skips the next page.

https://raw.githubusercontent.com/luciantin/Racket_Lang/master/slike/Tut1-wiki-slk/Png-out/2out.gif

  • End of the loop when memory at A reaches 0
  • (some commands are skipped and the program stops when it arrives on the STO command)

How it works in Racket

intrprtr

  • Program code gets converted into a list, the list and the start page number are put into a Racket Module with the language interpreter and the program memory list, at the end of the module is a function call for the interpreter which starts executing code from position 0 0 0.

Infinite Loop example :

 STR       ; start page
 PUP STP   ; page up command
 NEW       ; second page
 PDW STP   ; page down command

When in the future Elon Musk implant's electrodes in every persons brain the normal way of writing programs will have to change.