created by Felsner Felipe 2024
what is chronos
Chronos is my first programming language. It was started as a joke, and was never meant to be fast or have good syntax. I based myself in assembly because it was the most simple type of code I could imagine, and the first prototype interpreter was created in about a week using Python.
here are all commands that are already included in Chronos. The details of how to make you own commands will be after this section.
memory values may be called 'bytes' but they do not occupy one byte of memory.
add
[memory adress or value](value 01 and 02){two bytes}
adds two values together, it adds the hold register with the value or memory adress given and the result goes to the hold register
easter egg
aadd
(value 05) {one byte} # single-cycle
adds two values together, it adds the hold register with the value in the a register and the result goes to the hold register
sub
[memory adress or value]: (value 03 and 04) {two bytes}
subtracts two values together, it subtracts the hold register with the value or the memory adress given.
still an easter egg
asub
(value 06) {one byte} # single-cycle
subtracts two values together, it subtracts the hold register with the value in the a register and the result goes to the hold register
mult
[memory address or value] (value 0F,10) {two bytes}
multiplies two values, it multiplies the hold register with the value on the memory adress given and the result goes to thehold register
surprise muther******
amult
(value 11) {one byte} # single-cycle
multiplies two values, it multiplies the hold register with the value in the a register
div
[memory address or value] (value 0C,0D ) {two bytes}
divides two values, divides the hold register with the value or the memory adress given and the result goes to the hold register
is this even funny anymore?
adiv
(value 0E ) {one byte} # single-cycle
divides two values, divides the hold register with the value in the a register and the result goes to the hold register
cnde
[memory address or value] (value 18,19 ) {two bytes}
a instruction that compares the hold register with the value given and executes the next line if they are equal.
https://www.youtube.com/watch?v=dQw4w9WgXcQ
cndb
[memory address or value] (value 1A,1B ) {two bytes}
a instruction that compares the hold register with the value given and executes the next line if hold is bigger.
check the link ;)
cnds
[memory address or value] (value 1C,1D ) {two bytes}
a instruction that compares the hold register with the value given and executes the next line if hold is smaller
mark
[memory address or value] (value 1E,1F ) {two bytes}
a litteral mark that is used by jumps to repeat a line.
kilroy was here
jmpup
[memory address or value] (value 20,21 ) {two bytes}
a instruction that tries to find a mark, executing it again. it searches a mark of the same value above its current line. if no mark is given an error will accour
nothing
jmpdown
[memory address or value] (value 22,23 ) {two bytes}
a instruction that tries to find a mark and pc variable as it, executing it again. it searches a mark of the same value below its current line. if no mark is given an error will accour
nothing
goto
[line number]: (value 07 ) {two bytes}
a instruction that jumps you to the index given. It changes the program counter directly
hold
[memory address or value] (value 09,0A ) {two bytes}
a instruction that stores the info given in the hold register, all previous info stored in the hold register will be erased.
space
ahold
(value 0B ) {one bytes} # single-cycle
a instruction that stores the info in the a register into the hold register, all previous info stored in the hold register will be erased.
emptyness
aput
[memory or value] (value 16,17 ) {two bytes}
a instruction that stores the info given in the a register, all previous info stored in the a register will be erased
void
str
[memory address or value] (value 12,13) {two bytes}
stores a value in memory from hold register
nothingness
astr
[memory address or value] (value 14) {two bytes}
stores a value in memory from the a register
in
(value 24 ) {one byte} # single-cycle
a instruction that will stop the current and wait a value to be inputed
space
out
[memory or value] (value 25,26 ) {two bytes}
a intruction that will output a value as a number
space
outl
[memory or value] (value 27,28 ) {two bytes}
a intruction that will output a value as a letter using ascii
cmt
just type 'cmt' at the start of the line and it will not be executed
halt
(value 0) {one byte} # single-cycle
a instruction that kills the current task
chronos is a simple language, it can be used for simple code and new operations can be written easily as the source code is very flexible. here are the main structures you need to know to code in chronos and eventually make you own commands:
customizable syntax
Chronos whas created to be flexible, custom syntax is easy and fast to implement.here's how:
download the files for the Chronos interpreter or Compiler
locate the "configure" file
locate the commmand you want to change
change it
take care to make syntax that is different from the other commands: for exemple "add" would collide with the command "add_with_a" because it contains "add" in the same place. so stay cautious and creative.
you may note the weird dollar sign things in the "configure" file, they are there for list and index reasons and should not be changed if you dont know how the interpreter or copiler works.
memory and registers:
the memory is chosen by the user before execution of code and cannot be less than 30 "bytes" long. it follows the same rules real hardware memory would. the first 3 "bytes" are reserved for the 3 register
program counter (address #02)
register that holds a pointer to the operation that will be executed. counts up with every operation.(with some exceptions (jumps and gotos)).
hold register (address #01)
register that stores any value, it is used as ram to store operations.
A$ (adress #00)
register that can hold any info, can be changed by all intructions that start by "a" or by just using it's address.
then the other bytes that follow are the actual code. so be careful when writing to memory or using gotos.
difference between memory addressed and valued commands:
the presence of a "#" character is what indicates the interpreter that the value input is an address. It will fetch the value in the index of that value to be used in the operation.
operations that can use adresses will always have two functions. The first in the function list handles addresses and the next is used for values.
how to make your own commands:
the first you will want to do is download the source code for the interpreter. in it you will find a file named 'back_end' and in it you will find a lot of necessary functions
deciffer_file()
it is responsable for reading the file and placing indexes of each intruction into the memory (global_memory list).in it you will find a line that compares the index of the word variable with a list of values. if you plan to write a single cycle intruction this line will need to altered because it dictates if a function is single cycle or not. just add the value of your function there and the function will work normally.
a function for every command
it's here that you will code your own command, for your disposition are 3 pointers that make code more readable:
a,hold and pc_register_pointer variables
these variables will always have the value of the index of memory where the registers are stored
the boolian variables debug_mode and discreet_mode
will be true when the respective mode is activated.
now that you coded your command you can add it to the "configure.txt" file, remember to always add the unique combination of letters to the name of the function and always adding the unique string of characters after the function's name if it is not single cycle.
# it is always useful to look at the standard functions to understand better how everything works together#
faster c++ interpreter and compiler
better I/O
file opening capacity and other memory options (allocated memory)