Learning Assembly With A Web Based Assembler

AssemblyOnlineVery few people know assembly. [Luto] seeks to make learning assembly just a little bit easier with his “fully functional web-based assembler development environment, including a real assembler, emulator and debugger.”

These days, you can be a microcontroller expert without knowing a thing about assembly. While you don’t NEED to know assembly, it actually can help you understand quite a bit about embedded programming and how your C code actually works. Writing a small part of your code in assembly can reduce code size and speed things up quite a bit. It also can result in some very cool projects, such as using Java to program microcontrollers.

With high quality example code, it is very easy to get started learning assembly. The emulator consists of a microcontroller with 32 registers, hooked up to three LEDs, two buttons, and a potentiometer. This is way better than painfully learning assembly on real hardware. Be sure to check out the online demo! Being able to step through each line of code and clearly see the result help make assembly easier to use and understand. It would be great to see this kind of tool widely adopted in engineering programs.

Have you used assembly in any of your projects? Let us know how it went and why you choose to use assembly

47 thoughts on “Learning Assembly With A Web Based Assembler

        1. Not really. There may be good reasons to get a certain processor. Maybe you need embedded ethernet for instance, but not a lot of processing. In that case, you get an overpowered CPU for free. Or maybe it’s a commercial application, but not a very high volume, so shorter development time and better code quality outweigh the price advantage of a smaller processor.

        2. @Old’un
          If you think speccing is about picking the processor with just enough power to do the job, you don’t understand the economics/business side of speccing. :V

          The “right” processor is one that does what you need as reliably as you need it done for the lowest price. Sometimes what you need involves features only available on processors with “too much” power. Sometimes you get the best price going with, say, a manufacturer that also makes other components you need, allowing you to reduce cost by reducing the number of orders, even if unit prices aren’t the cheapest.

      1. Typical answer from someone who doesn’t understand Assembly.
        Looks like people who ditch Linux over Windows/Mac just because they’re too afraid of the command line :)

        1. Now I live and breathe command line goodness, but the sentiment you are putting out is just silly. It is like abandoning modern vehicles because they can’t go where horses can.

          Assembly, Linux, BSD, Windows, power drills, and even 3D printers are nothing more than tools. Use the right one and you prosper. Use the wrong one and get left behind. I don’t build out DNS boxes with Windows because it is a waste. Likewise I don’t use linux for mail servers because support and integration in AD is so much better. Assembly is great for one off, very small things or for replacing common calls in other languages. Sometimes a batch file will do the same job and nobody has to spend the better part of a week programming what in another language is two lines of instructions.

          Tools are tools. Not toys, not creeds, and certainly not religions.

          1. It’s not silly as you think. 99% of my customers and/or friends, when I recommend using Linux as an alternative, they just say: “nah, that’s too hard, learning all those commands”. Even when I show them user friendly interfaces, they say: yeh, nice, but no thanks.
            When talking about servers or enterprise envoirement is different. I agree not to use Windows or Linux for certain tasks. It’s not a religious or creeds matter, believe.
            Like you’ve said, tools are just tools.
            But when someone (like opjga) says something like that “ditch 80’s tech”, I’ll use your exampel as well:
            Let’s kill all the horses because we should be driving cars.
            Made myself clear? (english is not my primary language)

      2. It’s not harder to program 8 bit PIC or AVR in assembly than ARM. Assembly is easier to learn than ‘C’. The reason programming is done in ‘C’ is for portability not because it is easier. Some think it is easier in ‘C’ because it come with large libraries set. Those libraries can be used from assembly too.

        I learned to program in assembly in college because at the time (70’s) it was the way microprecessor were programmed, there were no ‘C’ yet.

    1. That depends a lot on the architecture. On platforms with good peripheral support, and a good compiler, you can do a lot of time critical tasks in plain C. In the last 5 years, I only remember one time I had to do something in assembly.

    2. Even in the days of $1 ARM chip, one would still have a need for at least reading Assembly code. Actually *especially* for ARM bare metal coding where the #%& GNU compiler might not come with startup code for your particular microcontroller or ARM SoC out of the thousands of ARM chips. On most other modern chips with a decent compiler, that’s pretty much a non-issue.

      When I use a new compiler, I sometimes look at the assembly code generated to get a feel of the microcontroller and tune my coding style if required. I even do that for CPLD/FPGA HDL.

      Been working on a USB project with a 8051 core. Kind of surprised at how much hand crafted assembly code can help for low level bitbanging as some of the CPU feature are not readily translated to C language.

          1. That may be the case, but that only applies to a small niche of applications where you have your own silicon. Even then, the 8051 makes a poor compiler target. And if you’re planning to write in assembly, there are many alternatives.

          2. 8051 core is kinda like ARM of the 1980’s. It was licensed & dropped into a lot of low ended parts like USB peripherals, data acquisition system. etc.

            TI still make recent SoC parts with a 8051 core. e.g. TI’s CC1110Fx / CC1111Fx. It is not like they don’t have their own microcontroller cores to chooses from.

            If you want to start new, sure go for something else.

      1. >#%& GNU compiler might not come with startup code for your particular microcontroller

        Startup code isn’t part of GCC.. Its part of your standard library like newlib. I guess you self censored the word shit from your post. Not sure how GCC not shipping something it shouldn’t make it shit to be honest.

  1. But which assembly language? Each family of devices has its own, even within a manufacturer – the Cortex-M series don’t share an instruction set with the ARM7TDMI, for example (though they’re similar). Although the low-level bit-twiddling mentality is a constant, learning one doesn’t help all that much when learning another, in my experience, especially if the architectures are very different (ARM vs PIC vs x86, for example).

    1. I think it is some made up language to teach students the basics of assembler. It would be nice if the resulting binaries could work in some real hardware but I have not been able to find any reference on that.

      1. Back in the day, we were taught how to do a 1-bit alu in 74series, then an 8-bit using AMD(?) bitslice, then a board using a Z80. After that we moved to 68k… If that kind of teaching is now lost, we’re all the poorer

    2. Learning new assembly code is no big deal. I have programmed in assembly so many microprocessor and microcontroller I can’t rebember each one. What is time consuming reading datasheet (hundreds of pages) and learning the working of peripherals for a particular MCU but libraries usualy distributed free by manufacturers alleviate this learning curve. Even if one program in ‘C’ one must read datasheets.

  2. Whilst it’s a cool project, I’m not sure I see the use for it. You need assembly when you’ve got a time critical (not just fast, but deterministically fast) bit of code. If you’re in this situation then you’ll already have a microcontroller and you’ll need to be able to write a very specific version of assembly for that particular device, and accessing peripherals via the registers is probably the harder part of it.

    Still think it’s a nice bit of work though. Things don’t have to be useful to be fun.

    It also reminds me of a time when I wrote a 6502 emulator in Basic on a BBC Micro so I could step through and reverse engineer some very complicated assembler. (Trying to crack the copy protection on a game called Elite of I remember correctly. It was decrypting itself just ahead of where it was running using the code itself as a key, so very hard to alter.)

  3. My first love has always been Assembler in its varied flavours which I learned on computers that actually looked like computers with rows of switches and flashing lights, so I gave this thing a go.

    It’s been a long time since I have been reminded of the joys of a clattering ARS-33 TTY eating paper tape for mass storage compared to the mind-numbing teeth-gnashing frustration of submitting Fortran punched card decks to a mainframe, and getting an error printout three days later (if I was lucky enough to get one at all) because my name is down near the end of the alphabet.

    If ever a system was designed to encourage any but the most OCD wannabe programmers to take up flower arranging instead, this is it (‘tho that might not be entirely a bad thing).

    Why on earth anybody thought that it would be better to burn up time, bandwidth and money instead of having the real thing for real hardware on your local machine I simply cannot imagine.

    Like “The Last One”, may it rapidly fade into the historic obscurity it so richly deserves. I’d rather cut off my right arm with a spoon.

    1. The good thing about that type of development cycle, though, is that it forced you to actually think about your code (and check it over just one more time) before submitting a job … I started out in a similar environment, but run into too many “software engineers” nowadays who seem to think that it’s productive to just constantly compile, download or burn, and test, because it’s so quick.

    1. Maybe not an “expert”, but you can do many useful things with a microcontroller without ever having to see or write a single line of assembly. That is especially true of C friendly architectures like Cortex, where you can even write startup code and interrupt handlers in 100% standard C.

    2. Agree completely but gonna take it lower where it belongs. One cannot be a computer expert without knowing machine language. Can be an expert on an OS and higher level languages but not the computer, That OS and languages were written so you didn’t have to be an expert and don’t even need to know what it is you should know to be an actual expert.
      Try hand assembling machine language for the processor from it’s datasheet using 8 toggle switches and an enter pushbutton. Then do that for at least 3 processors. Learn what a “monitor” is. Hint: it doesn’t emit any light. Learn the difference between relative and absolute addressing, Discover and learn the registers, eat sleep and breath POP and PUSH. Learn to keep a running count of your STACK position and contents. Suffer through building a UART interface with FSK for a cassette tape deck so you can reload your code “instantly” rather than uses those dreadful switches to load your monitor every time you power up. Drool over the chips to add 1024 more bytes of Static RAM to your 128 Byte computer. Struggle with funding till you can afford a 2704 or 2708 in which to hold your monitor so you never, ever, have to use those horrid switches and pushbutton to enter that same code first every day ever, ever again. Wire up a huge switch matrix and write code to scan it, giving you your first keyboard, then write the code for it and add it to your EPROM Monitor. Buy a dynamo labelmaker and make your own keycaps. Start scraping together money to get the RAM chips for your first 8K memory board. Got back and build a 2nd UART and FSK and get an acoustic coupler to run up exorbitant phone bills to reach out to a long distance BBS’s and download CODE FOR FREE!

      Another 20 yrs and there won’t be a single computer expert anywhere in the world. Just users.

      Can’t be an expert if you don’t know Machine Language.

  4. “””Very few people know assembly.”””

    This statement doesn’t really stand on its own. Among general humanity, yes, very few people know assembly. Among HAD readers, I would imagine that somewhere in the region of 10% of people have at least some experience with it. In the same sense I would expect maybe 50% of HAD readers are conversant with C or Pascal or similar HLLs.

    I learned IA-32 as my first ASM adventure and got a much better understanding of how computers work as a result. Nowadays I’m mainly doing Propeller PASM code and the occasional bit of AVR assembly.

    Even though often ASM code itself isn’t easily portable, the SKILLS of assembly programming definitely are transferrable. If you can do one type of assembly then there’s only a shallow learning curve to move to another architecture.

    Unfortunately, assembly has apparently earned a reputation for being difficult, intimidating or unforgiving. Anything that makes ASM more accessible to people is great in my opinion, as it will dispel this reputation for many.

    A very worthy project, bravo.

    1. “Even though often ASM code itself isn’t easily portable, the SKILLS of assembly programming definitely are transferrable”

      Definitely. It’s like learning Latin, then having an easy time learning Italian and French and Romanian and Spanish.

  5. I’m 19 years old and wrote my own ARM7TDMI-S interpreter (as part of a Nintendo Gameboy Advance emulator). I also write test ROMs for the emulator myself in assembly from time to time. The reason I use assembly for this is that I want full knowledge of what hardware features are used in which way. Maybe this is hope to some of the older generations. :D

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.