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

Comments

  1. Telimektar says:

    Nice, in these days asembly still make sense. On time critical and precious tasks its not replaceable.

    • opjga says:

      Replaceable if you ditch 80’s tech (8-bit PICs and AVRs) and start using modern 32-bit ARM micros.

      • Old'un says:

        Hah. If you don’t dip into asm at some point, you’ve overspecced the processor. Certainly in the commercial world.

        • Trui says:

          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.

        • Blue Footed Booby says:

          @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.

      • cpldcpu says:

        This is funny, because actually the ARM was conceived in the 80ies, and the AVR in the 90ies.

        PIC is 70ies, though.

      • Filipe YaBa Polido says:

        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 :)

        • respectacle says:

          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.

          • Filipe YaBa Polido says:

            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)

      • Jacques says:

        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.

    • Trui says:

      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.

    • tekkieneet says:

      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.

      • Telimektar says:

        8051 its still good choice today. Look at Sillicon Labs 8051 – heavy tuned core with modern functionalities.

        • Trui says:

          Maybe if you have a lot of 8051 legacy code… but name one good reason for preferring 8051 in a new application.

          • MikrySoft says:

            8051 core is public domain. You can implement it in your own silicon for free.

          • Trui says:

            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.

          • tekkieneet says:

            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.

      • cantido says:

        >#%& 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.

      • Jacques says:

        It’s not the responsability of GNU compiler team to support every ARM MCU on market, it is the manufacturer responsability.

  2. cooperised says:

    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).

    • jimmy_pop says:

      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.

    • tekkieneet says:

      It would be nice of the next course would teach students to make FPGA core for that CPU so that they get an appreciation of what’s going on behind the assembly.

      • Old'un says:

        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

    • Old'un says:

      It helps a lot. Z80 experience allowed me to be sufficiently familiar with ARM to be coding it within an afternoon

    • Jacques says:

      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.

  3. Andrew says:

    MPLAB, anyone?

  4. 0xfred says:

    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.)

  5. seba says:

    Here’s about the best security CTF I know, and it also features a web-based assembler. https://microcorruption.com/ Really nice for learning about security and assembly

  6. Luc Dijon says:

    This remind me my fisrt steps in assembly in the 80ies with my Vic20 & C64 with the 6502/6510. Thanks to bring back to us these so good souvenirs

  7. AussieTech says:

    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.

    • Len says:

      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.

  8. pcf11 says:

    $ apt-cache search assembler | wc -l
    70
    Nah thanks, I’m good here.

  9. a_comment says:

    That is complete nonsense!! You can not be microcontroller expert without knowing a thing about assembly!

    • Trui says:

      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.

    • Biomed says:

      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.

  10. w says:

    “””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.

  11. arturdent says:

    If you’re looking for real 8bit (Z80, 8080, 6502) assembler, try http://www.asm80.com – some description here: http://www.uelectronics.info/2013/12/21/online-assembler-ide-for-old-cpus/ It is used in online assembler course http://strojak.cz (in Czech) for embedding pieces of code which student can assemble and emulate directly in a browser.

  12. Ted R says:

    I thought this was done years ago with sites like 6502asm.com and so on?

  13. svofski says:

    I made my own online 8080 assembler when I needed one – http://sensi.org/~svo/i8080/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 97,511 other followers