'Accidental' CrossCompiler - Computerphile

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what we're gonna look at today is to pick up the story that we've been involved in for quite a while now of accidentally discovering that one's written across compiler the first ever one I wrote and I almost didn't realize I was getting into it for those of you have been following the story so far I've been trying to motivate T diagrams as a way of understanding compilers in general to illustrate the idea of moving compilers around or coping with hardware that won't talk to one another we did before Arduino and Raspberry Pi we say everybody speaks very quickly to each other nowadays was it like that then not a chance there wasn't a component to universal component you can put in the middle that would bridge a to be in a very very powerful way for the infamous Linotype - OH - jailbreak problem that we've covered a lot in videos this was the one step before laser printers came on the scene the trouble was that the 202 typesetter wanted everything down its own non-standard parallel port what I had to do was to Commission a single board z80 chip so fairly low-level character at a time stuff was coming down here it was being sucked into the z80 board as serial because it was simpler but out port as parallel to be compatible with a parallel input port on the line a tronic - whoo - typesetter I would point out that our bridging board here was hardly high-tech Steve Marchant who built it for me was a typical electronics engineer you shouldn't be messing about with saying everything could be done in the assembler I'm being very generous with you I'm giving you a 2k ROM to put your program text in and if you can generate that out of C and not overflow fine but also bless him he did give us an absolute lifeline which comes off the top of this diagram he did provide a monitor port from a VD you if you're in the UK VD t if you're elsewhere in the world video display terminal dumb terminal just showing you the flow of characters into and out from and that saved our lives many a time in debugging what was going wrong the problem is that if you're gonna put error messages out on the VDC they have to be stored somewhere he provided us very generously with 2k RAM richest beyond the dreams so yes it the tool camera I'm got very four because I remember Julian who took those projects over from way coming and saying we would get on very well if only we could do without the error messages once upon a said we can't so we phoned up Stevo was not very sympathetic and said it was all due to our being computer scientists and not electronics engineers and need a given as a thing for very good reasons we're at the low end of memory was our 2k of RAM sitting on top of that was the 2k of ROM in the memory space which was actually reading the characters preparing them for parallel listening for responses all this kind of stuff so when Julian now I said can you give us a more RAM know what he did he gave us two K more around sitting on top of that law so our RAM holding was split into two never mind said Julian quite rightly said we'll keep the lower level of around for the actual buffering of the characters we'll keep all the error messages in the upper bit he said you know frankly we're only about 40 bytes short of what we need but we have to have more anyway we did our plod interfacing program wrote it in C but the white Smith's system reduced everything to assembler so they had their own Zed 80 assembler so you could do assembler inserts and these could be linked into your C generated low-level code all in one big happily family but in the end it got united into a single big assembler level programming around the assembler you were scarcely aware of doing it because by this time it was all packaged up into a shell scripts and you just sort of ignored the detail we were happy for it to happen physically what happened was you prepared your program you've turned on the prom it's a EEPROM an EEPROM is a programmable read-only memory electrically driven you made a one-off effort and you burnt your program in there and you took it off your target board you plugged it in you hoped it works if it didn't work then there was an electrically erasable option to it and you could reuse it I don't know I mean eventually I think would have got tired but I don't think we ever had to use more than one but anyway that was the way it worked so it was a physical transportation mechanism you walked over you put it in to the driver board and you thought this time I've got it right it's going to work well you're looking at diagrams like this even at the time I began to get quite philosophical about this and think well you know there's so many questions you could ask here here am I sitting here producing my cross-compiled z80 code and it is cross-compiled because it's a different binary for the z80 than it is on the pdp-11 where it's actually being produced wouldn't it be wonderful if only I could have far more memory for data and the program on that board I mean 4k may be enough an electronics engineer but really let's get serious it's pathetic I also thought well we do this and we come with choose to come in and interface the one character down a parallel port level now we knew actually the line of Tron co2 typesetter was front ended not by a pdp-11 but by another 16-bit mini computer it was called the naked mini it was made by a firm called computer automation it was a 16-bit machine generally speaking it was slower than a PDP LEM would have been but it was adequate enough for the clunky electromechanical backing and forwarding a bromide at the 202 had to indulge in liner type had bought in and off the peg sorts of solution I think the reason when it was called the naked mini you could get a version with really no frills and furbelows no case it was a it was a component you could build into a bigger system and all that's and everything you added on to was an extra probably including the keyboard knowing that law but you see the more courageous attitude which Bell Labs did but they have how should we say more experience better skills and better lawyers than we had is to say blow this that's not really a very good place to intervene why don't we mount an invasion and invade the naked mini and take it over completely and that's what Ken Thompson did of course in the great jailbreak got himself on there his favorite implementation language was the B language which remember BCPL B is the first interrupted language still typeless C came along developed mainly by Dennis but consulting can to be v-system implementation language so first Ken's first reaction are getting strange machineries right I'll look up how the assembly works look up how the code is right now below and overnight I will pour my B interpreter and get it working on here and of course within a few weeks he'd got absolutely everything in there working of his cross compiler cross interpreter and everything and in many ways that was a way to do it because he could then decide do i port the whole software mechanism onto that machine or would i be better to say i know enough now to drive it directly from the PDP 1144 and bypass that largely so a lot of time was spent with his software decoding what the heck the 202 was up to in terms of rendering fonts and it took a long time to figure out what they were doing with the characters and so on so it still prompts the issue do you invade the enemy territory or do you stand off in the background and and arms the length using tolerance just gently feed it the odd serial line cow and we had to we just had to take that less of you but with my thoughts about wouldn't life be easier if only I had a bigger zhe memory could I actually host the compiler on that or would it be hopelessly slow yes it probably would but in theory could I do it although it's an 8-bit micro and appeared coincidentally or not in the sinclair zx80 S&X 81 around about that time there was a lot of people asking could we cross compile stuff for the zx80 and compile it and run it and at Cambridge at the time there was a gentleman who will be known to many of you because he became famous in the UNIX world Steve born stillborn is perhaps best known for writing the canonical Bourne shell that comes as part of UNIX but before he took the job at Bell Labs he was a PhD student and a researcher at Cambridge and he wrote a system called Algol 68 C was dialect for the Algol 68 language and his big aim since Algol 68 was his baby was I can only imagine because there's reports of these experiments going on can i generate code on here for the z80 and what is the best way for me to do this so all these zhe boards we working with with Cloud Sinclair and his boys you know it will be lovely to be able to prepare lots of code for them what's the best way to do this well I had a great big IBM 360 machine and what they discovered was their precious Algol 68 compiler and they went through all the tricks we've covered in previous episodes of getting it to compile itself or getting it to compile a stripped-down version of itself what they found was that in the process of preparing a stripped down version if I've got this right the actual compiler itself had to get very big for a while in order that it could generate a smaller version that would fit on the said eighty and when you say well what's very big a hundred K and you are limited by the architecture on a Zed 80 to 64 K no solution you had to cross compile yeah and and they did but I think also which is perhaps even more interesting in fact I went to see Steve at the time and I don't know ISM actually seen him since this really was in the very early eighties I remember it well I think it was back on vacation from Bell Labs and he said you know the more you look at this business of transporting or porting as it now called a compiler to a new environment the more you realize what a mess we get ourselves into we've got this language which gets compiled down close to binary on this machine then we want to do it on another machine like the spectrum and if we're not careful we start all over again so we must do the whole chain must get everything ready and all that but he said you know the hardest bit in writing a compiler is not all the syntax analysis and deciding what to do it's actually doing it in the code generator against an environment that can often see very very hostile indeed wouldn't it be great if one could have a sort of assembler level vaguely intermediate code that everybody could use now he was one of the early people to realize this and he said I don't have invented this thing called Zed code so my compilers now don't go to a specific binary in one step they omit Zed code and then for the new machine you don't have the whole big compiler to transport what you're saying is the Zed code is the back end the syntax analysis whatever is the front end all you need to do for new architecture is write as n code compiled of our interpreter as it said code he said yes my new colleagues at Bell Labs wanted to call it Zico and I keep telling them I'm from the UK it's my baby it's that Kahoot this approach at the time became so well known and so discussed that it even had its own title the uncalled problem uncle I think he stood the universal computer language the forlorn hope was that it might emerge from all those doing compilers that there would be one superbly capable intermediate language which every single compiling system in the world could subscribe to and be happy with its facilities and so on so the search for the uncle solution predictably it doesn't work like that there's always enough difference in architectures and maybe even today that it is not easy to have a one size fits all so I think this is a good place to draw a line for the moment and so we've got to investigate how do intermediate codes work how do they help you por tu compiler from machine a to machine B we vaguely see that it can obviously help because all your having to write to get a foothold is an intermediate code interpreter for the new back-end and that gets you started control C control C because it councils things love done right control seek is a 2 to 500 pixels squared usually training them takes all the memory
Info
Channel: Computerphile
Views: 95,665
Rating: 4.9504952 out of 5
Keywords: computers, computerphile, computer, science, University of Nottingham, Professor Brailsford, Compiler, Cross Compiler, Xcompiler, X-Compiler
Id: 9kp0yUA-KgQ
Channel Id: undefined
Length: 15min 12sec (912 seconds)
Published: Fri Sep 06 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.