 Hello party people, welcome to the chaos west stage. The next talk is held by Tom twiddle bit The one or the other person may know Tom twiddle bit. I think I just should hold the micro in there and then interesting things happened, so I Will try to bridge the time shortly. This is a self-organized session You can bring your papers and hold your project or King that you have here on stage. We We put it on the media CCC You can show it around So this stage is made for you basically and it's so well-loved that we don't have and we do have a few slots left So thank you very much community everybody of you here to make this Congress so special and add your your personality to it, too So Tom links. Are you ready? You finished your discussions? English English So please dear audience applause for Tom twiddle bit and the fourth programming language Thank you very much. I hope that in half an hour you will give me a hand as well I Have always been in a minority position in the chaos Environment because I have been I am a force programmer since 1980 And I'm so happy with the language that I never felt Any need to use something else for the things I'm doing and I will relate to this to you Why this is the case and I will take a very unusual and angle in that respect Where it comes from? I mean that is not controversial it was developed by Charles Moore in the 1960s and Over a period of 10 years he experimented with different concepts and it all started Because he was programming an IBM 26 something using punched cards of course in the 1960s and he had different what we would now call subroutines every subroutine was a card deck and In he was looking for a mechanism to pass arguments from one card deck and the programs to the next card deck and the programs and This is why he wound up with a data stack So the first program was running left its argued its results on the data stack and then the next card deck would pick up The parameters under the data stack and process them further So that is one of the constituents of the force programming which Then after this this Period of 10 years when he came to a version of his Personal programming environment that in retrospect he called this then was false He used an assembler on some mini computer. I think it was a variant and He wanted to call it fourth Because this was a time when everybody was talking about the third generation of languages and he wanted to leapfrog all of that But then unfortunately the assembler only accepted five letter identifiers and so the you had to go and It became false the programming language is based on a conceptual model of a CPU and This is basically the conceptual model. You have a data stack You have the two top items of the data stack which Have a special role if you think in hardware they would be registers The top of stack and the next of stack and the top of stack and next of that feed the ALU for binary arithmetic I mean with two arguments and the result goes back into the top of stack and Then there is a return stack because we want to do subroutine calls and returns and There is this little path on the left Where you can exchange data between the return stack and the data stack which comes in handy Sometimes I get into that later and then of course the program counter is connected to the return stack and Why I wrote this error to the memory, I don't know this is not necessary, but Basically the data stack is also connected to the data memory and you can store and retrieve results there That is very conventional. What is unconventional that instead of a register file? we just have a stack and everybody of you who ever use the Original you lit pocket Calculators knows how you operate do arithmetic on a stack Post that is called post fix notation or post fix operation And the data stack is the parameter storage used for evaluation of expressions All operators and functions take their parameters from and leave the results on the stack fourth words and Why they are called words I will come to that in a minute what you usually would call functions Do not have parameter lists So you don't need the opening parent and then this that comma and another parameter closing parent No, they just use the stack as parameter exchange and so This is one of the drawbacks of force You do not name the parameters the parameters are just there and The programmer has to take care that the parameters are really there in the order needed by the next word you call Just to make an example Arithmetic operations you put a one on the stack you put a two on the stack you do a plus and And then you put a three on the stack and you multiply and The dot is the print operator and the result is nine Because one plus two is three and three times three is nine. So this is exactly how the you lit packet Calculators used to operate manipulating the stack so The difference between a register Oriented machine and a stack oriented machine is not as big as you might think in both cases you have the difficulty that your Parameters that you need in order to call a function are not in the order that you need them in a register machine You have to exchange registers on a stack machine You have to Reorder the parameters on the stack and you have a couple of operations to do that Let me explain This notation here between the prance Before the dash dash that's the number and Semantics of the operator before the operation then comes the operation and At the right side you see the result. So the doop just duplicates an item on the stack The drop throw the way an item on the stack the swap exchanges the tools to stop items on the stack and the rot is I mean goes down to the third Operation parameter on the stack and then the minus rod is exactly the opposite of the rod Now you might start wondering Why is minus rod a valid name? Because Most programming languages would say aha. This is the minus followed by a rod not so in force. I Will jump ahead here Now this is too bad. I don't quite remember my Presentation and again, I keep in water so This was the things happening on the rich on the data stack now We also have the second stack the return stack and The return stack is primarily used to store return addresses of a word for a word or a function call and It also serves as a storage location for loop indices and therefore It is very easy in force to nest loops because if you are inside a loop and you do a call then Automatically the old loop index gets pushed on the read further down on the return stack and then you can do your Word and the return read automatically retrieves the loop index In addition the returns that can be used as a temporary Data storage to get some parameters out of the way which are currently not being used the interpreter Force is an interactive system that is controlled from the command line. So in that respect it is Similar to Python. It is very similar to list by the way only that this uses infix prefix notation and force uses post traction notation All words are kept in the linked list of word names Associated with compiled code. Now. This is what you conventionally would call The syntax tree Although because it is an interactive system this syntax tree or the dictionary as we call it in force is always present and The way it operates you type in a string of ASCII characters separated by a blank and Then the interpreter goes ahead and looks it up whether it can find the string in the dictionary If it finds the string in the dictionary, then it jumps to the associated executable address If it cannot find the string it tries to convert it into a number According to the setting of the variable base So if you have a two in the base you walk you walk work in binary If you have a 10 there it's decimal if you have a 16 then you work in hexadecimal If it is neither found in the dictionary Nor converted into a number you did a typo and the system says well, I don't know that Defining new words. So how how do you define new words? The basic operator is the colon and then after the colon comes the name of the new word you are defining and Then for and then usually you write a stack comment So you say what do I need before the word starts and what is the stack situation? when the word has finished and So we could define a word for plus that just does before plus intuitively But of course you can do nasty things like for instance you could define colon number two For semi-colon and all of a sudden if you now type in two there would be a four on the stack So that is something you should not do but it's possible So two times. I think it's pretty much self-explanatory You duplicate the n one on the stack and then you Add these two copies of the same number together and that is two times or a shift left Just to give you an idea of How how you program applications in force then Look at we have a washing machine And so this is the washer and the washer washes its pins it rinses and then it spins again and the force compiler is Just a one pass compiler And you do not have forward references. So if you want to make this definition you first have to Define wash spin rinse and spin again and just as an example I mean the definition of rinse could look like fill agitate and drain and Then you further the further you go down The closer you come to the hardware and then in the end you will have Nasty hexadecimal numbers that get stored in some addressable register What makes force so unique and why this is called an extensible language of the fact that newly defined words Exactly on the same level in terms of usability as The core word set we had to start with in the first place So in a sense you could say the force programming language is the assembler of a virtual machine that You can extend so you can you can increase the number of Instructions that this virtual machine is able to execute Memory and I owe So we have the fetch operator that consumes an address and Returns the content of the memory cell at that address in force We have no notion of bytes In force we have addressable cells and the addressable cell may be More or less any bit widths wide. I Mean conventionally you have 16 bits. You have 32 bits from an engineering point of view 24 bits make much more sense than 32 for instance and If you come to a force engine implementation on an FPGA then you will find that The internal program in FPGAs is not eight. It is nine bits wide And so it is very tempting to then just use an 18-bit machine for instance Perfectly feasible because it does your word widths does not have to be divisible by eight And if you want to operate on bytes You just store one byte at one memory location and if it has more than eight bits Well, you just throw away the extra bits Then you need words to display your results. We already Stumbled the cross dot. It just shows the number on the stack as a signed number You don't shows the top stack item as an unsigned number like in addresses and Type for instance takes an address and and the length and print this as a string primitive data types This is a definition of a constant The constant consumes a number and you give it a name a Variable allocates one memory cell in memory And so if we now that we defined Svi and weird you can do Svi weird store and Then if you do a weird fetch You you get a two To get more fancy You can create a vector So create my vector Just Creates a name for the next empty memory cell and it doesn't do anything else and Then you say okay my vector should be Ten cells wide and so you do this with the ampersand stands for decimal Decimal ten cells a lot and that gives you a vector then the the full line gives you a vector of ten elements and My vector as I said returns the address of the first element and then you can do address Computation on in order to get what you want or you can get more fancy like defining a new data type you can say I want to define a vector of a limited size and I want to be able to access the elements in the vector by passing the index To the name of the vector this I mean this is difficult to explain I must confess because here we have a word Where we defined the operation in two different time instances so the code between colon vector Which enters the name vector into the dictionary and When vector will be executed later on it we will create N cells and allocate them So in this example ten vector index vector will automatically Create a vector called index vector with ten elements and when we later on execute index vector Then the code between the does and the semicolon will be executed and that means at the beginning We have an index on the stack and in the end We have the actual physical address of the data item of of that index location on the stack And there is a little bit of un-unvisible mystery here because the word does returns the address of the first location of the data type So we have an index on the stack if you execute does we have also on top of the index We have the address of the first field Now then we first have to swap these two items to get the index on top We apply the cells operator to it Now yeah, I have to get to the cells operator why the cells operator is needed when force is working on let's say an Intel machine then of course we do have bytes and so if our Addressable cell is 32 bits wide it consumes four bytes and the cells operator is exactly the operator that computes out of the number of the 32-bit item that I want it computes the byte address on an inter machine for it and So we mark we we multiply the index for instance using cells by by for Because we have a 30 32 bit force system and then we add it at this To the first address that was left by the does and that gives up then the physical location of The data item at index in the vector So three index vectors Returns the memory address of the fourth element of Index vector and this is because force starts counting from zero So you always count zero one two three and so on controlled structures Of course, we have controlled structures and can modify the program flow as in every other Complete programming language Again with a special feature that this is a reverse Polish notation So we first compute always the first compute arguments and then we apply the operator to it in this case if we have the if Clause then We first compute a flag however complex that might be and then the if Interprets the top item on the stack as the flag and if the flag is true The code between if and then will be executed and if the flag on top of the stack is zero Then a jump after then is performed So then if else then is also then easy more or less easy to understand Although the syntax is unconventional if the flag is true We execute the code between if and else if it is false weak execute the code between else and then Another loop is the begin until loop which always executes the loop at least once and then at the end we decide whether we jump back or whether we leave the drill and the other variant is where We compute a flag If the flag is true We execute something between while and repeat and then the repeat jumps back to the begin Does the next computation and only if we are false we jump out of the loop after the repeat Another variant is counted loops that Consume two items on the stack a start value and a limiting value and then with do loop we loop So many times around and then there is the eye which returns us the current loop index compiler extension Now things become really interesting Because not only can you define new words or functions in force But you can also modify the compiler itself Modifying the compiler the important name here or what here is the word immediate That is attached to a word definition and it just means if the compiler encounters an immediate word That will be immediately executed by the compiler Whereas any word that is not immediate and that is part of a word definition will just its executable address will just be compiled into memory and nothing else and so in essence This if and this then and this if else then they are all immediate words which Execute while the compiler is working so This mechanism Extension of the compiler can be used to bake your own case or to bake your own struck compiler or I mean to make it really interested. I call this syntactic sugar So the question at hand was to define a Morse alphabet Generator so you would type in numbers and strings and it would be converted into the Morse code and if you Sugar syntactically Your compiler you can write down it you can write it down in this syntax Which is pretty intuitive You have a dot and a dash And then you have the vertical bar and the vertical bar Gives it then takes a name and the name From this moment on will be it will be Associated with a dot dash So what you have to do in order to do this magic You have to define Morse table colon as the beginning of the definition Semicolon Morse table as the end of course there are more lines. They don't fit here And so basically what you have to do is you have to define your compiling words Morse table colon Semicolon Morse table vertical bar, which is used At the end of the dots and dashes you have to define your dot and your dash and Each of those definitions takes between one and four lines of code And if you are an experienced prose programmer I mean you look at the problem and then it is very easy to come up with a solution to do that This pretty much covers the basic capabilities of force It is standardized and There are annual meetings on a European or actually nowadays on an international level the Euroforce conferences and This is where the standardization and ongoing standardization process is taking place Unfortunately, I'm missing one important slide here Okay, I will use this for for explain why I love force. I didn't tell you why I love force yet. I love force because Any character except tap and space can be part of a name So I can use all special characters in a name and this is the mystery why In force Minus rod is not a minus and a rod. It is just the word minus rod and for I mean pretty obvious reasons it is the inverse of rod And so I called it is usually called minus rod as the as an indication of of inverse and that Means in essence the hundreds of men days That up to now went into regular expression compilers Force doesn't need regular expressions. I mean the passing Process is so simple. You just look for the next space and that's all and everything that is enclosed in space or let's To be more precise is enclosed by white space is just a force word that gets looked up in a dictionary Is that is not successful it an attempt is made to convert it to a number and that's all which means that Or to put it in another way when I started to program in force I used to study computer science Which was pretty new in the mid 1970s and I stood in awe Before the compiler writers Because that seems like an extremely complex thing to do And when I then started to program in force and when I learned how to extend the compiling capabilities of force This all of the compiler writers went completely away it is simple and If you think about how force works and how you Program in force. It is basically pure anarchy because You can if you are a good programmer you can do excellent things in force If you occur a bad programmer, you are able to Write the most gibberish code, which is absolutely unrememberable in no time So in a sense force is a programming amplifier It gives you capabilities that you don't have in most other programming languages to express yourself and to create your own syntax to solve a problem and then the next logical step of course is because the force virtual machine is so simple on Most register machines. It has to be emulated. I mean just like Java has to be emulated And there are also bytecode implementations of force like for instance open boot It's just a bytecode implementation of the force language on a large variety of different processes and The advantage of this approach is that if you have peripheral IO cards They will execute the force bytecode and then the force bytecode is just interpreted on these different processes But the bytecode on the peripheral card remains exactly the same on all machines So this is where the big market niche was for open boot when we had At least four different variants of risk processes in the 1990s But since the force machine is the virtual machine is such a simple thing it is very easy to implement it in real hardware and I have been doing that for the past 15 years and Because I earn my money by filling FPGAs with content and So if I have a new piece of hardware with an FPGA on it The first thing I do is I put micro-core on it and then I can also always explore the FPGA phone inside Instead of and I can program the FPGA explore it and changing the code and Executing it on the FPGA on the software level takes well 10 15 seconds Whereas to run a new version with a change FPGA with a changed DHTL code on the current generation that I'm working on which is for satellites and radiation environments You were talking about 45 minutes so this approach makes a lot of sense and If you look at at the diagram you see the one-to-one relation more or less to the virtual machine And then well, this is not really a part of the force talk, but this is my baby basically Apart from interrupts since I'm a real-time programmer interrupts are very important There is also the the flip side of the coin and the flip side of the coin is and I spelled it out and An interrupt is an event that happened that was not expected by the software Whereas the pause exactly the opposite the An event did not happen that the software expected Like the software wants to fetch a bite from a UART But there is nothing on the UART yet it's still to come and In micro-core I can convert it this to like the flip side as a hardware signal as a flip side to the interrupt And then what you basically do is the hardware Signals on a hardware level that what this operation cannot be done Then a trap is called and calls the scheduler and does some other task in the multitasking environment Okay That's the end of the talk These are interesting links in that respect Questions, please questions So how many lookup tables do you need for your fourth machine? Lookup tables. Why would I need lookup tables in the FPGA? I just the size of the so, okay I Have been working on the micro semi what used to be active for such a long time They have a very very fine granularity So on those it is around 5,000 cells. I think if you if we talk about Xilinx or lettuce or Atmel we are talking about 2000 to 2500 Any more questions? I have a question You are here with we fixed the internet guys, is that correct? Yeah What has the program language fourth to do with we fixed the internet? Ask Bernd He did a full new internet stack all programmed in force Yes, he had to talk earlier today and he said and he referenced yours So maybe Bernd for the others just compress one problem We have with the internet is the attack surface is just too complicated everything we do is too complicated So we build a huge attack surface for all the evil people out there and we have to go Down make it simpler and simpler until we understand what we are doing and force is one way to Make things simpler at least our development systems that is the point here and It's not just Writing a stack in force. It's also when we think about JavaScript. It's too complicated even Even our image file formats are now so complicated that you can inject A tech in and PNG or JPEG and that's not the right way. So we have to cut down all this complicated and Things and the complicated stuff is just the accidental complication. It's not necessary complication and force force teaches you how to be simple is state of mind Solve simple don't solve complex things Thank you very much And you Maybe a dumb question, but When you run this force program on the FPGA How can I imagine this? Do you upload bite sequence to this? Yeah, I have I have a little what is called I Don't remember it from the spark architecture So you have you have something on the side with a receive and a transmit channel That allows you to connect it as we call it the umbilical to a host computer and the host computer runs across across compiler and a full image of the program and data memory on the target system and This was this technique you are in complete control of the target system because you can compile code that you have written in an editor you load the file and You compile for the target system and that compiles it into a memory Memory area in the host and then you transfer this memory image into the target system and then you start the target system and let it execute some executable routine on the target system and then I mean this is standard technology basically how you connect and a host in the target system via your binnacle and then you have a very simple monitor loop that Weights on the umbilical to receive an address that it should jump to and once it has Executed what it found at this address then if everything went, okay, it sends back a zero so the host system knows then Well, this word has been executed and everything was fine And if it is not a zero then it is either a warning or an error That's simple that did this answer your question. Not really. I will come to you Any more questions from the audience, okay, thank you very much for your attention