You are on page 1of 10

ARM Review

Team 15
Write an ALP to add 2 64 bit numbers
• Divide a 64 bit number into 2 parts i.e, lower and upper nibble and
store into two registers similarly for another number.
• Add the lower nibbles of the two numbers and store it into any one of
the register.
• Add the upper nibbles of the two numbers along with the carry
generated form the previous calculation.
• Store the lower and upper nibble of the result in two different
registers.
Code
;program to add 2 64 bit numbers ldr r2, =0x33333333
area add,code,readonly ldr r3, =0x44444444
entry
code32 add r3, r1
adr r0,thumb+1 adc r0, r2
bx r0 ldr r4,=0x40000000
code16 str r3,[r4]
thumb add r4,#4
ldr r0, =0x11111111 ; upper part of 1
ldr r1, =0x22222222 ; lower part of 1 str r0,[r4]
stop b stop
end
Result
Reverse the given String
• Load the string in left-to-right order into a suitable register, bitwise,
then load it to a suitable memory address using a looping function,
which repeats a 'count' times.
• Choose the 'count' according to size of the string.
• Now, load it into a suitable memory address in right-to-left order by
decrementing the 'count’.
Code
loop ldrb r1,[r0]
;reverse the given string
strb r1,[r3]
area reverse,code,readonly
add r0,#01
entry
add r3,#01
code32
sub r5,#01
start ldr r0,=into_thumb+1
bne loop
bx r0
l1 sub r0,#01
code16
ldrb r4,[r0]
into_thumb
strb r4,[r3]
ldr r0,=a
add r3,#01
ldr r3,=0x40000000
sub r6,#01
mov r5,#04
bne l1
mov r6,r5
sbs
a dcb "ABCDE",0
end
Result
Compute the average of bytes in a list
• Loading all the elements list
• Loop to fetch all the elements for total sum
• Divide to get average
• Result is stored in final register
Code
;Average of bytes in a list sub r5,#1 ;decrement
area aa,code beq div
entry b loop
main stop b stop
code32
ldr r0,=average+1; ;perform division
bx r0; div
code16 up add r5,#1; result is stored in r5
average mov r5,#5 ;no of data sub r4,#5
ldr r1,=var beq stop
loop ldrh r2,[r1] b up
add r1,#4 ;increment data pointer var dcd 0x1,0x2,0x3,0x4,0x5
add r4,r2 ;add end
Result

You might also like