


ARM Macro Assembler    Page 1 


    1 00000000         ;%ex5a_2400 (v.16)
    2 00000000         ;*********************** version 16*********************
                       **
    3 00000000         ;remember to set /flash/linker/use memory layout from ta
                       rget dialog, otherwise it will not run
    4 00000000         ;and stack_pointer SP (r13) will not be set correctly.
    5 00000000         ;*******************************************************
                       ************
    6 00000000         ;ex5_2400 exercises for chapter 5 of  CENG2400. It is fo
                       r your own revision purpose,no need to submit answers to
                        tutors.
    7 00000000         ;1) create a project based on this .s code
    8 00000000         ;2) In keil-ide, use project/rebuild all target files to
                        build the project
    9 00000000         ;3) use Debug / run_to_cursor_line to run the top line o
                       f the program, 
   10 00000000         ;4) In Debug mode/view/memory_windows,use the single ste
                       p mode to 
   11 00000000         ;    view the changes of memory locations( from 0x400004
                       1c), 
   12 00000000         ;    registers after the execution of each statement.
   13 00000000         ;5) Answer the questions and explain the observations an
                       d results.
   14 00000000         ;Note: top of stack is at 0x40000428 in lpc213x systems.
                       
   15 00000000         ;This exercise demonstrates how stack is used in subrout
                       ine call to preserved registers contents
   16 00000000         
   17 00000000         ; declare variables   New test12D
   18 00000000                 AREA             |.data|, DATA, READWRITE
   19 00000000 00000000 
              00000000 
              00000000 
              00000000 
              00000000 
              00000000 
              00000000 
              00000000 
              00000000 
              00000000 Data1p  DCD              0, 0, 0, 0, 0, 0, 0, 0, 0, 0
   20 00000028                 align
   21 00000028         ;-------------------------------------------------------
                       ------
   22 00000028         
   23 00000028         ; User Initial Stack & Heap
   24 00000028                 AREA             |.text|, CODE, READONLY
   25 00000000         
   26 00000000                 EXPORT           __main
   27 00000000         __main                               ;
   28 00000000         loop1                                ; 
   29 00000000 E3A00001        MOV              r0, #1      ;save 1 into r0
   30 00000004 E3A01002        MOV              r1, #2      ;save 2 into r1
   31 00000008 E3A02003        MOV              r2, #3      ;save 3 into r2
   32 0000000C         ;question1:what is the value in r13 now?
   33 0000000C EB000001        BL               subroutine
   34 00000010         ;question5:what is the value in r0 now?
   35 00000010 E1A00000        NOP
   36 00000014 EAFFFFF9        B                loop1
   37 00000018         



ARM Macro Assembler    Page 2 


   38 00000018         
   39 00000018 E82D4007 
                       subroutine
                               STMED            r13!, {r0-r2,r14} ;save r0,r1,r
                                                            2,r14 in  stack
   40 0000001C         
   41 0000001C         ;question2:what is the value in r13 now and why?
   42 0000001C         ;saved in stack
   43 0000001C         ; and r13-decremented 4x4=16=0x10 times , so 0x40000428-
                       0x10=0x40000418
   44 0000001C         ;r13-
   45 0000001C         ;question3:what are stored in the stack ?
   46 0000001C E3A00004        MOV              r0,#4       ;save 4 into r0
   47 00000020 E3A01005        MOV              r1,#5       ;save 5 into r1
   48 00000024 E3A02006        MOV              r2,#6       ;save 6 into r2
   49 00000028 E9BD4007        LDMED            r13!,{r0-r2,r14} ;get back r0,r
                                                            1,r2,r14 from stack
                                                            
   50 0000002C         ;question4:what is the value in r13 now?
   51 0000002C E12FFF1E        BX               LR
   52 00000030         
   53 00000030                 END
Command Line: --debug --xref --diag_suppress=9931 --apcs=interwork --depend=.\o
bjects\ex51a_2400s.d -o.\objects\ex51a_2400s.o -IC:\Keil_v5\ARM\RV31\INC -IC:\K
eil_v5\ARM\CMSIS\Include -IC:\Keil_v5\ARM\Inc\Philips --predefine="__EVAL SETA 
1" --predefine="__UVISION_VERSION SETA 520" --list=.\listings\ex51a_2400s.lst e
x51a_2400s.s



ARM Macro Assembler    Page 1 Alphabetic symbol ordering
Relocatable symbols

.data 00000000

Symbol: .data
   Definitions
      At line 18 in file ex51a_2400s.s
   Uses
      None
Comment: .data unused
Data1p 00000000

Symbol: Data1p
   Definitions
      At line 19 in file ex51a_2400s.s
   Uses
      None
Comment: Data1p unused
2 symbols



ARM Macro Assembler    Page 1 Alphabetic symbol ordering
Relocatable symbols

.text 00000000

Symbol: .text
   Definitions
      At line 24 in file ex51a_2400s.s
   Uses
      None
Comment: .text unused
__main 00000000

Symbol: __main
   Definitions
      At line 27 in file ex51a_2400s.s
   Uses
      At line 26 in file ex51a_2400s.s
Comment: __main used once
loop1 00000000

Symbol: loop1
   Definitions
      At line 28 in file ex51a_2400s.s
   Uses
      At line 36 in file ex51a_2400s.s
Comment: loop1 used once
subroutine 00000018

Symbol: subroutine
   Definitions
      At line 39 in file ex51a_2400s.s
   Uses
      At line 33 in file ex51a_2400s.s
Comment: subroutine used once
4 symbols
338 symbols in table
