EECS 373 SoftConsole Assembly Readme

Create and setup a new assembly project

  1. File > New > C Project
    1. Type project name
    2. Select the location that will be the project folder. If default workspace is selected, then a project folder with the given project name is automatically created in the workspace.
    3. Under Project type: select Empty Project under Executable (Managed Make)
    4. Under Toolchains: select Actel Cortex-M3 Tools
    5. Click Finish
  2. Right click on the project folder in the Project Explorer (left window pane) and select Properties. Then go to C/C++ Build and expand it. Select Settings and look at the Tool Settings tab.
    1. GNU Linker > General - Check everything BUT Omit all symbol information (-s)
    2. GNU Linker > Miscellaneous - In Linker flags add -T../link.ld (actual linker script will be added to project later)
    3. GNU Assembler > General - In Assembler flags add -g3 (for debugging assembly code)
    4. Click Apply and then OK

Create minimum running assembly code (Labs 2 and 3)

Use Right click > Save Link as...(Firefox) or Save Target as...(IE) to get the files.

  1. Add startup.s and link.ld to the project by dragging (or cut and pasting) the files from Window’s Explorer to the project folder in SoftConsole Project Explorer.
  2. Create a function main in a user created assembly file (File > New > Source File) with a .s extention

Create fully capable assembly code (Interrupts and printf373) Lab4

Use Right click > Save Link as...(Firefox) or Save Target as...(IE) to get the files.

  1. Add startupWithInt.s (instead of startup.s from above), printf373.c, printf373.h, and link.ld (same as above) to the project by dragging (or cut and pasting) the files from Window’s Explorer to the project folder in SoftConsole Project Explorer.
  2. Add this CMSIS folder to the project folder (you can use Import or cut and paste the whole upzipped folder into Project Explorer).
  3. Import only the mss_uart folder (generated by Libero IDE) from the concurrent FPGA project. They contain the UART drivers required to print strings to terminal.
  4. You can accomplish this by right clicking your project, then select Import. On the next window select File System under General and click Next. Browse to your Libero FPGA Project folder and select the firmware subfolder. Then click OK. Expand the firmware folder, and then expand the drivers folder. Add a check mark to the mss_uart folder. Then click Finish. You can safely overwrite already existing files.

  5. Create a function main in a user created assembly file (File > New > Source File) with a .s extention

How to build (compile) projects

Under Project > Clean:

  1. Check Clean projects selected below
  2. Check the project (only one) you want
  3. Check Start a build immediately and Build only selected projects
  4. Click OK.

Clean build is prefered but Hammer icon works in most cases. It is faster because it doesn't clean before compiling.

Final assembled code location

After the code is built, check the project_name.lst file under Debug folder in the Project Explorer

Debugging session

Creating NEW Debug configuration (only done once)

  1. Make certain the code has compiled successfully.
  2. Go to Project Explorer > project_folder > Right-Click > Debug As > Debug Configurations...
  3. In the left pane, under Actel Cortex-M3 RAM Target, delete any New Configuration entries using
  4. Create a new Debug configuration by selecting Actel Cortex-M3 RAM Target and clicking
  5. Make sure Project (Optional): and C/C++ Appliation: are filled as shown below. If not, then you did NOT build/compile your project.
  6. Finally, click Debug.

Running Debug once configuration exits

  1. If the configuration exits, jump to Eclipse's debug window by clicking on the Debug button at the top right.
  2. Now choose this project's debug configuration by selecting it from the drop down list of (De)bug button

How to use printf373() with assembly

Copy paste the following UART_0 initialization code at the begining of the main function. Make sure that you are not overwriting registers when you copy/paste this inside your code.
@ Initalize MSS UART 0
movw r0, #:lower16:g_mss_uart0
movt r0, #:upper16:g_mss_uart0
movw r1, #:lower16:57600 @ UART Baudrate
movt r1, #:upper16:57600
mov r2, #3
bl MSS_UART_init
Create strings as shown below. Place any string after .text symbol but before the first function name .global fun_name in an assembly file.
strName: 	.asciz "print the number: %d\n\r"
strName2: .asciz "xyz\n\r"
strName3: .asciz "so on...\n\r"
.align 2
strNameX: is the address of the string. .asciz tells the assembler to create a null terminate version of the given string. .align 2 tells the assembler to pad odd length strings to make them a multiple of 2. This is required for assembly debugging.
Finally, call printf373 like any other function. The first parameter is the string address. The rest of the parameters are all the variables to be printed. The variable value is passed in r1, not the pointer to the variable.  For example, if you are to use strName from above, pass the pointer to the string strName in r0 and the value that you want to print in r1. 
movw	r0,	#:lower16:strName
movt r0, #:upper16:strName
movw r1, 1 @in this case we are printing the value 1 in decimal. The output will appear "print the number: 1"
bl printf373

Putty and FunTerminal Setup

SmartFusion Serial Port 

Two USB cables are used with the SmartFusion kits. One is for the Debug port for SoftConsole and programming the FGPA. The other is for supply power and acts as a standard serial port (UART). A special driver is installed in the 373 load to "convert" the USB port to a UART on COM3. You can see this via the device manager (My Computer -> Properties -> Hardware tab -> Device Manager).  Note since this is a USB device the USB cable has to be plugged and attached to the SmartFusion board.

FunTerminal is a very simple, free terminal program and is not installed in the program directory. You can find it in C:funterminal. Directly execute by clicking on the executable FUNterm-102. Right click on the executable to add to desk top or pin to start menu.  You may need to set the COMM port and baud rate under Comm--> Config. Set to COM3, 57600 BAUD.

Putty is a common , free terminal and should be installed on the current  373 load. Go to the program menu or find it in the start menu. If it is not available you can download it  here

  1. Under Session, check Serial
  2. Under Connection > Serial: Use the following settings: Baud - 57600, Data bits - 8, Parity - None, Stop bits - 1, Flow control - none.


  1. Be extremely cautious when copy/pasting assembly code. Over writing critical register values is incredibly easy.
  2. Use Instruction Stepping Mode to force the debugger to only step one instruction at a time, even in assembly. Sometimes the debugger seems to mistake branches for functions and skips entire code segments.

  3. Debugger troubleshooting tips:
    1. Hardfault Handler when paused - asserts and segfaults causes the processors get stuck here
    2. 0x6000XXXX address when paused - MSS Configurator Bootcode issue if not using eNVM. Restart Flashpro and reflash the board.
  4. .data section should be utilized for global variables if the .text section moves to Flash. However, the .data section is not initialized for now.
  5. Other than branch to main in the Reset Handler and the actual vector table itself, no other start code should be required. The debug session sets everything up for us.