A Compiler In Plain Text Also Plays Music

As a layperson reading about some branches of mathematics, it often seems like mathematicians are just people who really like to create and solve puzzles. And, knowing that computer science shares a lot of its fundamentals with mathematics, we can assume that most computer scientists are also puzzle-solvers as well. This latest project from [tom7] shows off his puzzle creating and solving skills with a readable file which is also a paper, which is also a compiler for C programs, which can also play music.

[tom7] started off with the instruction set for the Intel 8086 processor. Of the instructions available, he wanted to use only instructions which are also readable in a text file. This limits him dramatically in what this file will be able to execute, but also sets up the puzzle. He walks through each of the hurdles he found by only using instructions that also code to text, including limited memory space, no obvious way of exiting the program once it was complete, not being able to jump backward in the program (i.e. looping), and a flurry of other issues that come up once the instruction set is limited in this way.

The result is a sort of C compiler which might not be the most efficient way of executing programs, but it sure is the most effective way of showing off [tom7]’s PhD in computer science. As a bonus, the file can also play an antiquated type of sound file due to one of the available instructions being a call for the processor to interact with I/O. If you want to learn a little bit more about compilers, you can check out a primer we have for investigating some of their features.

Thanks to [Greg] for the tip!

Continue reading “A Compiler In Plain Text Also Plays Music”

Tiny Programming Language In 25 Lines Of Code

There are certain kinds of programs that fascinate certain kinds of software hackers. Maybe you are into number crunching, chess programs, operating systems, or artificial intelligence. However, on any significant machine, most of the time those activities will require some sort of language. Sure, we all have some processor we can write hex code for in our head, but you really want at least an assembler if not something sturdier. Writing languages can be addictive, but jumping right into a big system like gcc and trying to make changes is daunting for anyone. If you want a gentle introduction, check out [mgechev’s] language that resides in 25 lines of Javascript.

The GitHub page bills it as a tiny compiler, although that is a bit misleading and even the README says it is a transpiler. Actually, the code reads a simple language, uses recursive descent parsing to build a tree, and then uses a “compiler” to convert the tree to JavaScript (which can then be executed, of course). It can also just interpret the tree and produce a numerical answer.

Continue reading “Tiny Programming Language In 25 Lines Of Code”

Disrupting The Computer Industry Before It Existed: Rear Admiral Grace Hopper

The feature of being easier to write than assembly is often seen as the biggest advantage of high-level programming languages. The other benefit that comes with them is portability. With high-level languages, algorithms can be developed independently from the underlying hardware. This allows software to live on once the hardware becomes obsolete.

The compiler was a concept that was met with resistance when it was first introduced. This was at a time when computers were custom-built machines bearing individual names like ENIAC, UNIVAC and Mark I. A time when the global demand for computers was estimated to be around five units by the CEO of IBM. In this scenario, it took a visionary to foresee a future where the number of computers would outgrow the number of programmers and hardware would evolve so much faster than software that a compiler would make sense. One visionary was [Grace Hopper].

Continue reading “Disrupting The Computer Industry Before It Existed: Rear Admiral Grace Hopper”

Language Parsing With ANTLR

There are many projects that call out for a custom language parser. If you need something standard, you can probably lift the code from someplace on the Internet. If you need something custom, you might consider reading [Federico Tomassetti’s] tutorial on using ANTLR to build a complete parser-based system. [Frederico] also expanded on this material for his book, but there’s still plenty to pick up from the eight blog posts.

His language, Sandy, is complex enough to be a good example, but not too complex to understand. In addition to the posts, you can find the code on GitHub.

Continue reading “Language Parsing With ANTLR”

A Real Hacker’s IDE

We don’t use a GUI IDE, but if we did, it would most certainly be something along the lines of [Martin]’s embedded-IDE project. We’ve always felt that most IDEs are just fancy wrappers around all the tools that we use anyway: Makefiles, diff, git, ctags, and an editor. [Martin]’s project makes them less fancy, more transparent, and more customizable, while retaining the functionality. That’s the hacker’s way — putting together proven standard tools that already work.

The code editor he uses is QScintilla, which uses clang for code completion. The “template” system for new projects? He uses diff and patch to import and export project templates. Because it uses standard tools all along the way, you can install the entire toolchain with sudo apt-get install clang diffutils patch ctags make on an Ubuntu-like system. Whatever compiler you want to use is supported, naturally.

We can’t see a debugger interface, so maybe that’s something for the future? Anyway, if you want a minimalistic IDE, or one that exposes the inner workings of what it’s doing rather than hiding them, then give [Martin]’s IDE a try. If you want more bells and whistles that you’re not going to use anyway, and don’t mind a little bloat and obscuration, many of our writers swear by Eclipse, both for Arduino and for ARM platforms. We’ll stick to our butterflies.

Grace Hopper, Margaret Hamilton, Richard Garwin Named For Medal Of Freedom

Somewhat hidden among athletes, actors, and musicians, three giants of technology have been aptly named as 2016 Presidential Medal of Freedom recipients. Grace Hopper, Margaret Hamilton, and Richard Garwin all made significant contributions to the technology that envelops our lives and embody the quest for knowledge and life-long self learning that we’d like to see in everyone.

Commodore Grace M. Hopper, USN (covered).

Rear Admiral Grace Hopper’s legacy lies with the origins of computer science. She wrote the first compiler. In a time when computers were seen more as calculating machines than easily adaptable frameworks she looked to the future and made it happen. She continued to make huge contributions with lasting effect in developing COBOL, unit testing methods for programmers, and in education. We have long loved her explanation of a nanosecond (and why software engineers shouldn’t waste cycles) and was one of the first to program on the Harvard Mark I which can still be seen in the lobby of the school’s engineering building.

margaret_hamilton_1995As Director of Apollo Flight Computer Programming, Margaret Hamilton is the driving force behind the software of Apollo. When the program started, she was Director of Software Engineering at MIT Instrumentation Laboratory. Originally there wasn’t a plan or budget for software in the space program. Hamilton built the program and led the team who wrote the software and turned it into punch cards to be fed into the computer. We enjoyed reading about some of her adventures during the Apollo project, her drive to develop pristine code is palpable. Over the past year we’ve marveled at the rope memory of the Apollo Guidance Computer and delighted when a hardcopy of AGC software showed up at a party. Her legacy at having written the code for the first portable computer — one that happened to land on the moon and return home safely — is incredible.

richardgarwin1980Physicist Richard Garwin’s name is most associated with the first hydrogen bomb design. But another part of his work is more likely to have directly touched your life: his research into spin-echo magnetic resonance helped lead to the development of Magnetic Resonance Imaging. MRIs have of course become a fundamental tool in medicine. Garwin studied under Fermi during his doctoral work — you may remember Fermi from our look at the Fermiac analog computer last year.

Congratulations to these three recipients, their recognition is incredibly well deserved. We’d love to hear about some of your own technology heroes. Let us know on the tips line so that we may help celebrate their accomplishment and inspire the next generation of giants.

Image Credits:

Lightweight Game Console Packs A Punch

Any maker worth their bits will look for new ways to challenge themselves. [Robert Fotino], a computer science student at the University of California, is doing just that: designing and building his own lightweight hobbyist game console that he has appropriately named Consolite.

[Fotino] wrote his own compiler in C++ that converts from C-like languages to a custom-designed assembler that he has dubbed Consolite Assembly. To test his code, he also wrote an emulator before loading it onto the Mimas V2 FPGA board. Presently, Consolite  uses 64KiB of main memory and 48 KiB of video memory; a future version will have 32 bit support to make better use of the Mimas’ 64 MiB of on board ram, but the current 16-bit version is a functional proof of concept.

consolite-status-leds-and-hardware-switches_thumbnailAn SD card functions as persistent storage for up to 256 programs, which can be accessed using the hardware switches on the Mimas, with plans to add user access in the form of saving game progress, storage outside of main memory, etc. — also in a future update that will include audio support.

As it stands, [Fotino] has written his own versions of Breakout, Tetris, and Tron to show off his project.

Not wanting for diligence, [Fotino] has provided thorough documentation of nearly every step along the way in his blog posts and on GitHub if you are looking for guidelines for any similar projects you might have on the back burner — like an even tinier game console.

[via r/FPGA]