0% found this document useful (0 votes)
10 views4 pages

Lab1

Uploaded by

nakethavath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views4 pages

Lab1

Uploaded by

nakethavath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ES 333 Microprocessors and Embedded Systems

LAB 01

Kethavath Madhu 22110119


Zala darshan 22110297

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

Instruction Value in the registers Flag update

adds r2,r1,r0 r2=0x02b (r2=r1+r0) No flag is updated

subs r3,r0,r1 r3=0xfffff9(r3=r0-r1) N flag update to 1


As the msb became 1

muls r4,r2,r1 r4=0x0433 No flag is updated

b. Load any 32-bit value in memory and display it’s memory address in any of the Register.

ldr r1,=0x20000008 (loading the address into the register)


ldr r2,=0x0980 (loading any value into the register)
str r2,[r1] (storing the value in the register r2 to the memory of the address in r1)
movs r3,r1 (store the memory address in r3 resistor)
Value in the r3 is 0x20000008 (memory address)

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

r4=0x00f is the value in the register r4


This is the code to find the sum of first five natural numbers

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

Instruction Register value Flag update

Adds r0,r1,r2 r0=0x00000033 No flag is updated

Movne r3,r0 r3=0x0000 No flag is updated

Orreq r0,r4,r5 r0=0x00,r4=0x033,r5,0x055 No flag is updated

Lsr r3,r6,#7 r3=0x00200000 No flag is updated

Sbc r0,r4,r5 r0 =ffffffdd No flag is updated

Movw r5,0x5422 r5=0x05422 No flag is updated

Movt r6,0x524 r6=0x05240000 No flag is updated


Q4. Write an Assembly Language Program to store and retrieve two 8-bit numbers. Store
the numbers 20H and 3DH on the stack and then retrieve them back into registers. Store
the result of adding these two numbers in memory location 000000f0.

mov r1,#0x20 (numbers1)


mov r2,#0x3d (number 2)
ldr r4,=#0x000000f0
push {r1 , r2} pushing in to the stack
pop {r2 , r3} retrieve from the stack
add r2,r3 (adding r2and r2 and storing at r2 register)
str r2,[r4] (store value in the r2 at the memory address of r4(0x000000f0)

we will store the addition of 0x20 and 0x3d i.e r2( 0x5d) at memory address r4(0x000000f0)

Q5.Consider the following 5 numbers in hexadecimal format:


1.0x79
2.0x58
3.0x1D
4.0x43
5.0x64
Write an ARM assembly language program to achieve the following:
a. Store these numbers in 5 consecutive memory locations.

mov r0,#0x79
​ mov r1,#0x58
​ mov r2,#0x1d
​ mov r3,#0x43
​ mov r4,#0x64
​ ldr r5,=#0x100
​ stmib r5,{r0-r4}

At memory address 0x100+4,0x100+8,0x100+c,0x100+0x10,0x100+0x14 we will find the


values of the registers from ro to 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 .

Memory address Registers with values

0x100 r0(ox79)

0x104 r1(0x64)

0x108 r2(0x58)

0x10c r3(0x43)

0x110 r4(0x1d)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy