Interworking using veneers

This example shows interworking of source code in assembly code to set registers R0 to R2 to the values 1, 2, and 3 respectively. Registers R0 and R2 are set by the ARM code. R1 is set by the Thumb code. The linker automatically adds an interworking veneer. To use veneers:

Show/hideExample of assembly language interworking using veneers

The following example shows assembly language interworking using veneers.

Example 33. Assembly language interworking using veneers

     ; *****
     ; arm.s
     ; *****

     AREA     Arm,CODE,READONLY   ; Name this block of code.	
     IMPORT   ThumbProg	
     ENTRY                        ; Mark 1st instruction to call.	
     MOV  R0,#1                   ; Set R0 to show in ARM code.	
     BL   ThumbProg               ; Call Thumb subroutine.		
     MOV R2,#3                    ; Set R2 to show returned to ARM.	
                                  ; Terminate execution.	
     MOV  R0, #0x18               ; angel_SWIreason_ReportException	
     LDR  R1, =0x20026            ; ADP_Stopped_ApplicationExit	
     SVC 0x123456                 ; ARM semihosting (formerly SWI)

     ; *******
     ; thumb.s
     ; *******

     AREA  Thumb,CODE,READONLY	    ; Name this block of code.	
     THUMB                        ; Subsequent instructions are Thumb.	
     EXPORT ThumbProg	
     MOVS  R1, #2                 ; Set R1 to show reached Thumb code.	
     BX   lr                      ; Return to the ARM function.	
     END                          ; Mark end of this file.

Show/hideBuilding the example

Follow these steps to build and link the modules:

  1. To assemble the ARM code for interworking, type:

    armasm --debug --apcs=/interwork arm.s
  2. To assemble the Thumb code for interworking, type:

    armasm --thumb --debug --apcs=/interwork thumb.s
  3. To link the object files, type:

    armlink arm.o thumb.o -o count.axf

    Alternatively, to view the size of the interworking veneers, type:

    armlink arm.o thumb.o -o count.axf --info=veneers
  4. Run the image using a compatible debugger with an appropriate debug target.

Show/hideSee also

Copyright © 2010-2012 ARM. All rights reserved.ARM DUI 0471G