0% found this document useful (0 votes)
4 views14 pages

Mic Lab Experiments

The document provides assembly language programs (ALPs) for performing various arithmetic operations such as subtraction and addition on 32-bit and 64-bit data stored in registers. It includes examples of moving data between memory locations using pre and post-indexing techniques. The output sections show the state of registers before and after execution of the programs.

Uploaded by

puligaddarishit
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)
4 views14 pages

Mic Lab Experiments

The document provides assembly language programs (ALPs) for performing various arithmetic operations such as subtraction and addition on 32-bit and 64-bit data stored in registers. It includes examples of moving data between memory locations using pre and post-indexing techniques. The output sections show the state of registers before and after execution of the programs.

Uploaded by

puligaddarishit
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

3b.

Write an ALP to subtract two 64-bit immediate data stored in such a way that first number is in the register R1, R0 and
second number in R3, R2 and store the result in the registers R5, R4 and borrow in R6.

Aim: To subtract Bwo 64 data


Tool Used: kil Mvision 4
Code: AREA 03B, CODE, READONLY
ENTRY
LDR R1, =0X 00000001

LDR R0, 2 0N00000002

LOR R3, 20X 00000003

LDR R2, 20200000004

SUBS Ru, RO1 R2


SBLS RS, RII R3

MOVCC R6 , #01

STOP B STOP

END

Output:

Before execution:
Ro 0x00000000
R5 0x0000000o
R 0x0000000o
86 0%00000000
R2 O 00000000

R3 0x 00000000

Ru O* 00000000

After execution:

KO 0* 00000002 RY OX FFFFFF FE
d
0 00000001
R5 O FF FF FF F D
R2 0 00000004
P6 0 00000001
RB 0x00000003
2
3. c) Write an ALP to perform reverse subtraction of two 32-bit immediate data stored
in the registers R0 and Ri and store
the difference in the register R3 and store the borrow in R4.

Aim: To reverse subtract two 32 bir dara


Tool Used: kül uVisionG
Code: AREA 03C, CODE, READONLY
ENTRY
LOR Ro, 2 0X00000002

LOR RII 0x00000001

RSBS R2, RI, RO


MOUCC R3 , #01
STOP B STOP
END

Output:

Before execution:

Ro 000000000

RI 0x 00000000

R2 0 00000000

R3 0x 00000000
After execution:

Ro 0x 00000002

RI 0x 00000001

R2 00 FFFF FF PE

0x 00000001
R3

3
r is in
in such a way that first numbe
of two 64-bit immediate data stored
3d) Write ALP to perform reverse subtraction w in R6.
the registers R5, R4 and borro
an
r in R3, R2 and store the differ ence in
the register RI, R0 and second numbe

Aim: To reverse subtract 1w06u bir data

Tool Used: Keil Muision 4


Code: AREA 22D, CODE, READONLY
ENTRY
LDR RI =0 D0000001

LDR R07 200 00000002

LOR 23, 20+00000003

LDR 22 =0x 00000004

RS BS Ru, RO, R2

RSCS RS, RI, R3


MOULL
R6 #01
STOP B S TOP
END

Output:

Before execution:

lo 0x00000000
RS OAD0000000
RI O0 00000000
86 0x00000000
82 0%00000000

23 0700000000

0x00000000
After execution:

Ro 0x00000002 R5 0200000002

R 0x00000001
Ro 0x 0O000000

22 0A 00000004

R3 0000000003

Ku 0x 00000002
[Link] an ALP to move a block of five
32-bit data stored from memory location starting with
new memory locat the address 0x40000000 to
ion starting with the address
0x40000030 Aim:
Tool Used:
Keil Mvision 4
Code: ALE A SMTG, CODE, READONLY
ENTRY
LDR RO, = 0x40000000

LDR RI , 2 DA40000030

mov R2, #05


Pra LDR R3, [RO]
STR RB, (RI)
ADD RI, #04
ADD R0, #04
SUBS R2, #01

BNE pra
STOP B STOP

END

Output:

Before execution: Address


RO 0700000000 Or 40000000
: 3423 43 AA
32 45 78
0x00000000 4: 12
R Ox4000000
AB EF IF
00 : Ce
R2 Oх000000 0x40000008
34 66 AB
13
4000000C 12
0x
0 AB CD Ef
After execution: 0x4000001 AA
34 23 43
0х 4000003о
Ro 0x40000014
34 212 32 45 78
0x 4000 00
RI Dx 40000044 EP IF
381 CC AB
02400000
56 AB
R2 0x 00000000 3C:
13 34

0x 400000
AB CDEF 12
0x 400000 4 D
data to
g and post indexing technique for a block of N 32-bit
move
4b. Write an ALP to perform Pre indexing, Auto indexin
30. Take N=3 Aim:
from source location 0x40000000 to destination location 0x400000

Tool Used: Keil Avision 4


Code:

AREA POST, CODEI RGADONIY SUBS R2, #01

ENTRY BNE PRE


4000000D
LDR RO, 20x
A Mov Ra,#04
0x40000020
LDR RI, 2
LDR R3, [ROJ
Mov Ra, # 05 [RIJ
3TR R3,
BALK R3, [RO], #04
LDR
AUTO LDR R3, [RO, #O4]!
STR R3, [RI], #04
STR R3, [RI,#OL31
SUBS R3, H01
SUBS R2, #01
BNE BACK
BNE AUTD
LDR RO , 20x40000000

LDR RI, =Ox40000020 STOP B STOP


MOV R2, #OS END
PRE LDR R3, [RO, R3]
STR R3, [RI, R3]

Output:
ADD R3,# 04
Before execution:

Adaress
0x40000000 OO FFEFOO 0x40000010 FFFFFFFF
0x 40000004 0000 0012
The addresses 0740000020
40000008
0
0x 24 O 12 00
to oxu000003C win
0x 400000OL Ef 36 00046 have 00000000.
After execution:

0x40000020 00 Pf EF 00 o The add resses


0x 4000 0030 00 0000 12 0x40000000 to
0x 400000 34 24 001100 0x4000000C

0x 400000 38 36 0046 will retain the


Ef
0x 40000030 Same memory 6
PF FP FF FF
Writean ALP to perfor
m addition, subtra
ction, reverse sub
with the address 0x4 traction of N 32
0000000 and store bit numbers sto
the result in the next red in memory loc
Tool Used: Keil Mrision 4 me mory location (use ation staring
post indexing tec
hnique) Take N=4Aim
:
Code:
ARFA ASRS, CODE, READONLY
ENTRY
LDR RO, = 0x40000000
LDR RI, 2 Ox 40000020

MOV R2, #04


BALK
LDR R3, [RO], #04
ADD R4, R3

SUB RS, R3

RSB R6, 83

SUBS R2, #01


STR R4, [Rn

STR RS, PRI, #04]


STR R6, [RI, #08
BNE BACK
STOP B STOP
END
Output:

Before execution:

Address
04000000 C 00000004
0*40000000 00 00 00 이

0A4000 0004 00 00 0002 The addresses Ox 40000020

40000008 00 00 0003 t0 Ox 4000 0034 will


0x

After execut
ion: have 0000 00 00

0 20 0000OO OA
0x40000 The addresses
00 00 00 F6
30 to
Ox 40O000 040000000
02
000000
200000 34
0x4000OOOL will
7
retain he Sane

wemory
us
Res
5a.

Before execution:

After execution:
5b.

Before execution:

After execution:
5c.

Before execution:

After execution:
5D.

Before execution:

After execution:
6a.

Before execution:

After execution:
6b.

Before execution:

After execution:
6d.

Before execution:
After execution:

You might also like