This year course includes creating a compiler of course using Syntax Analyzer and Lexical Analyzer, Semantics and of course through all this generate Assembly Code

But also the teaching program includes using at least a little piece of hardware to pass assembly code to it.

Does anyone know a programmable hardware that we can use just for education purposes?

We will pass assembly code to the hardware.

  • 4
    $\begingroup$ Normally assembly code is still symbolic and needs to be further translated to machine code (assembled). But is there a reason that you want to go to actual hardware? Many compiler courses compile for a machine simulator instead. That gives you the chance to use a more rational machine definition than most actual hardware provides. Real machines can be messy. $\endgroup$ – Buffy Aug 18 '17 at 23:53
  • 1
    $\begingroup$ Two additional problems you need to solve with real hardware is (a) a link between the development and target machines, and, (b) if the target has an OS, dealing with that as well. The complications are one reason for using pseudo-hardware instead, so the students can focus on the compilation process itself - especially in a first compiler course. $\endgroup$ – Buffy Aug 19 '17 at 0:00
  • 1
    $\begingroup$ Also, welcome to Computer Science Educators! I have starred this question as one that I am interested in. In my program, we teach on a simulation of the 6502. The limited number of registers and commands make it pretty manageable. I hope to hear more from you around the site. $\endgroup$ – Ben I. Aug 19 '17 at 0:27
  • 1
    $\begingroup$ And the 6502 has a reputation as a pretty clean design. So does the Zilog Z80 if you can find a simulator. Intel hardware tends to be more complicated after the first couple of editions (i.e. 8080). @BenI. have you got a reference for the 6502? Maybe a full answer is warranted. $\endgroup$ – Buffy Aug 19 '17 at 0:52
  • $\begingroup$ Thanks for the answers, Yes the students will build a simple compiler and of course this will generate assembly code (MOV, LOOP, etc). So with this can we play with some hardware or do we need something more? $\endgroup$ – NathanWay Aug 19 '17 at 2:04

My first piece of advice would be to avoid any modern hardware (and possibly to avoid hardware itself, as the simulators out there are pretty good). As far as I can tell, all of the very cheap processors out there right now (such as come with Arduino) use languages like asm, and do not lend themselves to the kind of conceptually clear assembly programming that would presumably be most helpful for your students.

In a prior discussion, I talked about the experience I've had teaching with 6502 Assembly, and I would recommend this course as well. This plucky little processor (and, therefore, its assembly language as well) is about as clean, simple, and streamlined as a processor can be.

Additionally, there is a lovely simulator for the 6502, a complete assembly specification, a community devoted to it, and

And if you do want to continue on to use actual hardware, the following computers used the 6502, many of which are readily available on eBay and the like:

  • Apple IIe.
  • Commodore PET.
  • BBC Micro.
  • Atari 2600.
  • Atari 800.
  • Commodore VIC-20.
  • Commodore 64.
  • $\begingroup$ Thanks a lot fro you answer Ben. Didn't know about this and sounds like a great idea. Im interested in purchasing one of this computers in eBay. What computer do you recommend us to use? And after we have it. How can we pass assmebly code to it? and through what? Thanks. Any manual o explanation? $\endgroup$ – NathanWay Aug 19 '17 at 23:04
  • $\begingroup$ I haven't dealt with the hardware myself, though that complete assembly specification goes so far as to give the byte-code for each processor command. I'd guess that each of the machines provides their own way to enter your assembly programs. (You may need to find a way to transfer files to a 5 1/4 inch floppy disk.) $\endgroup$ – Ben I. Aug 19 '17 at 23:06
  • $\begingroup$ Then that works for me :) Thanks a lot Ben. I'll do a research about this. And I think we will start working in building a compiler for the 6502. Thank you so much for your help :) Greetings. $\endgroup$ – NathanWay Aug 19 '17 at 23:18
  • $\begingroup$ The 6502 ISA, although nice for hand coding, is not the best instruction set target for a modern compiler. The most popular compilers (UCSD Pascal and others) for 6502 PCs targeted an interpreted P-code instead. $\endgroup$ – hotpaw2 Aug 20 '17 at 21:22
  • $\begingroup$ @hotpaw2 I can't find that information anywhere. Where are you seeing that? And also, what p-code was used? Presumably the p-code would be a better match, then, if one were to take this path. $\endgroup$ – Ben I. Aug 21 '17 at 2:28

The 32-bit subsets of ARM assembly language are fairly clean, orthogonal and RISC-like, as well as being a reasonably nice target for a simple compiler.

Inexpensive Raspberry Pi's run 32-bit ARM code, as well as natively supporting a complete compiler development tool set (lex, yak, bison, et.al.)

Almost every student is likely to possess a mobile phone that will also run ARM machine code, and both Apple and Google provide free development tools that allow coding portions of a mobile app (iOS or Android) in ARM assembly language.

The 6502 and 8051 ISAs were not designed for modern compiler output, even though otherwise suitable for teaching hand-coded assembly language and running it on inexpensive (vintage or microcontroller) hardware.

  • $\begingroup$ So, Getting Raspberry Pi's (ej Zero cheapest one), can we get the work done for the students on writing assembly code? $\endgroup$ – NathanWay Aug 20 '17 at 18:36
  • 1
    $\begingroup$ Likely yes. A generic web search turns up tons of sites/pages with tutorials on programming a Pi in ARM ASM. $\endgroup$ – hotpaw2 Aug 20 '17 at 20:40

Dr Michelle Strout (now at University of Arizona) used this approach when she was at Colorado State University.

  1. For hardware, the students used Meggy JR. Students were expected to write simple programs/games using a Java interface to the hardware. Initially, the hardware was purchased as kits and there was a pizza party to assemble it.

  2. The students then wrote compilers for a subset of Java (MeggyJava), using Java. See class web page. The code their compiler created could be executed on the hardware, or in a simulator.

  3. In another year, the students did the same project, See class web page, but the implementation language was in Haskell.

The students enjoyed creating simple games and displays and then using their compiler to realize the result on the physical hardware.

For grading, the course used our autograder to compare the "output" of the instructors compiler (i.e. what did the code do to the state of the Meggy JR when the code was executed on the simulator), to that of the code produced by their compiler.

I hope this helps.


If you want to look at hardware which might also be suitable for programming in C/C++, the BBC micro:bit might be a good alternative to an arduino. It has a more self-contained set of peripherals, and is programmed in ARM assembler. It uses drag-drop style programming (you need an ASCII format hex file) over USB. Of course, you need to set up a tool chain to compile the code, unless you want to write raw hex by hand (or analyse compiled code from the online tool chains). Halting debug (single step and modifying registers) is supported, so it's a capable platform to work on if you want hardware.

In terms of a compiler for Cortex-M0 (as in the micro:bit), the educational toolchains support an in-browser compiler which demonstrates that it's not actually too complicated.

Of course, there is a fair amount of initialisation required if you want to actually turn the LEDs on or look at the push buttons (let alone the SPI accelerometer on board). You might include some assembler within an online compiler C++ project - that ought to work (if you use the ARM mbed toolchain rather than the school specific toolchains).

An alternative is to look at something more low-level, using a verilog simulator (but there is non-trivial cost involved in the simulator which might put this out of reach to schools - it's more targeted at universities who are teaching embedded hardware, and start-ups). The whole Cortex-M3 processor and a supporting system can be downloaded from ARM for free. This runs code (and has a model which prints out disassembly as it runs). - disclaimer - I developed this product.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.