Files
hpr-knowledge-base/hpr_transcripts/hpr3403.txt

88 lines
19 KiB
Plaintext
Raw Normal View History

Episode: 3403
Title: HPR3403: Forth on microcontrollers
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr3403/hpr3403.mp3
Transcribed: 2025-10-24 22:47:06
---
This is Hacker Public Radio Episode 3403 4 Wednesday, the 18th of August 2021.
Today's show is entitled, Fourth on Microcontrollers.
It is hosted by Brian in Ohio and is about 22 minutes long and carries a clean flag.
The summary is a little more about Fourth and a couple of chapters in the novel of my life.
This episode of HPR is brought to you by an honest host.com.
Get 15% discount on all shared hosting with the offer code HPR15.
That's HPR15.
Better web hosting that's honest and fair at an honesthost.com.
Hacker Public Radio, Brian is the host of Hacker Public Radio Episode 3403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4403 4
I know how you hear I'm out from under my rock I'm subletting and close ofing through another episode. This is part two of my dive into the fourth programming language. And I want to respond first to a nice comment from KG on my last show. And I would love to hear a show about your time at SAO. That's the place where Chuck Moore started working on fourth. It seemed maybe that was at Harvard though in Boston, not in Arizona. I'm not sure but you know as maybe KG cross pass with Chuck.
As far as fourth's readability I find that when looking at fourth code somebody else's fourth code that's starting at the bottom of the listing and working your way up is the way to go. So an example this would be I've made an alarm clock using a popular micro patrol board. And at the very bottom of the listing is a word clock that is defined as setup and operate clock.
And then you work your way up to set up and then set up as a procedure to initialize all the ports and variables and operate a clock is a breakable endless loop that sounds kind of doesn't make any sense but I'll explain when I get to that project in the future.
And that endless loop pulls some of the keys and does some clock stuff and then you can just work your way up through each word to try to to try to understand what's going.
And then the other thing you have to do when you're looking at fourth code is that you have to realize it unlike other languages there.
Fourth, everything in a fourth listing is a word. There is no punctuation. There's no, there is syntax but the syntax is this.
A word is defined by some ASCII characters surrounded by spaces and words are defined and put into the dictionary and that's done by a symbol that we say is colon.
If you didn't know fourth you'd see a colon but that colon isn't just like a punctuation, it's an actual fourth procedure. So there is no syntax sugar in fourth and that's beautiful.
And the reason I think it's beautiful is because it follows. When you program and see the asterisks can mean different things in different contexts but in fourth it has only one definition in the dictionary that you're using.
And that being said an asterisks can mean different things and different well let's go back to the C and see an asterisks can mean multiplication.
It could also mean a pointer and then you get a bunch of asterisks together and you got to figure out is that a pointer to a pointer or a pointer.
So it becomes I think even more confusing than fourth in some ways in the sense that you have to not only look at the symbol you have to figure out from the context what the symbol means which actually kind of makes compilers even more amazing in some ways.
But in fourth it's not that way an asterisks means one thing usually multiplication and it takes two numbers off of the stack and it multiplies them and puts the result back on the stack.
And but you could redefine that if you wanted to and that's the other thing that makes fourth hard to read in that that every fourth dictionary every fourth system is unique.
The old adage is when you've seen one fourth you've seen one fourth and that and that means that because you're building definitions in fourth there's probably no two fourth systems that are going to be exactly like because there are going to be words in that dictionary that are different than other words or not available in other other systems.
But you can always add words and if you have something that you like and you're on a system that it's not there you can probably define it for yourself.
The only thing I will say about that is that two things I'll say about that this makes doing fourth standards difficult because fourth was that mean but I think that by fourth standards there are like the fourth twenty twelve standard has a series of words they consider the core core system and all fourth system should have this and then they have a bunch of different groups of words core extensions and tools and things.
That exist that aren't necessarily required for a fourth system to be fourth twenty twelve compliant but they're there and defined and so as a minimum when you find a word in fourth let's say let's use one definite example here.
So there's a there's a word in fourth spelled dup it's pronounced dupe it does the same thing on all fourth systems it takes the first item on the stack and it puts a copies it and puts that that copy on top of the stack so you end up with two copies of two of the same things on the top of the stack and that dupe works the same on all systems and there's generally you know minimum there's somewhere
between you know there's probably 150 words that you need to to make a minimal fourth system and then you can build from there.
And then so that's so you you'll always find the word dupe in a fourth system but you may not find the word forget in all fourth systems that's that's what that's enough on that.
Lastly another thing you'll find as you as you start working in fourth is because everything has is a word there things are named and you say things so an example would be when you see an exclamation point you'll start saying in your mind store that
exclamation point is a fourth word that takes the value on the top of the stack and stores it in the address that you've provided prior to that the second item on the stack and stores it into that into that register or into that in that place in memory.
It's it's kind of a pointer or your it's a it's a pointer type function that in fourth but what you'll find is you'll be reading a novel and you'll see an exclamation point and you're in your mind will say you'll say store and then you know you falling down the fourth rabbit hole.
So my fall into that rabbit hole starts back in 1984 I was a the Commodore 64 came out that year and unfortunately or fortunately as a case may be unlike some people I was a little bit too old to really get excited about that I was just starting college and college.
At that time still hadn't there weren't a lot of computer wasn't a lot of computer usage in college even though I was a math major we had we did some work on main frames but there was nobody had home computers for the most part and basically I was into into girls cars and airplanes not necessarily in that order but that was my life and so I didn't really get into the early Commodore 64.
Crays of computing I knew they were there and I played with computers a little bit but it wasn't really a core part of what I was doing at the time and and so kind of I kind of missed out on on that part of the early home computer world.
And by 1991 I had a family and I was in the military and I finally got a Commodore 128 and that was the beginning of a lot of computer stuff for me.
I subscribed to a dis magazine called Commodore or it was called load star I think I got every issue of load star still and and they would come in little disks in the mail and you would and it all kinds of cool programs on it that you could mess with and also at that time I basically started playing around on on what was going to become the internet you know bulletin board systems and things like that it was finally at the time money
and energy to try out some of these things is very and became very interested and that's when I kind of got into programming at that time and then from about I'd say from 95 to 2001 I was in the valley of the shadow of death I was a Windows user I didn't really know of anything else but like most people who have switched to Linux who started out as Windows users I became more and more disappointed in the system.
And then I'm pretty sure it was when they made they were going to try to make me pay for an upgrade to maybe the vista or something like that I said forget it and that's when I found out about Linux and started my my my world my move to the world of Linux.
But that's a not maybe another episode for now. So it's about 2002 I found a book in the library called about building a robot that was controlled by transistors and I had always been sort of a little bit interested in electronics and and I thought that would be kind of a fun project to do with my son and so we put together a little robot using transistors and it worked okay
It was kind of a bump against the wall change direction kind of thing very simple but very cool and that was sort of what got me into the maker movement.
2000 and by 2005 maybe 2005 was when I think the first make magazines came out I was building stuff with electronics at that point and the maker movement was really interesting to me I went to some maker fairs and subscribed to the magazine
and tried different things very cool and it was probably at this time that I that I became I had already known that working with microcontrollers was was very cool.
And so I started working I got a basic stamp basic stamp was a system on chip I think we would call it now with a basic interpreter never really did anything with the basic stamp I think I bought it and never really used it but then I bought a pickax.
Pickax was a pick microcontroller with a basic interpreter on I think it was in the e-prom it was it was protected and it you could it was very Arduino like you could but it was in basic you would bite and I knew basic it you know I think everybody by that point and I learned some basic programming skills and the so I played around with pickaxes
and they're they're kind of cool too and I made some stuff flash some LEDs and I don't think I made any big projects and then Arduino came along and I'm not going to go into a whole history of Arduino but when the Arduino boards came out those looked extremely I saw that this is very cool this is not only a board it's a programming environment and there was
are it right at the beginning there was already a lot of cool open source resources out there that you could get projects moving and going using an Arduino and so my first Arduino was actually the make it yourself single board Arduino I think if you dig around their site there's still boards you know there's there's a PDFs
PDFs and find how to make the board and you know I etched my own boards and put it together and drilled out the 5,000 holes that were in that thing it was it was fun and then I bought an Arduino and and just moved on from there but it there came a point there using Arduino that I realized there was limitations in certain things some of the interrupts didn't work
there was like registry access was weird and they did obscure there's a level of obscurity that sometimes you you would find yourself doing something and you go well why did that fail and then you realized the library that you had installed to make whatever hardware work didn't wasn't very well written and it just turns out that you're probably better office for some of these things just to write your own library and that's what I did I think it was with the LCD module
the little character LCD modules that everybody uses that was my first driver that I built and it was kind of cool to see oh this is what's behind all that Arduino code that's like one line of Arduino code is you know 100 lines of C code to get the to get your LCD up and running so again programming the Arduino boards in C
and you end up in that wonderful world of write compile test debug you know you write some code you compile it you throw it on the board you try it out it fails you try to figure out where it fails and you go back and it's just endless kind of cycle that can can be especially if you're if you're compiling a pretty big source file
you can take a little while and it just it's a little bit frustrating but it was what it was and I learned a lot in in programming C and and and I'm not I'm not I'm happy I did it but along this time I also started getting into
Lisp through through my use of EMAX and EMAX and so I learned some Lisp and Lisp is a very cool language and and fourth at its root is a list processing language it it it's a lot like a list
in the sense that it looks through this list of definitions to try to figure out what's what to do next and if it if it can't find it it throws an error if it or tries to make it a number or whatever.
So anyway along comes a I found you know just as as you're searching around a guy and I will put the link in the in the show notes for his site because it's still a live project and it's very cool it's micro Lisp
micro Lisp is Lisp on an ABR microcontroller and so I when I saw this I was like this is very very cool because you're not and you're now you're not doing this right compile test debug cycle you're working at the repel and you can you can type stuff in and see it work and then if you like it you can save it and store it and then recall it as micro Lisp is pretty cool
but it has this limitations it doesn't really give you a lot of coding space on on on the Arduino controller because it's size is pretty big and he's he's sort of tied himself to the Arduino environment for it's you for it's uploading the the base stuff anyway it's it's a cool project but it's I saw it's limitations and it was something I just kind of tinkered with
and then and then during this time I started watching some YouTube videos by Ben Eater Eater.net I think is this thing I'll put links again in the show note for this he is a guy who built one of these no CPU computers on a breadboard and then he and then he's also got some videos on building a 6502 based computer on breadboards now his his videos
are really worth watching very well done he's a really he's got a really great way of explain explain stuff that's pretty complicated yet he does it in a way that you can really understand but that's 6502 is of course the the the core of the
the Commodore computers and so that of course was my early computer life the you know 6502 based and so I thought oh that's kind of cool to do a 6502 single board kind of computer home built things
I found a site 6502.org I think it is and there's all kinds of projects on that on that site and it was there that I discovered fourth in one of the things it was fourth on a 6502 and I started reading about it I did some more looking around and and lo and behold there's fourth there
fourths available for avr microcontrollers so that's when I discovered the first one which is e fourth which is classic there's there's books I'll put some links again
there's books on that show the complete source code for fourth e fourth and it's by written by it was developed by man called Chen Hansen Ting
the book that that's a classic is the Arduino and e fourth very cool book really describes fourth that it's at its roots and is even if you never put e fourth on an on Arduino or anything it's if you're into fourth that's a good book to look at
then I just found another project called am fourth it's very robust it's been around for years and it is fourth for avr microcontrollers and some other boards and it's it's pretty full featured and then I found the fourth that I'm using now which is flash forth
I like flash forth a little better than am fourth because of its its the way it's unified the memory the system doesn't use the e prompt for any part of its actual course system it has some words built in one of them being marker that you have to add to am fourth anyway but it's already built in and there's some other convenience kind of things that are built into flash forth specifically for the avr
that make it avr microcontroller that make it easy to use when you're using fourth on an avr microcontroller I think I will stop there that's how I got into fourth oh I might I might add there is of course micro python out there but you I won't try to avoid using python
I don't really like it so anyway but maybe you'll love micro python but that's another one where you can I guess do stuff right at sort of a repel a command line and get things to work
but I've settled on fourth for my interactions with the microcontrollers and so I'll stop there on the next show I think I'll talk about putting forth on an avr microcontroller board
maybe I'll try to show a few different ones how to get them installed and maybe my little bit of a review of them and then after that I guess this is going to expand more than three shows and then I'll talk about doing that hello world program
but for now it's Brian in Ohio here thanks for listening if you have any comments leave a comment make a show yourself about micro python or anything that sounds cool hackery
oh one last thing oh it's talk about that guy on the internet last show that I listen to where he's talking about working at the command line
very good episode he is a guy who although when I sometimes make comments about apt get and stuff he's not that guy he's he is a guy who's digging learning and I didn't even realize you could do all that stuff with apt get and stuff and searching and very very good episode
and so when I make fun of people using apt get as their solution to a program problem it's not a person like that guy on the internet I'm talking about a person who stops at apt get and doesn't dig any farther who just is happy with the you know just some blind incantation and who knows what ends up on your system so anyway enough of that
until the next show Brian in Ohio signing off and I'd like to say that a life without risk is a life not worth living take care
you've been listening to hecka public radio at hecka public radio dot org we are a community podcast network that releases shows every weekday Monday through Friday today show like all our shows was contributed by an HBR listener like yourself if you ever thought of recording a podcast then click on our contributing to find out how easy it really is
hecka public radio was founded by the digital dog pound and the infonomicon computer club and it's part of the binary revolution at binwreff.com
if you have comments on today's show please email the host directly leave a comment on the website or record a follow up episode yourself unless otherwise status today's show is released under creative comments, attribution, share a life, 3.0 license
you