ARM GAS  abc-3.s 			page 1


   1              	/* --------------------------------------------------
   2              	   Define required labels for EGTAPI
   3              	   -------------------------------------------------- */
   4              	        .global main, Stop, CodeEnd
   5              		.global DataStart, DataEnd
   6              	
   7              		.global a,b,c
   8              	
   9              	/* --------------------------------------------------
  10              	   byte   a = 4;
  11              	   short  b = 5;
  12              	   int    c = 256;
  13              	
  14              	   a = b + c;     //  a = 5 + 256 (overflow !!!)
  15              	   -------------------------------------------------- */
  16              		.text
  17              	main:
  18              	
  19              		// Move b into r1
  20 0000 000000E3 	        movw    r0, #:lower16:b 	// Moves the address of memory
  21 0004 000040E3 	        movt    r0, #:upper16:b 	//   variable b into register r0
  22 0008 F010D0E1 		ldrsh	r1,[r0]			// Move short value from var into r1
  23              						// ** ldrsb also sign-extend to int !!
  24              	
  25              		// Move c into r2
  26 000c 000000E3 	        movw    r0, #:lower16:c 	// Moves the address of memory
  27 0010 000040E3 	        movt    r0, #:upper16:c 	//   variable c into register r0
  28 0014 002090E5 		ldr	r2,[r0]			// Move int value from var into r2
  29              	
  30              		// Add them up
  31 0018 022081E0 		add	r2, r1, r2		// r2 = b + c
  32              	
  33              		// Move sum in r2 to a
  34 001c 000000E3 	        movw    r0, #:lower16:a 	// Moves the address of memory
  35 0020 000040E3 	        movt    r0, #:upper16:a 	// variable a into register r0
  36 0024 0020C0E5 		strb	r2,[r0]			// Move sum in r2 to BYTE var a
  37              	
  38              	
  39              	Stop:
  40              	CodeEnd:
  41 0028 00F020E3 	    	nop
  42              	
  43              	/* --------------------------------------------------
  44              	   Begin of the permanent program variables
  45              	   -------------------------------------------------- */
  46              		.data
  47              	DataStart:
  48              	
  49 0000 04       	a:    .byte   4        // a contains the value 4 in 8  bits
  50 0001 00       	      .align 1
  51 0002 0500     	b:    .2byte  5        // b contains the value 5 in 16 bits
  52              	      .align 2
  53 0004 00010000 	c:    .4byte  256      // c contains the value 256 in 32 bits
  54              	
  55              	DataEnd:
  56              	
  57              		.end
ARM GAS  abc-3.s 			page 2


ARM GAS  abc-3.s 			page 3


DEFINED SYMBOLS
             abc-3.s:17     .text:0000000000000000 main
             abc-3.s:39     .text:0000000000000028 Stop
             abc-3.s:40     .text:0000000000000028 CodeEnd
             abc-3.s:47     .data:0000000000000000 DataStart
             abc-3.s:55     .data:0000000000000008 DataEnd
             abc-3.s:49     .data:0000000000000000 a
             abc-3.s:51     .data:0000000000000002 b
             abc-3.s:53     .data:0000000000000004 c
             abc-3.s:20     .text:0000000000000000 $a
             abc-3.s:50     .data:0000000000000001 $d

NO UNDEFINED SYMBOLS
