Path: home => avr main => how-to => assemble win    (Diese Seite in Deutsch: Flag DE) Logo
How-To logo

How-to assemble a source code file for win users

A demo asm program The following assumes that you have a source code file, written for AVR assembler, and you want to assemble it.

The example program here is named "my_asm_code.asm". As you see, it is a simple text file, that you can view and change with a simple editor. It's content is shown here in a notepad window.

To the top of that page, to the Q+A page

Step 1: Get the gavrasm assembler for win

gavrasm location All you need is a command line assembler for your operating system. And here is one: it is my own one. It already knows all symbols for all AVR types, so you do not have to care about those files that ATMEL provides with its studio software. To get gavrasm navigate with your favoured webbrowser here.

Executable for win So here is the latest executable of gavrasm for win. Download it with a right-click to the folder where your assembler source code resides.

Zipped file As it is packed in a zipped file, you will have to unzip it. A rightclick on it offers you to unzip it. It unzips to a new folder, so navigate into that folder and move the three unzipped files to your folder with the source code.

Unzipped files So this is how your source code folder should like like: it should have the gavrasm.exe file, the assembler exceutable, a file named instr.asm - holding all instructions that the assembler code for AVR has and which you can assemble as a test case -, and the file ReadMe.txt.

The binary executable of gavrasm is provided for 64 bit versions of Windows. If you have a 32 bit Windows, an old DOS, or any other operating system, go back to the gavrasm download page, download and unpack the provided pascal source code files, download and install fpc for your operating system and compile your own executable, e.g. with

c:\FPC\2.6.4\win64\bin\i386-win32\ppcrossx64 -Xs -B gavrasm


To the top of that page, to the Q+A page

Step 2: getting familiar with gavrasm

ReadMe for gavrasm So these are the first 56 lines of the ReadMe.txt. This tells you anything that is necessary to assemble with gavrasm. Whenever you start again, you should consult these lines as you will understand the command line options of gavrasm.

To the top of that page, to the Q+A page

Step 3: creating a batch file to start gavrasm

Making a batch file Only dumb nerds love to type in all the same stupid pathes, options and filenames over and over again. We prefer having that once written and stored in a batch file.
Within the source code folder, create a text file and name it "assemble.bat".

Batch lines With a rightclick on the batch file and "Edit" the file opens in an editor, presumably notepad. Type in these lines. The "D:\asm_howto" should rather be the path to the folder where YOUR source code resides. Save that batch file.

To the top of that page, to the Q+A page

Step 4: Starting the assembler

gavrasm run So this is what appears if you run that batchfile by double-clicking on it: a black window opens and the output of gavrasm appears. The window tells you anything that gavrasm found notifyable: warnings and errors. In the example case it outputs one warning: gavrasm uses the integrated symbols instead of searching for external files. You can ignore that warning. At the end it says "No errors", and that is what you want to see.

To the top of that page, to the Q+A page

Step 5: The output of the assembler

Created files The assembler has created two new files with the same name like the source code, but with the extensions .lst and .hex. If your source code would use EEPROM, a third file with the extension .eep would be created. If you source code produces error messages those would be listed in a fourth file with the extension .err.

List file The list file can be opened with an editor and displays this content. Here you will find all necessary info on the hex code generated, on errors and warnings, and a symbol list telling you anything about those symbols that were found.

This symbol list at the end of the .lst file is unique for gavrasm, you will not find this in other assemblers. It lists all symbols that your source code uses, such as the AVR type (symbol type T, a gavrasm internal number encoding the device type), the register names used (symbol type R - useful if you did not define the registers in an ordered list), the names of constants used (symbol type C) and - of course - their decimal and hex values in case you need to know, and all label addresses (symbol type L) in your source code, so you are enabled e.g. to find a table in your source code.

Hex file And this is the generated hex file. This file can be send to the burner software to write it to the AVR's flash memory and to execute it there.

To the top of that page, to the Q+A page

©2014-2017 by