Function Definition

The label which is associated with the start of the function should be the link name of the function. The following table shows an example of the link name of a pure assembly language function.

Table 1. Example of the Link Name for an Assembly Language Function
C Code Link Name
my_asm_func _my_asm_func

The labels defined in an assembly file have local scope. To access them from the other file (the .c file) they should be marked as global. For example,

  .global  _my_asm_func  
Note: Make sure that both on the caller and the callee side, the function has same signature and calling convention.

The following listing is an example of a pure assembly language function.

Listing: Sample Code - A Pure Assembly Language Function
.global _my_asm_func
.text

_my_asm_func:

 subq.l   #4,a7

 move.l   d1,(a7)

 add.l    (a7),d0

 addq.l   #4,a7

 rts