Home > User Support > CoverageMaster winAMS FAQ

CoverageMaster winAMS FAQ

Test Data Settings

301_02: How to test a function written in assembly?

Question:

Can I unit test a function written in assembly?

Answer:

Yes you can. CoverageMaster has the functionality to perform unit testing for functions written in assembly and measure C0 (statement) coverage.

C functions are defined using the specific structure enclosed by { }. However, there is no fixed structure for assembly functions, and users can freely write instructions at arbitrary addresses to create assembly functions.

<Assembly Function Example>

SUB_ASM_FUNC: ; (Start address label)
      SUBR: 
      MOV        R6, #12H 
      MOV        R7, #10H 
      ADD        R6, R7 
      MOV        R0, R6 
END_SUB_ASM_FUNC:  ; (End address label)
      NOP 

Therefore, to test an assembly function with CoverageMaster, the user must define the range of the assembly function by specifying the function start position and function end position.

In the above example, the start of the assembly function is the label SUB_ASM_FUNC, and the end of the function is the label END_SUB_ASM_FUNC.

The procedure to unit test an assembly function is as follows.

1. Click "Create CSV" and select "Start/End Address Test CSV" as the CSV file type.

2. Check the "Run from start address" checkbox.
(With this setting the test is executed from the specified assembly start address. If it is not checked, the PC (program counter) must be set to the assembly start address in the startup command file.

3. Check the "Assembly code" checkbox.
(This setting records C0 coverage from the start address to the end address.)

4. Select the "All Variables" tab and check the "Show assembly labels" checkbox.

5. Select the start address label from the variable list and click the "Select ->" button next to "Start Address".

6. Select the end address label from the variable list and click the "Set -->" button next to "End Address". If there is no end address label, specify the address value directly.

7. Set the other Input and Output variables used by the function (internal registers can be specified as Input or Output variables for assembly function tests).

Note: Inline assembly code written in a C function can be executed, but the coverage for each instruction cannot be measured.

 

Related Technical Tips Search

Other technical tips in GAIO's web site can be searched for using the links below.

Search key word link: Assembly language
Technical Tips Google Search


Information Links