0
\$\begingroup\$

I would like to program a microcontroller board directly in Assembly (any instruction set) in the most direct way.
I don't want to use any IDE or bootloader code to handle the flashing. My aim is to flash a binary file containing the instructions, directly to memory and have the microcontroller boot from it.
I have noticed that many or the more popular microcontrollers have their own flash tools or very high level IDE interfaces to communicate to the microcontroller.
Can anyone suggest me a specific microcontroller and a method for transferring assembly code to microcontroller?

\$\endgroup\$
6
  • \$\begingroup\$ Depends on your microcontroller, but shopping questions are off-topic here. \$\endgroup\$
    – DKNguyen
    May 5, 2020 at 13:11
  • \$\begingroup\$ I can't think of any microcontroller that doesn't allow this. Relatively simple 8 bit microcontrollers like AVR are probably going to be the easiest to work with, the various programmers can read HEX files and send them to the microcontroller. If you are that masochistic, you can create HEX files by hand and then use just the programmer. \$\endgroup\$ May 5, 2020 at 13:26
  • \$\begingroup\$ Microcontrollers don't run assembly, you still need a compiler. Then it depends on what microcontroller you are using for the tool to flash the binary... \$\endgroup\$
    – Ron Beyer
    May 5, 2020 at 13:29
  • \$\begingroup\$ Yes, just to clarify - you can flash machine code (actual binary instructions) from the HEX file, you cannot flash assembler instructions (e.g. "mov r6,10"). You will have to assemble the instructions into binary machine code. If you want to program in assembly language, then use an assembler to create the HEX files (which is also supported by every microcontroller). If you tell us why you want to do this you might get more useful responses. \$\endgroup\$ May 5, 2020 at 13:39
  • \$\begingroup\$ @RonBeyer incorrect, you would use an assembler, not a compiler. In simple cases as these there is a 1:1 correspondence between assembly instructions and opcodes, so the processor is essentially running the assembly, only in binary form. You can of course generate the opcodes manually, too. \$\endgroup\$ May 5, 2020 at 14:20

1 Answer 1

0
\$\begingroup\$

This is not an uncommon thing to do: you are looking for an assembler. This can be done on any microcontroller. All manufacturers provide tools to do this. Often it is in the same package as those "high level" IDEs. The IDE is merely running the command-line tools for you, whereas you will run them directly.

The easiest way to step into this is would be to use the standard bootloader and write your amount inline inside your C/CPP file using the "asm" directive. Once you are practiced at it, you can then move to writing the assembly code in an .asm file and running the assembler instead of the C compiler. Then you can skip the step of linking to the standard C libraries and standard bootloader, and flash the output directly to the microcontroller.

Supposing you chose Atmel, you could do this two ways:

The simplest would be to purchase a development board like the Arduino. Next download the Arduino IDE to start with inline assembly. Lastly download AVR Studio which is the full development platform.

The bare-metal way would be to purchase an Atmel microcontroller like the AtMega328p + a USB in-circuit programmer (ISP). Then download the AVR Studio. Mount the chip on a breadboard and use the ISP to flash the chip using AVR Studio.

Hopefully I've given you enough keywords that you can find your way from here.

\$\endgroup\$
1
  • \$\begingroup\$ Also, check out the "related" questions that SO is suggesting. There is one talking about different wants to flash microcontrollers, and another talking about how flashing and boot loading works. \$\endgroup\$
    – Moby Disk
    May 5, 2020 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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