Lab1
Lab1
LAB 01
Q1. Perform the following operations and verify the functionality of the following
instructions:
a. Add, Subtract and Multiply any two registers and notify the flag being set while
performing the operation
movs r0,#0x012
movs r1,#0x019
b. Load any 32-bit value in memory and display it’s memory address in any of the Register.
Q2. Write a ARM Assembly Language Program to find the sum of First Five Natural
Numbers.
Movs r0,#0x05
Movs r1,#0x00
Movs r3,#0x00
next:
Adds r1,#0x01
Adds r3,r1
cmp r0,r1
bne next
Movs r4,r3
Q3.Suppose R1= 11H, R2= 22H, R4= 33H, R5= 55H, R6=0x10000000. Mention the content
of all locations and registers involved after execution of the following instructions and
notify the flag set (all questions are independent):
Loading the values to the registers or moving the value to the registers
Movs r1,#0x011
Movs r2,#0x022
Movs r4,#0x033
Movs r5,#0x055
ldr r6,=#0x10000000
we will store the addition of 0x20 and 0x3d i.e r2( 0x5d) at memory address r4(0x000000f0)
mov r0,#0x79
mov r1,#0x58
mov r2,#0x1d
mov r3,#0x43
mov r4,#0x64
ldr r5,=#0x100
stmib r5,{r0-r4}
b. Sort the data in the descending order in the memory and display the starting address of
memory in any of the register. Also, read the data in the same order to store it in the
register.
//Loading the values in the register
mov r0,#0x79
mov r1,#0x58
mov r2,#0x1d
mov r3,#0x43
mov r4,#0x64
ldr r5,=#0x100 // address of the memory
stmia r5,{r0-r4} //storing multiple data from the address r5 as increment after load
mov r6,r5
mov r3,#0
ma:
add r3,#1
mov r2,#0
mov r5,r6
next: ldr r0,[r5] //loading the data
ldr r1,[r5,#4] //loading the data
subs r4,r1,r0
Bmi loop // if subtraction is positive then we will go into the loop
str r1,[r5] //swapping the data
str r0,[r5,#4]
loop: add r5,#4
add r2,#1
cmp r2,#5
Bne next
cmp r3,#4
Bne ma
mov r5,r6 // storing memory address in the r5 register
ldmia r5,{r0-r4} //loading the data in the registers in the
descending order as .
0x100 r0(ox79)
0x104 r1(0x64)
0x108 r2(0x58)
0x10c r3(0x43)
0x110 r4(0x1d)