Arm Lpc2148codesfinallll
Arm Lpc2148codesfinallll
Arm Lpc2148codesfinallll
AREA ADD,CODE,READONLY
ENTRY
LDR R0,=0X12345678
LDR R1,=0X11223344
ADD R2,R0,R1
STOP B STOP
END
MEMORY TIME
CODE 24B 0.583us
AREA ADD,CODE,READONLY
ENTRY
LDR R0,=0X12345678
LDR R1,=0X11223344
SUB R2,R0,R1
STOP B STOP
END
MEMORY TIME
CODE 24B 0.583us
AREA ADD,CODE,READONLY
ENTRY
LDR R0,=0X12345678
LDR R1,=0X11223344
LDR R2,=0X11111111
LDR R3,=0X22222222
ADD R4,R0,R1
ADC R5,R2,R3
STOP B STOP
END
memory time
code 44b 1.166us
AREA ADD,CODE,READONLY
ENTRY
LDR R0,=0X12345678
LDR R1,=0X11223344
LDR R2,=0X11111111
LDR R3,=0X22222222
SUB R4,R0,R1
SUB R5,R3,R2
STOP B STOP
END
memory time
code 44b 1.166us
5. ARM CODE TO CHECK IF A NUMBER IS POSITIVE OR NEGATIVE IF ITS POSITIVE SUBTRACT 1 AND
IF ITS NEGATIVE ADD 1
AREA POSNEG,CODE,READONLY
ENTRY
MOVS R0,R1
ADDMI R0,R0,#0X01
SUBPL R0,R0,#0X01
STOP B STOP
END
memory time
code 16b 1.166us
6. ARM CODE TO CHECK IF A NUMBER IS EVEN OR ODD,IF ITS EVEN ADD 0 IF ITS ODD ADD 1
AREA EVODD,CODE,READONLY
ENTRY
ADDCS R1,R1,#0X01
ADDCC R1,R1,#0X00
STOP B STOP
END
memory time
code 16b 0.249us
CODE1:
AREA ADD532,CODE,READONLY
ENTRY
LDR R0,=0X12345678
LDR R1,=0X11223344
LDR R2,=0X12341111
LDR R3,=0X11111111
LDR R4,=0X22222222
ADD R5,R0,R1
ADC R5,R5,R2
ADC R5,R5,R3
ADC R5,R5,R4
STOP B STOP
END
CODE2:
AREA ADD32,CODE,READONLY
ENTRY
LDR R0,=0X40000000
LDR R1,=0X40000000
MOV R2,#0X04
LDR R3,[R0],#4
ADD R3,R3,R4
SUBS R2,R2,#0X01
BNE LOP
STR R3,[R1]
STOP B STOP
END
EXECUTION PROFILING :
MEMORY TIME
CODE1 60b 1.582us
CODE2 40b 3.165us
CODE1:
AREA SUB532,CODE,READONLY
ENTRY
LDR R0,=0X22222222
LDR R1,=0X12345678
LDR R2,=0X12222222
LDR R3,=0X11112222
LDR R4,=0X11111111
SUB R5,R0,R1
SUB R5,R5,R2
SUB R5,R5,R3
SUB R5,R5,R4
STOP B STOP
END
CODE2:
AREA ADD32,CODE,READONLY
ENTRY
LDR R0,=0X40000000
LDR R1,=0X40000000
MOV R2,#0X04
LDR R3,[R0],#4
SUB R3,R3,R4
SUBS R2,R2,#0X01
BNE LOP
STR R3,[R1]
STOP B STOP
END
MEMORY TIME
CODE1 60b 1.582us
CODE2 40b 3.165us
CODE1:
AREA LAR,CODE,READONLY
ENTRY
CMP R0,R1
MOVCS R3,R0
MOVCC R3,R1
STOP B STOP
END
CODE2:
AREA LAR,CODE,READONLY
ENTRY
SUBS R5,R0,R1
MOVCS R3,R0
MOVCC R3,R1
STOP B STOP
END
MEMORY TIME
CODE1 16B 0.249us
CODE2 16B 0.249us
10. ARM CODE TO FIND THE SMALLEST
CODE1:
AREA LAR,CODE,READONLY
ENTRY
CMP R0,R1
MOVCS R3,R1
MOVCC R3,R0
STOP B STOP
END
CODE2:
AREA LAR,CODE,READONLY
ENTRY
SUB R5,R0,R1
MOVCS R3,R1
MOVCC R3,R0
STOP B STOP
END
MEMORY TIME
CODE1 16B 0.249us
CODE2 16B 0.249us
AREA SUBDIV,CODE,READONLY
ENTRY
SUBPL R0,#0X04
ADDPL R1,R1,#0X01
CMP R0,#0X04
BPL LOOP
STOP B STOP
END
MEMORY TIME
CODE 24B 1.583us
12.ARM CODE FOR MULTIPLYING A NUMBER BY 5 USING ADDITION LOGIC
CODE1.
AREA MULADD,CODE,READONLY
ENTRY
MOV R0,#0X05
ADDNE R2,R2,R1
SUBNE R0,R0,#0X01
B LOOP
STOP B STOP
END
CODE2.
AREA MULADD2,CODE,READONLY
ENTRY
MOV R0,#0X02
STOP B STOP
END
MEMORY TIME
CODE1 24B 1.832us
C0DE2 12B 0.166us
13. ARM CODE TO FIND THE LARGEST IN AN ARRAY OF 5 32 BIT NUMBERS
AREA MAXC2,CODE,READONLY
ENTRY
MOV R0,#0X04
LDR R1,=ARRAY
LDR R2,[R1],#4
LDR R5,=0X40000000
LOOP LDR R3,[R1],#4
CMP R2,R3
MOVCS R2,R2
MOVCC R2,R3
SUBS R0,R0,#0X01
BNE LOOP
STOP B STOP
ARRAY DCD 0X55554411,0X44567890,0X12341111,0X11111111,0X22222222
END
CODE2:
AREA LARGEST,CODE
ENTRY
MOV R5,0X05;
LDR R1,=0X40000000;
LDR R2,[R1],#04;
LOOP LDR R4,[R1],#04
CMP R2,R4
BCC LOOP1
MOV R2,R4
LOOP1 SUBS R5,R5,#1
BNE LOOP
STOP B STOP
END
MEMORY TIME
CODE1 64B 25ms
CODE2 40B 4.75us
AREA MAXC2,CODE,READONLY
ENTRY
MOV R0,#0X04
LDR R1,=ARRAY
LDR R2,[R1],#4
LDR R5,=0X40000000
LOOP LDR R3,[R1],#4
CMP R2,R3
MOVCC R2,R2
MOVCS R2,R3
SUBS R0,R0,#0X01
BNE LOOP
STOP B STOP
ARRAY DCD 0X55554411,0X44567890,0X12341111,0X11111111,0X22222222
END
CODE2:
AREA LARGEST,CODE
ENTRY
MOV R5,0X05;
LDR R1,=0X40000000;
LDR R2,[R1],#04;
LOOP LDR R4,[R1],#04
CMP R2,R4
BCC LOOP1
MOV R2,R4
LOOP1 SUBS R5,R5,#1
BNE LOOP
STOP B STOP
END
MEMORY TIME
CODE1 68B 4.08us
CODE2 40B 48ms
AREA ZO,CODE,READONLY
ENTRY
ADDCS R1,R1,#0X01
ADDCC R2,R2,#0X01
ADDCS R1,R1,#0X01
ADDCC R2,R2,#0X01
ADDCS R1,R1,#0X01
ADDCC R2,R2,#0X01
ADDCS R1,R1,#0X01
ADDCC R2,R2,#0X01
STOP B STOP
END
CODE2:
AREA ZO,CODE,READONLY
ENTRY
LDR R0,=0X40000000
LDR R1,[R0]
MOV R2,#0X08
ADDCC R4,R4,#0X01
ADDCS R5,R5,#0X01
SUBS R2,R2,#0X01
BNE LOP
STOP B STOP
END
MEMORY TIME
CODE1 52B 0.913us
CODE2 36B 4.92us
16.ARM CODE TO FIND THE NUMBER OF EVEN NUMBERS IN AN ARRAY OF 5 32 BIT NUMBERS
AREA EV32,CODE,READONLY
ENTRY
MOV R0,#0X05
LDR R1,=ARRAY
ADDCC R4,R4,#0X01
SUBS R0,R0,#0X01
BNE LOOP
STOP B STOP
END
MEMORY TIME
CODE 56B 3.917us
17. ARM CODE TO FIND THE NUMBER OF ODD NUMBERS IN AN ARRAY OF 5 32 BIT NUMBERS
AREA EV32,CODE,READONLY
ENTRY
MOV R0,#0X05
LDR R1,=ARRAY
ADDCS R4,R4,#0X01
SUBS R0,R0,#0X01
BNE LOOP
STOP B STOP
END
MEMORY TIME
CODE 56B 3.917us
18.ARM CODE TO FIND THE NUMBER OF POSITIVE NUMBERS IN AN ARRAY OF 5 32 BIT NUMBERS
AREA POS32,CODE,READONLY
ENTRY
MOV R0,#0X05
LDR R1,=ARRAY
CMP R2,#0X00
ADDPL R3,R3,#0X01
SUBS R0,R0,#0X01
BNE LOOP
STOP B STOP
END
memory Time
code 56b 3.917us
AREA POS32,CODE,READONLY
ENTRY
MOV R0,#0X05
LDR R1,=ARRAY
CMP R2,#0X00
ADDMI R3,R3,#0X01
SUBS R0,R0,#0X01
BNE LOOP
STOP B STOP
END
memory Time
code 56b 3.917us
20. .ALP TO ADD TWO ARRAY ELEMENTS AND SAVE THE ANSWER IN THIRD ARRAY
AREA ARRAYSUM,CODE,READONLY
ENTRY
LDR R3,=0X40000000
LDR R2,=ARRAY1
LDR R4,=ARRAY2
MOV R5,#0X05
LDR R6,[R4],#4
ADD R7,R0,R6
STR R7,[R3],#4
SUBS R5,R5,#1
BNE ADD
STOP B STOP
END
MEMORY TIMETAKEN
CODE1 92B 7.754us
AREA EVSUM,CODE,READONLY
ENTRY
MOV R3,#0
MOV R5,#0X05
LDR R0,=0X40000000
MOVS R6,R2,ROR #1
ADDCC R3,R3,R2
SUBS R5,R5,#0X01
BNE LOOP
STOP B STOP
END
MEMORY TIME TAKEN
CODE 36bytes 3.833us
AREA ODSUM,CODE,READONLY
ENTRY
MOV R3,#0
MOV R5,#0X05
LDR R0,=0X40000000
MOVS R6,R2,ROR #1
ADDCC R3,R3,R2
SUBS R5,R5,#0X01
BNE LOOP
STOP B STOP
END
MEMORY TIME TAKEN
CODE 36bytes 3.833us
23. ALP TO FIND THE SUM OF ALL THE NEGATIVE NUMBERS IN AN ARRAY
AREA NEG,CODE,READONLY
ENTRY
MOV R3,#0
MOV R0,#0X05
LDR R1,=0X40000000
CMP R2,#0X00
ADDMI R3,R3,R2
SUBS R0,R0,#0X01
BNE LOOP
STOP B STOP
END
AREA EVSUM,CODE,READONLY
ENTRY
MOV R3,#0
MOV R0,#0X05
LDR R1,=0X40000000
CMP R2,#0X00
ADDPL R3,R3,R2
SUBS R0,R0,#0X01
BNE LOOP
STOP B STOP
END
AREA ASC,CODE,READONLY
ENTRY
MOV R0,#0X05
MOV R3,#0X04
IN LDR R1,[R5]
LDR R2,[R6]
CMP R1,R2
BCC LOP
MOV R4,R2
MOV R2,R1
MOV R1,R4
STR R2,[R6]
ADD R5,R5,#4
ADD R6,R6,#4
SUBS R3,R3,#0X01
BNE IN
SUBS R0,R0,#0X01
BNE LOOP
STOP B STOP
END
MEMORY TIME TAKEN
CODE 80bytes 35.585us
AREA ASC,CODE,READONLY
ENTRY
MOV R0,#0X05
ADD R6,R5,#4
MOV R3,#0X04
IN LDR R1,[R5]
LDR R2,[R6]
CMP R1,R2
BCS LOP
MOV R4,R2
MOV R2,R1
MOV R1,R4
STR R2,[R6]
ADD R5,R5,#4
ADD R6,R6,#4
SUBS R3,R3,#0X01
BNE IN
SUBS R0,R0,#0X01
BNE LOOP
STOP B STOP
END
MEMORY TIME TAKEN
CODE 80bytes 35.997us
AREA ASC,CODE,READONLY
ENTRY
MOV R0,#0X03
ADD R6,R5,#4
MOV R3,#0X02
LDR R2,[R6]
CMP R1,R2
BCC LOP1
MOV R4,R2
MOV R2,R1
MOV R1,R4
STR R2,[R6]
ADD R5,R5,#4
ADD R6,R6,#4
SUBS R3,R3,#0X01
BNE IN1
SUBS R0,R0,#0X01
BNE LOOP1
MOV R0,#0X02
ADD R6,R5,#4
MOV R3,#0X01
IN LDR R1,[R5]
LDR R2,[R6]
CMP R1,R2
BCS LOP
MOV R4,R2
MOV R2,R1
MOV R1,R4
STR R2,[R6]
ADD R5,R5,#4
ADD R6,R6,#4
SUBS R3,R3,#0X01
BNE IN
SUBS R0,R0,#0X01
BNE LOOP
STOP B STOP
END
MEMORY TIME
CODE 156 15.2us
28.(25)DEVELOP A ARM CODE FOR:
a) AREA CCODE,CODE,READONLY
ENTRY
CMP R0,#00
BEQ LOOP
SUB R1,R0,#1
B STOP
STOP B STOP
END
MEMORY TIME
28B 0.416us
b) AREA CCODE,CODE,READONLY
ENTRY
MOV R0,#06;(a)
CMP R0,#5
BPL LOOP1
SUB R1,R0,#1
B STOP
STOP B STOP
END
MEMORY TIME
CODE 28B 0.416us
AREA FIBBO,CODE
ENTRY
MOV R0,#00
SUB R0,R0,#01
MOV R1,#01
MOV R4,#10
LDR R2,=0X40000000
STR R0,[R2],#4
MOV R3,R0
MOV R0,R1
MOV R1,R3
SUBS R4,R4,#01
BNE BACK
STOP B STOP
END
MEMORY TIME
CODE 52B 8.58us
AREA GENE_EVEN,CODE,READONLY
ENTRY
MOV R0,#2
LDR R1,=0X40000000
MOV R2,#10
ADD R0,R0,#2
SUBS R2,R2,#1
BNE LOOP
STOP B STOP
END
MEMORY TIME
CODE 32B 5.915us
AREA ODD,CODE,READONLY
ENTRY
MOV R0,#1
LDR R1,=0X40000000
MOV R2,#10
ADD R0,R0,#2
SUBS R2,R2,#1
BNE LOOP
STOP B STOP
END
MEMORY TIME
CODE 32B 5.915us
32.FINDING SQUARE OF A NUMBER WITHOUT USING MULTIPLICATION
AREA SQUARE_MUL,CODE,READONLY
ENTRY
MOV R0,#3
MOV R1,#00
MOV R2,R0
SUBS R2,R2,#1
BNE LOOP
STOP B STOP
END
MEMORY TIME
CODE 28B 1.332us
33.MULTIPLY A NUMBER BY 23 USING SHIFT LOGIC
AREA SHIFT23,CODE,READONLY
ENTRY
MOV R0,#3
MOV R1,R0
MOV R2,R0
MOVS R1,R1,LSL#4
MOVS R2,R2,LSL #3
ADD R2,R1,R2
SUBS R3,R2,R0
STOP B STOP
END
MEMORY TIME
CODE 32B 0.581us
34.DEVELOP ARM CODE FOR THE FOLLOWING C PROGRAM CODES
a)
AREA C1,CODE,READONLY
ENTRY
MOV R1,#0X02
MOV R2,#0X05
MUL R0,R1,R2
SBS
END
MEMORY TIME
CODE 16B 0.167us
b)
AREA C1,CODE,READONLY
ENTRY
MOV R4,#0X02
MOV R2,#0X0A
MUL R3,R4,R2
SBS
END
MEMORY TIME
CODE 16B 0.333
c)
AREA C1,CODE,READONLY
ENTRY
MOV R3,#0X02
MOV R2,#0X0F
MUL R7,R3,R2
SBS
END
MEMORY TIME
CODE 16B 0.333
d)
AREA C1,CODE,READONLY
ENTRY
MOV R0,#5
MOV R1,#2
CMP R0,R1
BPL LOOP1
MOV R3,#7
MUL R4,R3,R1
ADD R2,R0,R4
B STOP
LOOP1 MOV R5,#4
MUL R6,R5,R1
ADD R2,R0,R6
STOP B STOP
END
MEMORY TIME
CODE 48B 0.832us
e)
AREA CCODE,CODE,READONLY
MOV R5,#2
MOV R6,#5
MOV R0,#1;A
MOV R1,#1;B
MOV R2,#1;C
CMN R5,R6
BEQ LOOP1
LOOP MUL R3,R0,R1
MUL R4,R1,R2
MUL R7,R0,R2
ADD R8,R3,R4
ADD R9,R8,R7
LOOP1
EOR R3,R0,R1
EOR R3,R3,R2
STOP B STOP
END
MEMORY TIME
CODE 60B 1.414us
AREA SEARCHSTRING,CODE,READONLY
ENTRY
LDR R0,=STRING
CMP R2,#'B'
ADDEQ R3,R3,#1
CMP R2,#0
BNE LOOP
STOP B STOP
END
MEMORY TIME
CODE 36B 2.582us
AREA COUNT,CODE,READONLY
ENTRY
LDR R0,=STRING
CMP R2,#SPACE
ADDEQ R3,R3,#1
CMP R2,#0
BNE LOOP
STOP B STOP
END
MEMORY TIME
CODE 44B 4.833us
AREA CMP_STR,CODE,READONLY
ENTRY
LDR R0,=STRING1
LDR R1,=STRING2
MOV R9,R0
MOV R10,R1
MOV R8,#0
CMP R2,#0
ADD R3,R3,#1
BNE LOOP
CMP R4,#0
ADD R5,R5,#1
BNE LOOP1
CMP R3,R5
BNE STOP
LDRB R7,[R10],#1
CMP R6,R7
ADDEQ R8,R8,#1
CMP R6,#0
BNE LOOP2
CMP R8,R3
ADDEQ R11,R11,#1
STOP B STOP
END
MEMORY TIME
CODE 116B 8.08us
AREA REV,CODE
ENTRY
LDR R0,=STRING
LDR R10,=0X40000000
MOV R2,#00
CMP R1,#0
ADDNE R3,R3,#1
BNE LOOP
SUBS R0,R0,#2
STRB R1,[R10],#1
SUBS R3,R3,#1
BNE LOOP1
STOP B STOP
END
MEMORY TIME
CODE 64B 10.749us
AREA STRING,CODE
ENTRY
LDR R0,=STRIN
MOV R1,#00
BEQ STOP
ADD R1,#1
B LOOP
STOP B STOP
END
MEMORY TIME
CODE 44B 4.667us
AREA PALIN,CODE,READONLY
ENTRY
LDR R0,=0X40000000
LDR R1,=ARRAY
MOV R10,R1
BNE LEN
MOV R4,R3
MOV R1,R10
STRB R2,[R0],#1
SUBS R3,R3,#1
BNE SEC
MOV R1,R10
SUB R0,R0,#1
LDRB R6,[R1],#1
CMP R5,R6
SUBS R4,R4,#1
BNE CCMP
END
MEMORY TIME
CODE 96B 13.746us
41.BLOCK EXCHANGE
a) DATA TO STACK
AREA BT,CODE,READONLY
ENTRY
LDR R13,=0X40000020
LDR R7,=0X40000000
LDMFD R13,{R1-R3}
MOV R6,R1
SWP R1,R6,[R7]
ADD R7,#4
MOV R6,R2
SWP R2,R6,[R7]
ADD R7,#4
MOV R6,R3
SWP R3,R6,[R7]
STMIA R13,{R1-R3}
S B S
END
MEMORY TIME
CODE 52B 2.33us
AREA BT,CODE,READONLY
ENTRY
MOV R3,#3
LDR R5,=0X40000020
LDR R7,=0X40000000
MOV R6,R1
SWP R1,R6,[R7]
STR R1,[R5]
ADD R5,#4
ADD R7,#4
SUBS R3,#1
BNE LOP
S B S
END
MEMORY TIME
CODE 48B 4.082us
b)DATA TO DATA
AREA BT,CODE,READONLY
ENTRY
MOV R3,#3
LDR R5,=0X40000020
LDR R7,=0X40000000
MOV R6,R1
SWP R1,R6,[R7]
STR R1,[R5]
ADD R5,#4
ADD R7,#4
SUBS R3,#1
BNE LOP
S B S
END
MEMORY TIME
CODE 48B 4.082us
2. USING LDM/STM
AREA BT,CODE,READONLY
ENTRY
LDR R5,=0X40000020
LDR R7,=0X40000000
LDM R5,{R1-R3}
MOV R6,R1
SWP R1,R6,[R7]
ADD R7,#4
MOV R6,R2
SWP R2,R6,[R7]
ADD R7,#4
MOV R6,R3
SWP R3,R6,[R7]
STM R5,{R1-R3}
S B S
END
MEMORY TIME
C0DE 52B 2.33us
42.BLOCK TRANSFER
1.USING LDM/STM
AREA BT,CODE,READONLY
ENTRY
LDR R5,=0X40000020
LDR R7,=0X40000000
LDMIA R7,{R2-R4}
STMIA R5,{R2-R4}
SBS
END
MEMORY TIME
CODE 20B 0.916us
AREA BT,CODE,READONLY
ENTRY
LDR R1,=0X40000020
LDR R0,=0X40000000
MOV R5,#0X03
STR R2,[R1],#4
SUBS R5,#0X01
BNE LOOP
SBS
END
MEMORY TIME
CODE 32B 2.332us
b)CODE TO DATA
1.WITHOUT LDM/STM
AREA BT,CODE,READONLY
ENTRY
LDR R1,=ARRAY
LDR R0,=0X40000000
MOV R5,#0X03
STR R2,[R0],#4
SUBS R5,#0X01
BNE LOOP
SBS
END
MEMORY TIME
CODE 48B 2.499us
2.WITH LDM/STM
AREA BT,CODE,READONLY
ENTRY
LDR R1,=ARRAY
LDR R0,=0X40000000
MOV R5,#0X03
LDMIA R1,{R2-R4}
STMIA R0,{R2-R4}
SBS
END
MEMORY TIME
CODE 40B 1.166us
c)DATA TO STACK
1.USING LDM/STM
AREA BT,CODE,READONLY
ENTRY
LDR R1,=0X40000010
LDR R0,=0X40000000
MOV R5,#0X03
LDMFD R1,{R2-R4}
STMIA R0,{R2-R4}
SBS
END
MEMORY TIME
CODE 24B 0.999uS
AREA BT,CODE,READONLY
ENTRY
LDR R1,=0X40000020
LDR R0,=0X40000000
MOV R5,#0X03
STR R2,[R1],#4
SUBS R5,#0X01
BNE LOOP
SBS
END
MEMORY TIME
CODE 32B 2.332uS
THUMB PROGRAMS:
AREA T32ADD,CODE,READONLY
ENTRY
CODE32
LDR R0,=THUMB+1
BX R0
CODE16
LDR R2,=0X20000000
ADD R1,R2
LDR R3,=ARM
BX R3
CODE32
STR R1,[R4]
STOP B STOP
END
MEMORY TIME
CODE 48BYTES 2.083 MICROSECOND
AREA T32SUB,CODE,READONLY
ENTRY
CODE32
LDR R0,=THUMB+1
BX R0
CODE16
LDR R2,=0X20000000
SUB R1,R2
LDR R3,=ARM
BX R3
CODE32
STR R1,[R4]
STOP B STOP
END
MEMORY TIME
CODE 48BYTES 2.083 MICROSECOND
AREA T64ADD,CODE,READONLY
ENTRY
CODE32
LDR R0,=THUMB+1
BX R0
CODE16
LDR R2,=0X20000000
LDR R3,=0X40000001
LDR R4,=0X10000000
ADD R1,R2
ADC R3,R4
LDR R5,=ARM
BX R5
CODE32
STR R1,[R6]
ADD R6,#0X04
STR R3,[R6]
STOP B STOP
END
MEMORY TIME
CODE 68BYTES 2.666 MICROSECOND
AREA T64SUB,CODE,READONLY
ENTRY
CODE32
LDR R0,=THUMB+1
BX R0
CODE16
LDR R2,=0X20000000
LDR R3,=0X40000001
LDR R4,=0X10000000
SUB R1,R2
SBC R3,R4
LDR R5,=ARM
BX R5
CODE32
STR R1,[R6]
ADD R6,#0X04
STR R3,[R6]
STOP B STOP
END
MEMORY TIME
CODE 68BYTES 2.666 MICROSECOND
5. TO CHECK POSITIVE
AREA TPOS,CODE,READONLY
ENTRY
CODE32
LDR R1,=0X40000000
LDR R0,=THUMB+1
BX R0
CODE16
CMP R2,#0X00
BPL POS
BMI NEG
NEG B STOP
STOP B STOP
END
CODE2:TO CHECK OF A GIVEN NUMBER IS POSITIVE OR NOT(CODE2)
AREA TPS,CODE,READONLY
ENTRY
CODE32
LDR R3,=0XFFFFFFFF
LDR R1,=0X40000000
LDR R0,=THUMB+1
BX R0
CODE16
AND R3,R2
LSL R3,#1
BCC POS
BCS NEG
NEG B STOP
STOP B STOP
END
MEMORY TIME
CODE 1 32BYTES 1.583 MICROSECOND
CODE 2 36 BYTES 1.748 MICROSECOND
AREA TPS,CODE,READONLY
ENTRY
CODE32
MOV R5,#0X05
LDR R1,=0X40000000
LDR R0,=THUMB+1
BX R0
CODE16
ADD R1,#0X04
CMP R2,#0X00
BPL POS
BMI N
BNE THUMB
BEQ STOP
N SUB R5,#0X01
BNE THUMB
BEQ STOP
STOP B STOP
END
AREA TPS,CODE,READONLY
ENTRY
CODE32
MOV R5,#0X05
LDR R3,=0XFFFFFFFF
LDR R1,=0X40000000
LDR R0,=THUMB+1
BX R0
CODE16
AND R3,R2
LSL R3,#1
BCC POS
BCS NE
SUB R5,#0X01
BNE THUMB
BEQ STOP ;
NE SUB R5,#0X01
BNE THUMB
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 1 48BYTES 5.583 MICROSECOND
CODE 2 52 BYTES 4.583 MICROSECOND
6. TO CHECK NEGATIVE
CODE 1: TO CHECK IF A GIVEN NUMBER IS NEGATIVE OR NOT
AREA TNEG,CODE,READONLY
ENTRY
CODE32
LDR R1,=0X40000000
LDR R0,=THUMB+1
BX R0
CODE16
CMP R2,#0X00
BMI NEG
BPL POS
POS B STOP
AREA TPS,CODE,READONLY
ENTRY
CODE32
LDR R3,=0XFFFFFFFF
LDR R1,=0X40000000
LDR R0,=THUMB+1
BX R0
CODE16
AND R3,R2
LSL R3,#1
BCS NEG
BCC POS
POS B STOP
STOP B STOP
END
MEMORY TIME
CODE 1 32BYTES 1.582 MICROSECOND
CODE 2 36 BYTES 1.748 MICROSECOND
AREA TPS,CODE,READONLY
ENTRY
CODE32
MOV R5,#0X05
LDR R3,=0XFFFFFFFF
LDR R1,=0X40000000
LDR R0,=THUMB+1
BX R0
CODE16
ADD R1,#0X04
AND R3,R2
LSL R3,#1
BCC POS
BCS NE
BNE THUMB
BEQ STOP
NE ADD R4,#0X01
SUB R5,#0X01
BNE THUMB
BEQ STOP
STOP B STOP
END
CODE 2:TO FIND THE NUMBER OF NEGATIVE NUMBERS IN AN ARRAY
AREA TPS,CODE,READONLY
ENTRY
CODE32
MOV R5,#0X05
LDR R1,=0X40000000
LDR R0,=THUMB+1
BX R0
CODE16
ADD R1,#0X04
CMP R2,#0X00
BPL POS
BMI N
BNE THUMB
BEQ STOP
N ADD R4,#0X01
SUB R5,#0X01
BNE THUMB
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 1 52BYTES 6.415 MICROSECOND
CODE 2 48 BYTES 5.917 MICROSECOND
AREA TPS,CODE,READONLY
ENTRY
CODE32
LDR R1,=0X40000000
LDR R0,=THUMB+1
BX R0
CODE16
LSR R2,#1
BCC EVE
BCS ODD
STOP B STOP
END
CODE 2:
AREA TPS,CODE,READONLY
ENTRY
CODE32
LDR R7,=0X11111111
LDR R1,=0X40000000
LDR R0,=THUMB+1
BX R0
CODE16
AND R2,R7
LSR R2,#1
BCC EVE
BCS ODD
STOP B STOP
END
MEMORY TIME
CODE 1 36BYTES 1.415 MICROSECOND
CODE 2 44 BYTES 1.748 MICROSECOND
CODE 1:TO FIND THE NUMBER OF EVEN AND ODD NUMBERS IN AN ARRAY
AREA TPS,CODE,READONLY
ENTRY
CODE32
MOV R5,#0X05
LDR R3,=0X11111111
LDR R1,=0X40000000
LDR R0,=THUMB+1
BX R0
CODE16
ADD R1,#0X04
AND R3,R2
LSR R3,#1
LDR R3,=0X11111111
BCC EVN
BCS NE
SUB R5,#0X01
BNE THUMB
BEQ STOP
SUB R5,#0X01
BNE THUMB
BEQ STOP
STOP B STOP
END
CODE 2:
AREA TPS,CODE,READONLY
ENTRY
CODE32
MOV R5,#0X05
LDR R1,=0X40000000
LDR R0,=THUMB+1
BX R0
CODE16
ADD R1,#0X04
LSR R2,#1
BCS ODD
BCC EVN
SUB R5,#0X01
BNE THUMB
BEQ STOP
BNE THUMB
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 1 60BYTES 8.167MICROSECOND
CODE 2 48 BYTES 5.834 MICROSECOND
AREA MAX2,CODE,READONLY
ENTRY
CODE32
LDR R0,=0X40000000
LDR R1,=THUMB+1
BX R1
CODE16
ADD R0,#0X04
LDR R2,[R0]
CMP R1,R2
BCC L2
BCS L1
L2 MOV R3,R2
B STOP
L1 MOV R3,R1
B STOP
STOP B STOP
END
CODE 2:
AREA MAX2,CODE,READONLY
ENTRY
CODE32
LDR R0,=0X40000000
LDR R1,=THUMB+1
BX R1
CODE16
ADD R0,#0X04
LDR R2,[R0]
MOV R5,R2
SUB R4,R5
BCC L2
BCS L1
L2 MOV R3,R2
B STOP
L1 MOV R3,R1
B STOP
STOP B STOP
END
MEMORY TIME
CODE 1 40BYTES 1.748MICROSECOND
CODE 2 44 BYTES 1.665MICROSECOND
CODE 1:
AREA MAX2,CODE,READONLY
ENTRY
CODE32
MOV R7,#0X05
LDR R0,=0X40000000
LDR R3,[R0]
LDR R1,=THUMB+1
BX R1
CODE16
LDR R2,[R0]
MOV R4,R3
SUB R4,R2
BMI L2
BPL L1
L2 MOV R3,R2
SUB R7,#0X01
BNE THUMB
BEQ STOP
L1 SUB R7,#0X01
BNE THUMB
BEQ STOP
STOP B STOP
END
CODE 2:
AREA MAX2,CODE,READONLY
ENTRY
CODE32
MOV R7,#0X05
LDR R0,=0X40000000
LDR R3,[R0]
LDR R1,=THUMB+1
BX R1
CODE16
LDR R2,[R0]
MOV R4,R3
CMP R4,R2
BMI L2
BPL L1
L2 MOV R3,R2
SUB R7,#0X01
BNE THUMB
BEQ STOP
L1 SUB R7,#0X01
BNE THUMB
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 1 52BYTES 6.665 MICROSECOND
CODE 2 52BYTES 6.667 MICROSECOND
CODE 1:
AREA MAX2,CODE,READONLY
ENTRY
CODE32
LDR R0,=0X40000000
LDR R1,=THUMB+1
BX R1
CODE16
LDR R2,[R0]
CMP R1,R2
BCS L2
BCC L1
L2 MOV R3,R2
B STOP
L1 MOV R3,R1
B STOP
STOP B STOP
END
CODE 2:
AREA MAX2,CODE,READONLY
ENTRY
CODE32
LDR R0,=0X40000000
LDR R1,=THUMB+1
BX R1
CODE16
THUMB LDR R1,[R0]
MOV R4,R1
ADD R0,#0X04
LDR R2,[R0]
MOV R5,R2
SUB R4,R5
BCS L2
BCC L1
L2 MOV R3,R2
B STOP
L1 MOV R3,R1
B STOP
STOP B STOP
END
MEMORY TIME
CODE 1 40BYTES 1.499 MICROSECOND
CODE 2 44BYTES 1.998 MICROSECOND
AREA MAX2,CODE,READONLY
ENTRY
CODE32
MOV R7,#0X05
LDR R0,=0X40000000
LDR R3,[R0]
LDR R1,=THUMB+1
BX R1
CODE16
LDR R2,[R0]
MOV R4,R3
SUB R4,R2
BPL L2
BMI L1
L2 MOV R3,R2
SUB R7,#0X01
BNE THUMB
BEQ STOP
L1 SUB R7,#0X01
BNE THUMB
BEQ STOP
STOP B STOP
END
CODE 2:
AREA MAX2,CODE,READONLY
ENTRY
CODE32
MOV R7,#0X05
LDR R0,=0X40000000
LDR R3,[R0]
LDR R1,=THUMB+1
BX R1
CODE16
LDR R2,[R0]
MOV R4,R3
CMP R4,R2
BMI L2
BPL L1
L2 MOV R3,R2
SUB R7,#0X01
BNE THUMB
BEQ STOP
L1 SUB R7,#0X01
BNE THUMB
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 1 52BYTES 6.834 MICROSECOND
CODE 2 52BYTES 6.667 MICROSECOND
AREA DIV,CODE,READONLY
ENTRY
CODE32
LDR R0,=THUMB+1
BX R0
CODE16
MOV R2,#0X03
CMP R2,#0X00
BEQ STOP
BNE LQ
LQ CMP R1,R2
BEQ LOP
BNE DI
DI SUB R1,R2
CMP R1,#0X00
BPL AD
BMI STOP
AD ADD R3,#0X01
B DI
STOP B STOP
END
MEMORY TIME
CODE 44 BYTES 3.248 MICROSECOND
AREA MUL,CODE,READONLY
ENTRY
CODE32
LDR R0,=THUMB+1
BX R0
CODE16
MOV R2,#0X03
CMP R2,#0X00
BEQ STOP
BNE LQ
LQ ADD R3,R1
SUB R2,#0X01
BNE LQ
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 32 BYTES 2.081 MICROSECOND
11. PROGRAM TO ADD TWO ARRAYS AND SAVE THE RESULT IN THIRD ONE
AREA AD,CODE,READONLY
ENTRY
CODE32
LDR R0,=0X40000000
LDR R1,=0X40000010
LDR R6,=0X40000020
MOV R2,#0X05
LDR R3,=THUMB+1
BX R3
CODE16
ADD R0,#0X04
LDR R5,[R1]
ADD R1,#0X04
ADD R4,R5
STR R4,[R6]
ADD R6,#0X04
SUB R2,#0X01
BNE THUMB
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 52 BYTES 7.416 MICROSECOND
AREA ZO,CODE,READONLY
ENTRY
CODE32
MOV R1,#0X0E
MOV R4,#0X04
LDR R0,=THUMB+1
BX R0
CODE16
BCC Z
BCS ONE
Z ADD R2,#0X01
SUB R4,#0X01
BNE THUMB
BEQ STOP
BNE THUMB
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 44 BYTES 3.664 MICROSECOND
AREA ADODD,CODE,READONLY
ENTRY
CODE32
LDR R0,=0X40000000
MOV R2,#0X05
LDR R3,=THUMB+1
BX R3
CODE16
ADD R0,#0X04
MOV R6,R4
LSL R4,#1
BCS ODD
BCC LOP
SUB R2,#0X01
BNE THUMB
BEQ STOP
BNE THUMB
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 48 BYTES 6.415 MICROSECOND
AREA ADODD,CODE,READONLY
ENTRY
CODE32
LDR R0,=0X40000000
MOV R2,#0X05
LDR R3,=THUMB+1
BX R3
CODE16
ADD R0,#0X04
MOV R6,R4
LSL R4,#1
BCC ODD
BCS LOP
SUB R2,#0X01
BNE THUMB
BEQ STOP
BNE THUMB
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 48 BYTES 6.415 MICROSECOND
AREA ADODD,CODE,READONLY
ENTRY
CODE32
LDR R0,=0X40000000
MOV R2,#0X05
LDR R3,=THUMB+1
BX R3
CODE16
ADD R0,#0X04
MOV R6,R4
LSR R4,#1
BCS ODD
BCC LOP
SUB R2,#0X01
BNE THUMB
BEQ STOP
BNE THUMB
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 48 BYTES 6.584 MICROSECOND
AREA ADODD,CODE,READONLY
ENTRY
CODE32
LDR R0,=0X40000000
MOV R2,#0X05
LDR R3,=THUMB+1
BX R3
CODE16
MOV R6,R4
LSR R4,#1
BCC EV
BCS LOP
EV ADD R5,R6
SUB R2,#0X01
BNE THUMB
BEQ STOP
BNE THUMB
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 48 BYTES 6.584 MICROSECOND
ENTRY
CODE32
LDR R0,=0X40000000
MOV R2,#0X0A
MOV R1,#0X00
LDR R3,=THUMB+1
BX R3
CODE16
ADD R0,#0X04
ADD R1,#0X02
SUB R2,#0X01
BNE THUMB
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 40 BYTES 5.828 MICROSECOND
18. CODE TO GEERATE FIRST 10 ODD NUMBERS
AREA GEN,CODE,READONLY
ENTRY
CODE32
LDR R0,=0X40000000
MOV R2,#0X0A
MOV R1,#0X01
LDR R3,=THUMB+1
BX R3
CODE16
ADD R0,#0X04
ADD R1,#0X02
SUB R2,#0X01
BNE THUMB
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 40 BYTES 5.828 MICROSECOND
19. CODE TO GENERATE FIBONACCI SERIES
AREA GEN,CODE,READONLY
ENTRY
CODE32
LDR R0,=0X40000000
MOV R3,#0X01
ADD R0,#0X04
MOV R2,#0X00
STR R2,[R0]
ADD R0,#0X04
MOV R6,#0X08
LDR R5,=THUMB+1
BX R5
CODE16
ADD R0,#0X04
MOV R4,R3
ADD R3,R2
MOV R2,R4
SUB R6,#0X01
BNE THUMB
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 60 BYTES 7.749 MICROSECOND
AREA ASC,CODE,READONLY
ENTRY
CODE32
LDR R0,=TH+1
BX R0
CODE16
TH MOV R1,#5
UP LDR R2,=0X40000000
MOV R3,R2
ADD R3,#0X04
MOV R7,#0X03
LDR R5,[R3]
CMP R4,R5
BCC COR
BCS IN
IN MOV R6,R4
MOV R4,R5
MOV R5,R6
STR R5,[R3]
ADD R2,#0X04
ADD R3,#0X04
SUB R7,#0X01
BNE LOP
BEQ SUBB
BNE UP
STOP B STOP
END
MEMORY TIME
CODE 64BYTES 30.333 MICROSECOND
AREA ASC,CODE,READONLY
ENTRY
CODE32
LDR R0,=TH+1
BX R0
CODE16
TH MOV R1,#5
UP LDR R2,=0X40000000
MOV R3,R2
ADD R3,#0X04
MOV R7,#0X04
LDR R5,[R3]
CMP R4,R5
BCS COR
BCC IN
IN MOV R6,R4
MOV R4,R5
MOV R5,R6
STR R5,[R3]
ADD R2,#0X04
ADD R3,#0X04
SUB R7,#0X01
BNE LOP
BEQ SUBB
BNE UP
STOP B STOP
END
memory Time
Code 64bytes 30.333 microsecond
area asc,code,readonly
entry
code32
ldr r0,=th+1
bx r0
code16
th mov r1,#3
up ldr r2,=0x40000000
mov r3,r2
add r3,#0x04
mov r7,#0x02
ldr r5,[r3]
cmp r4,r5
bcc cor
bcs in
in mov r6,r4
mov r4,r5
mov r5,r6
str r5,[r3]
add r2,#0x04
add r3,#0x04
sub r7,#0x01
bne lop
beq subb
bne up
mov r3,r2
add r3,#0x04
mov r7,#0x01
ldr r5,[r3]
cmp r4,r5
bcs dcor
bcc din
mov r4,r5
mov r5,r6
str r5,[r3]
add r2,#0x04
add r3,#0x04
sub r7,#0x01
bne dlop
beq dsubb
bne dup
stop b stop
end
memory Time
Code 112bytes 17.333 microsecond
area asc,code,readonly
entry
code32
ldr r0,=string
ldr r1,=th+1
bx r1
code16
th ldrb r2,[r0]
add r0,#0x01
cmp r2,#dollar
bne ad
beq stop
ad add r3,#0x01
b th
stop b stop
end
memory Time
Code 44 bytes 7.499 microsecond
area asc,code,readonly
entry
code32
ldr r0,=string
ldr r1,=th+1
bx r1
code16
th ldrb r2,[r0]
add r0,#0x01
cmp r2,#space
beq ad
bne rep
ad add r3,#0x01
b th
bne th
beq stop
stop b stop
end
memory Time
Code 52 bytes 9.249 microsecond
entry
code32
ldr r0,=string1
ldr r4,=string2
ldr r1,=th+1
bx r1
code16
th ldrb r2,[r0]
add r0,#0x01
cmp r2,#dollar
bne ad
beq dth
ad add r5,#0x01
bne th
add r4,#0x01
cmp r2,#dollar
beq lop
bne dad
bne dth
bne stop
ldr r4,=string2
add r0,#0x01
ldrb r3,[r4]
add r4,#0x01
cmp r2,r3
beq hap
bne stop
sub r5,#0x01
bne loop
beq comp
beq addd
bne stop
stop b stop
end
memory Time
Code 120 bytes 13.416microsecond
area strrev,code,readonly
entry
code32
ldr r1,=th+1
bx r1
code16
th ldr r0,=string
ldr r2,=0x40000000
l ldrb r3,[r0]
add r0,#0x01
cmp r3,#0
bne ad
beq reverse
ad add r4,#0x01
bl
add r0,r4
b loop
ldrb r5,[r0]
strb r5,[r2]
add r2,#0x01
sub r4,#0x01
bne loop
stop b stop
end
memory Time
Code 68 bytes 10.665microsecond
area strrev,code,readonly
entry
code32
ldr r0,=s+1
bx r0
code16
s mov r0,#0
ldr r1,=string
ldr r2,=string
add r1,#1
cmp r3,#0
bne loop2
beq loop3
sub r4,#0x01
add r2,r4
ldr r1,=string
ldrb r7,[r2]
add r1,#0x01
sub r2,#0x01
cmp r4,r7
beq loop4
bne loop6
bne loop5
beq yes
bne stop
stop b stop
end
memory Time
Code 88 bytes 15.498 microsecond
memory Time
Code 104 bytes 25.081 microsecond
AREA CODE1,CODE,READONLY
ENTRY
CODE32
LDR R0,=MAIN+1
BX R0
CODE16
LDMIA R1!,{R2-R6}
AD BL ADDITION
LDR R0,=0X40000020
STR R2,[R0]
STOP B STOP
ADD R2,R4
ADD R2,R5
ADD R2,R6
MOV PC,LR
END
MEMORY TIME
CODE 44 BYTES 2.915 MICROSECOND
AREA ASC,CODE,READONLY
ENTRY
CODE32
LDR R0,=THU+1
BX R0
CODE16
MOV R0,#0X09
MOV R1,R0
MOV R2,#0X02
CMP R0,#0X02
BEQ PRIME
BNE CONT
B STOP
CMP R2,R0
BPL CONT
BMI STOP
MOV R4,R2
BL DIV
CMP R3,#0X00
BNE GO
BEQ NOTPRIME
GO ADD R2,#0X01
CMP R0,R2
BNE CONT
BEQ PRIME
STOP B STOP
ADD R5,#0X01
CMP R3,R4
BPL DIV
MOV PC,LR
END
MEMORY TIME
CODE 72 BYTES 7.58 MICROSECOND
AREA MOVE,CODE,READONLY
ENTRY
CODE32
LDR R0,=DATA
LDR R1,=0X40000000
LDR R2,=THUMB+1
BX R2
CODE16
STMIA R1!,{R2-R4}
STOP B STOP
END
MEMORY TIME
CODE 44 BYTES 1.583 MICROSECOND
AREA MOVE,CODE,READONLY
ENTRY
CODE32
LDR R0,=0X40000000
LDR R1,=0X40000010
LDR R2,=THUMB+1
BX R2
CODE16
STMIA R1!,{R2-R4}
STOP B STOP
END
MEMORY TIME
CODE 28 BYTES 1.416 MICROSECOND
1. R0=5R1
AREA MULT,CODE,READONLY
ENTRY
CODE32
LDR R3,=THUMB+1
BX R3
CODE16
MOV R0,#0X00
MOV R2,#0X05
LQ ADD R0,R1
SUB R2,#0X01
BNE LQ
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 28 BYTES 2.749 MICROSECOND
2. R3=10R4
AREA MULT,CODE,READONLY
ENTRY
CODE32
LDR R0,=THUMB+1
BX R0
CODE16
MOV R3,#0X00
MOV R2,#0X0A
LQ ADD R3,R4
SUB R2,#0X01
BNE LQ
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 28 BYTES 2.749 MICROSECOND
3. R7=10R3
AREA MULT,CODE,READONLY
ENTRY
CODE32
LDR R0,=THUMB+1
BX R0
CODE16
MOV R7,#0X00
MOV R2,#0X0A
LQ ADD R7,R3
SUB R2,#0X01
BNE LQ
BEQ STOP
STOP B STOP
END
MEMORY TIME
CODE 28 BYTES 2.749 MICROSECOND
4. IF (R0>R1)
R2=R0+4R1
ELSE
R2=R0+7R1
AREA MULT,CODE,READONLY
ENTRY
CODE32
LDR R4,=THUMB+1
BX R4
CODE16
THUMB MOV R0,#0X01
MOV R1,#0X02
CMP R0,R1
BPL L1
BMI L2
L2 MOV R1,#0X02
MOV R2,#0X00
MOV R3,#0X07
SUB R3,#0X01
BNE LQ1
ADD R0,R2
MOV R2,R0
B STOP
L1 MOV R1,#0X02
MOV R2,#0X00
MOV R3,#0X04
LQ ADD R2,R1
SUB R3,#0X01
BNE LQ
ADD R0,R2
MOV R2,R0
STOP B STOP
END
MEMORY TIME
CODE 60 BYTES 4.246 MICROSECOND