


ARM Macro Assembler    Page 1 


    1 00000000         ;ex3_2400 exercises for chapter 3 of  CENG2400. It is fo
                       r your own revision purpose,no need to submit answers to
                        tutors.
    2 00000000         ;1) create a project based on this .s code
    3 00000000         ;2) In keil-ide, use project/rebuild all target files to
                        build the project
    4 00000000         ;3) use Debug/run_to_cursor_line to run the top line of 
                       the program, 
    5 00000000         ;    i.e. movs r0,#1,just under the label ex3_2a 
    6 00000000         ;4)  use the single step mode to view the registers and 
                       cpsr after the execution of each statement
    7 00000000         ;5) Explain the observations and results.
    8 00000000         
    9 00000000         
   10 00000000         
   11 00000000         ; declare variables      New test12D
   12 00000000                 AREA             |.data|, DATA, READWRITE
   13 00000000 00000000 
              00000000 
              00000000 
              00000000 
              00000000 
              00000000 
              00000000 
              00000000 
              00000000 
              00000000 Data1p  DCD              0, 0, 0, 0, 0, 0, 0, 0, 0, 0
   14 00000028                 align
   15 00000028         ;-------------------------------------------------------
                       ------
   16 00000028         
   17 00000028         ; User Initial Stack & Heap
   18 00000028                 AREA             |.text|, CODE, READONLY
   19 00000000         
   20 00000000                 EXPORT           __main
   21 00000000 E59F00FC 
                       __main  LDR              R0, =Data1p
   22 00000004         ;;;;;;;;;;;; CEG2400   ex3_2
   23 00000004         loop_top
   24 00000004         ;clear flags
   25 00000004         
   26 00000004         ex3_2a                               ;;;;;;;;;;;;;;;;;;;
                                                            ;;;;;;;;;;;;;;;
   27 00000004 E3B00001        movs             r0,#1       ; this clears N,Z
   28 00000008 E2900001        adds             r0,#1       ; this clears C,V
   29 0000000C         ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   30 0000000C E3A0100F        mov              r1,#15      ;r1=15
   31 00000010 E3E02000        mov              r2,#0xffffffff ; in 2' compleme
                                                            nt it is -1. 
   32 00000014 E0810002        ADD              r0,r1,r2
   33 00000018 E0A10002        ADC              r0,r1,r2    ;r0=r1+r2+C
   34 0000001C E0410002        SUB              r0,r1,r2    ;r0=r1-r2
   35 00000020 E0C10002        SBC              r0,r1,r2    ;r0=r1-r2+C-1
   36 00000024         ;Question1: explain the result in r0 and cpsr of the abo
                       ve steps .
   37 00000024         
   38 00000024         ex3_2b                               ;;;;;;;;;;;;;;;;;;;
                                                            ;;;;;;;;;;;;;;;
   39 00000024 E3B00001        movs             r0,#1       ; this clears N,Z



ARM Macro Assembler    Page 2 


   40 00000028 E2900001        adds             r0,#1       ; this clears C,V
   41 0000002C         ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   42 0000002C E3E01102        mov              r1,#0x7ffffffF ;=the biggest 32
                                                            -bit 2's complement
                                                             num. +2,147,483,64
                                                            7
   43 00000030 E3A02001        mov              r2,#0x1
   44 00000034 E0910002        ADDS             r0,r1,r2    ;r0=0x80000000.  
   45 00000038         ;Questio2: explain the result in cpsr.
   46 00000038         
   47 00000038         ex3_2c                               ;;;;;;;;;;;;;;;;;;;
                                                            ;;;;;;;;;;;;;;;
   48 00000038 E3B00001        movs             r0,#1       ; this clears N,Z
   49 0000003C E2900001        adds             r0,#1       ; this clears C,V
   50 00000040         ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   51 00000040 E3E01106        mov              r1,#0x7ffffffE ;=the 2nd bigges
                                                            t 32-bit 2's comple
                                                            ment num.  +2,147,4
                                                            83,647-1
   52 00000044 E3A02001        mov              r2,#0x1
   53 00000048 E0910002        ADDS             r0,r1,r2    ; ;
   54 0000004C         ;Question3: explain the result in cpsr.
   55 0000004C         ex3_2D                               ;;;;;;;;;;;;;;;;;;;
                                                            ;;;;;;;;;;;;;;;
   56 0000004C E3B00001        movs             r0,#1       ; this clears N,Z
   57 00000050 E2900001        adds             r0,#1       ; this clears C,V
   58 00000054         ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   59 00000054 E3E01000        mov              r1,#0xFffffffF ; THE VALUE IS -
                                                            1 IN 2'S COMPLEMENT
                                                            
   60 00000058 E3A02001        mov              r2,#0x1     ; IS 1
   61 0000005C E0910002        ADDS             r0,r1,r2    ; ;
   62 00000060         ;Question4: explain the result in r0 and cpsr.
   63 00000060         
   64 00000060         ex3_3                                ;;;;;;;;;;;; CEG240
                                                            0   ex3_3
   65 00000060 E3B00001        movs             r0,#1       ; this clears N,Z
   66 00000064 E2900001        adds             r0,#1       ; this clears C,V
   67 00000068         ;;;;;;;;;;;;;;;;;;;
   68 00000068 E3A01055        mov              r1,#0x55
   69 0000006C E3A02061        mov              r2,#0x61
   70 00000070 E0010002        and              r0,r1,r2    ;
   71 00000074         ;Question5: explain the result in r0 and cpsr.
   72 00000074 E1810002        orr              r0,r1,r2    ;r0=r1 or r2
   73 00000078 E0210002        EOR              r0,r1,r2    ;
   74 0000007C         ;Question6: explain the result in r0 and cpsr.
   75 0000007C E1C10002        BIC              r0,r1,r2    ;Question: 
   76 00000080         ;Question7: explain the result in r0 and cpsr.
   77 00000080         ex3_4                                ;;;;;;;;;;;;;;;;;;;
                                                            ;;;;;;
   78 00000080 E3B00001        movs             r0,#1       ; this clears N,Z
   79 00000084 E2900001        adds             r0,#1       ; this clears C,V
   80 00000088         ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   81 00000088 E3A01003        MOV              r1,#0x3
   82 0000008C E3A02007        MOV              r2,#0x7
   83 00000090 E3A0200C        MOV              r2,#12      ;r2=#12
   84 00000094 E1A00002        MOV              r0,r2       ;
   85 00000098         ;Question8: explain the result in r0 and cpsr.
   86 00000098 E1E01002        MVN              r1,r2       ;Question: explain 



ARM Macro Assembler    Page 3 


                                                            the result in cpsr.
                                                            
   87 0000009C         ;Question9: explain the result in r0 and cpsr.
   88 0000009C         ex3_5                                ;
   89 0000009C E3B00001        movs             r0,#1       ; this clears N,Z
   90 000000A0 E2900001        adds             r0,#1       ; this clears C,V
   91 000000A4         ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   92 000000A4 E3A01011        mov              r1,#0x11    ;r1=0000 0011 (the 
                                                            least significant 8
                                                             bits) 
   93 000000A8 E3A02023        mov              r2,#0x23    ; r2=0000 0023
   94 000000AC E0513002        subs             r3, r1, r2
   95 000000B0         ;Question10: explain the result in r3 and cpsr.
   96 000000B0 E3B00001        movs             r0,#1       ; this clears N,Z
   97 000000B4 E2900001        adds             r0,#1       ; this clears C,V
   98 000000B8 E1510002        cmp              r1,r2       ;   ;
   99 000000BC         ;Question11: explain the result in r0->r12 and cpsr.
  100 000000BC E1A01002        mov              r1,r2       ;    ; r1<=r2
  101 000000C0 E1510002        CMP              r1, r2      ;    
  102 000000C4         ;Question12: explain the result in r0->r12 and cpsr.
  103 000000C4         ex3_6a                               ; place ex6
  104 000000C4 E3B00001        movs             r0,#1       ; this clears N,Z
  105 000000C8 E2900001        adds             r0,#1       ; this clears C,V
  106 000000CC         ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  107 000000CC E3A0100F        mov              r1,#15      ;r1=15 decimal=0xf=
                                                            0000 1111 (the leas
                                                            t significant 8 bit
                                                            s)
  108 000000D0 E3A02018        mov              r2,#24      ;r2=24 =0x18      =
                                                            0001 1000 (the leas
                                                            t significant 8 bit
                                                            s)
  109 000000D4 E1110002        TST              r1,r2       ;
  110 000000D8         ;Question13: explain the result in r0->r12 and cpsr.
  111 000000D8         ;not saved to any registers) is neither nagative nor zer
                       o 
  112 000000D8         ; (bits c,v are not affected by tsts)
  113 000000D8 E3B00001        movs             r0,#1       ; this clears N,Z
  114 000000DC E2900001        adds             r0,#1       ; this clears C,V
  115 000000E0 E1310002        TEQ              r1,r2       ;
  116 000000E4         ;Question14: explain the result in r0->r12 and cpsr.
  117 000000E4         ex3_6b                               ; place ex6
  118 000000E4 E3B00001        movs             r0,#1       ; this clears N,Z
  119 000000E8 E2900001        adds             r0,#1       ; this clears C,V
  120 000000EC         ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  121 000000EC E3A0100F        mov              r1,#0x0f    ;15=0x0f=  0000 111
                                                            1 (the least signif
                                                            icant 8 bits)
  122 000000F0 E3A020F0        mov              r2,#0xf0    ;r2=0x18=  1111 000
                                                            0 (the least signif
                                                            icant 8 bits)
  123 000000F4 E1110002        TST              r1,r2       ; 
  124 000000F8         ;Question15: explain the result in r0->r12 and cpsr.
  125 000000F8 E3B00001        movs             r0,#1       ; this clears N,Z
  126 000000FC E2900001        adds             r0,#1       ; this clears C,V
  127 00000100 E1310002        TEQ              r1,r2       ;
  128 00000104         ;Question16: explain the result in r0->r12 and cpsr.
  129 00000104                 END
              00000000 



ARM Macro Assembler    Page 4 


Command Line: --debug --xref --diag_suppress=9931 --apcs=interwork --depend=.\o
bjects\ex3_2400.d -o.\objects\ex3_2400.o -IC:\Keil_v5\ARM\RV31\INC -IC:\Keil_v5
\ARM\CMSIS\Include -IC:\Keil_v5\ARM\Inc\Philips --predefine="__EVAL SETA 1" --p
redefine="__UVISION_VERSION SETA 520" --list=.\listings\ex3_2400.lst ex3_2400.s



ARM Macro Assembler    Page 1 Alphabetic symbol ordering
Relocatable symbols

.data 00000000

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

Symbol: Data1p
   Definitions
      At line 13 in file ex3_2400.s
   Uses
      At line 21 in file ex3_2400.s
Comment: Data1p used once
2 symbols



ARM Macro Assembler    Page 1 Alphabetic symbol ordering
Relocatable symbols

.text 00000000

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

Symbol: __main
   Definitions
      At line 21 in file ex3_2400.s
   Uses
      At line 20 in file ex3_2400.s
Comment: __main used once
ex3_2D 0000004C

Symbol: ex3_2D
   Definitions
      At line 55 in file ex3_2400.s
   Uses
      None
Comment: ex3_2D unused
ex3_2a 00000004

Symbol: ex3_2a
   Definitions
      At line 26 in file ex3_2400.s
   Uses
      None
Comment: ex3_2a unused
ex3_2b 00000024

Symbol: ex3_2b
   Definitions
      At line 38 in file ex3_2400.s
   Uses
      None
Comment: ex3_2b unused
ex3_2c 00000038

Symbol: ex3_2c
   Definitions
      At line 47 in file ex3_2400.s
   Uses
      None
Comment: ex3_2c unused
ex3_3 00000060

Symbol: ex3_3
   Definitions
      At line 64 in file ex3_2400.s
   Uses
      None
Comment: ex3_3 unused
ex3_4 00000080

Symbol: ex3_4



ARM Macro Assembler    Page 2 Alphabetic symbol ordering
Relocatable symbols

   Definitions
      At line 77 in file ex3_2400.s
   Uses
      None
Comment: ex3_4 unused
ex3_5 0000009C

Symbol: ex3_5
   Definitions
      At line 88 in file ex3_2400.s
   Uses
      None
Comment: ex3_5 unused
ex3_6a 000000C4

Symbol: ex3_6a
   Definitions
      At line 103 in file ex3_2400.s
   Uses
      None
Comment: ex3_6a unused
ex3_6b 000000E4

Symbol: ex3_6b
   Definitions
      At line 117 in file ex3_2400.s
   Uses
      None
Comment: ex3_6b unused
loop_top 00000004

Symbol: loop_top
   Definitions
      At line 23 in file ex3_2400.s
   Uses
      None
Comment: loop_top unused
12 symbols
348 symbols in table
