   1              	
   2              	/* --------------------------------------------------
   3              	   Define required labels for EGTAPI
   4              	   -------------------------------------------------- */
   5              	        .global main, Stop, CodeEnd, DataStart, DataEnd
   6              	
   7              		.global myMethod
   8              	
   9              	/* --------------------------------------------------
  10              	   Begin of the program instructions
  11              	   -------------------------------------------------- */
  12              		.text
  13              	main:
  14 0000 570400E3 		mov	r0, #1111
  15 0004 571400E3 		mov	r1, #1111
  16 0008 020000EB 		bl	A
  17 000c AE2800E3 		mov	r2, #2222
  18 0010 AE3800E3 		mov	r3, #2222
  19              	
  20              	
  21              	Stop:
  22 0014 0000A0E1 		nop
  23              	
  24              	A:
  25 0018 04E02DE5 		push	{lr}
  26 001c 570400E3 	        mov     r0, #1111
  27 0020 571400E3 	        mov     r1, #1111
  28 0024 020000EB 	        bl      B
  29 0028 AE2800E3 	        mov     r2, #2222
  30 002c AE3800E3 	        mov     r3, #2222
  31              	
  32 0030 04F09DE4 		pop     {pc}
  33              	
  34              	B:
  35 0034 04E02DE5 	        push    {lr}
  36 0038 570400E3 	        mov     r0, #1111
  37 003c 571400E3 	        mov     r1, #1111
  38 0040 020000EB 	        bl      C
  39 0044 AE2800E3 	        mov     r2, #2222
  40 0048 AE3800E3 	        mov     r3, #2222
  41              	
  42 004c 04F09DE4 		pop     {pc}
  43              	
  44              	C:
  45 0050 04E02DE5 	        push    {lr}
  46 0054 570400E3 	        mov     r0, #1111
  47 0058 571400E3 	        mov     r1, #1111
  48 005c 020000EB 	        bl      D
  49 0060 AE2800E3 	        mov     r2, #2222
  50 0064 AE3800E3 	        mov     r3, #2222
  51              	
  52 0068 04F09DE4 		pop     {pc}
  53              	
  54              	
  55              	
  56              	D:
  57 006c 04E02DE5 		push	{lr}
  58 0070 570400E3 	        mov     r0, #1111
  59 0074 571400E3 	        mov     r1, #1111
  60 0078 04F09DE4 		pop	{pc}
  61              	        
  62              	
  63              	
  64              	
  65              	CodeEnd:
  66 007c 0000A0E1 	    	nop
  67              	
  68              	/* --------------------------------------------------
  69              	   Begin of the permanent program variables
  70              	   -------------------------------------------------- */
  71              		.data
  72              	DataStart:
  73              	
  74              	DataEnd:
  75              	
  76              		.end
DEFINED SYMBOLS
/home/cs255001/cs255/demo/8-sub/demo1.s:13     .text:0000000000000000 main
/home/cs255001/cs255/demo/8-sub/demo1.s:21     .text:0000000000000014 Stop
/home/cs255001/cs255/demo/8-sub/demo1.s:65     .text:000000000000007c CodeEnd
/home/cs255001/cs255/demo/8-sub/demo1.s:72     .data:0000000000000000 DataStart
/home/cs255001/cs255/demo/8-sub/demo1.s:74     .data:0000000000000000 DataEnd
/home/cs255001/cs255/demo/8-sub/demo1.s:14     .text:0000000000000000 $a
/home/cs255001/cs255/demo/8-sub/demo1.s:24     .text:0000000000000018 A
/home/cs255001/cs255/demo/8-sub/demo1.s:34     .text:0000000000000034 B
/home/cs255001/cs255/demo/8-sub/demo1.s:44     .text:0000000000000050 C
/home/cs255001/cs255/demo/8-sub/demo1.s:56     .text:000000000000006c D

UNDEFINED SYMBOLS
myMethod
   1              	
   2              		.global	malloc, print
   3              		.global	stdout_start, stdout_end
   4              	
   5              	// **********************************************
   6              	// malloc: simulate memory allocate
   7              	//
   8              	// This function will NOT change ANY registers
   9              	// (I.e.: will preserve ALL registers)
  10              	// **********************************************
  11              	malloc:
  12 0000 0E002DE9 		push 	{r1, r2, r3}		// Save scratch registers
  13              	
  14 0004 001000E3 		movw	r1, #:lower16:maddr
  15 0008 001040E3 		movt	r1, #:upper16:maddr	// r1 = &maddr
  16 000c 003091E5 		ldr	r3, [r1]		// r3 = maddr 
  17              	
  18              		// --------------------------------------
  19              	        // Make new maddr (divisible by 8)
  20              	        // --------------------------------------
  21              	
  22 0010 002083E0 		add	r2, r3, r0		// New maddr
  23 0014 082082E2 		add	r2, r2, #8		// Making sure it increase
  24              	
  25 0018 0700A0E3 		mov	r0, #0x7		// r0 = 0000..00111
  26 001c 0000E0E1 		mvn	r0, r0			// r0 = 1111..11000
  27 0020 002002E0 		and	r2, r2, r0		// Knock off the last 3 bits
  28 0024 002081E5 		str	r2, [r1]		// Update maddr 
  29              	
  30              	
  31              		// --------------------------------------
  32              		// Return to caller
  33              		// --------------------------------------
  34 0028 0300A0E1 		mov	r0, r3			// Return maddr value in r0
  35 002c 0E00BDE8 		pop  	{r1, r2, r3}		// Restore scratch registers
  36 0030 0EF0A0E1 		mov	pc, lr			// Return
  37              	
  38 0034 00000400 	maddr:	.word 0x40000		// Start address of the heap
  39              	
  40              	
  41              	// *******************************************************************
  42              	// print: simulate print output in Egtapi
  43              	//
  44              	//	input: r0 = address of string
  45              	//	       r1 = # characters to write
  46              	//
  47              	// Egtapi will show ASCII data stored starting at stdout_start
  48              	// until stdout_end  in its output area
  49              	//
  50              	// This function will NOT change ANY registers
  51              	// (I.e.: will preserve ALL registers)
  52              	// *******************************************************************
  53              	print:
  54 0038 1C002DE9 		push	{r2, r3, r4}            	// Save scratch registers
  55              	
  56 003c 002000E3 	        movw    r2, #:lower16:stdout_end
  57 0040 002040E3 	        movt    r2, #:upper16:stdout_end	// r2 = &stdout_end
  58 0044 002092E5 	        ldr     r2, [r2]                	// r2 = stdout_end
  59              	
  60 0048 0130A0E1 		mov	r3, r1			// r3 = # char to copy
  61              	
  62              	printLoop:
  63 004c 000053E3 		cmp	r3, #0
  64 0050 0500000A 		beq	printDone
  65              	
  66 0054 0040D0E5 		ldrb	r4, [r0]		// Get next char
  67 0058 0040C2E5 		strb	r4, [r2]		// Write next char
  68              	
  69 005c 010080E2 		add	r0, r0, #1
  70 0060 012082E2 		add	r2, r2, #1
  71              	
  72 0064 013043E2 		sub	r3, r3, #1
  73              	
  74 0068 F7FFFFEA 		b	printLoop
  75              	
  76              	printDone:
  77 006c 2040A0E3 		mov	r4, #32			// Space
  78 0070 0040C2E5 		strb	r4, [r2]
  79 0074 012082E2 		add	r2, r2, #1
  80              	
  81 0078 003000E3 	        movw    r3, #:lower16:stdout_end
  82 007c 003040E3 	        movt    r3, #:upper16:stdout_end	// r2 = &stdout_end
  83 0080 002083E5 		str	r2, [r3]
  84              	
  85 0084 1C00BDE8 		pop  	{r2, r3, r4}		// Restore scratch registers
  86 0088 0EF0A0E1 		mov	pc, lr			// Return
  87              		
  88              	
  89              		
  90              	
  91 008c 00000500 	stdout_start: 	.word 0x50000		// This value remains unchanged
  92 0090 00000500 	stdout_end: 	.word 0x50000
  93              	
  94              	
  95              		.end
DEFINED SYMBOLS
/home/egtapi/lib/cs255lib.s:11     .text:0000000000000000 malloc
/home/egtapi/lib/cs255lib.s:53     .text:0000000000000038 print
/home/egtapi/lib/cs255lib.s:91     .text:000000000000008c stdout_start
/home/egtapi/lib/cs255lib.s:92     .text:0000000000000090 stdout_end
/home/egtapi/lib/cs255lib.s:12     .text:0000000000000000 $a
/home/egtapi/lib/cs255lib.s:38     .text:0000000000000034 maddr
/home/egtapi/lib/cs255lib.s:38     .text:0000000000000034 $d
/home/egtapi/lib/cs255lib.s:54     .text:0000000000000038 $a
/home/egtapi/lib/cs255lib.s:62     .text:000000000000004c printLoop
/home/egtapi/lib/cs255lib.s:76     .text:000000000000006c printDone
/home/egtapi/lib/cs255lib.s:91     .text:000000000000008c $d

NO UNDEFINED SYMBOLS
