0% found this document useful (0 votes)
29 views13 pages

CH - En.u4ece21016 - Lab Report 1

The document is a lab report that demonstrates various arithmetic operations in assembly language code. It initializes registers, performs operations like addition, subtraction, logical/arithmetic shifts, and stores results. For each operation, it shows the code, expected output, and inference summarizing what the code is doing. The operations covered are addition, subtraction, logical/arithmetic shifts, multiplication, and their variants like addition with carry.

Uploaded by

NP GK
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)
29 views13 pages

CH - En.u4ece21016 - Lab Report 1

The document is a lab report that demonstrates various arithmetic operations in assembly language code. It initializes registers, performs operations like addition, subtraction, logical/arithmetic shifts, and stores results. For each operation, it shows the code, expected output, and inference summarizing what the code is doing. The operations covered are addition, subtraction, logical/arithmetic shifts, multiplication, and their variants like addition with carry.

Uploaded by

NP GK
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/ 13

Course Code: 19ECE304 Name: N P Ganesh Kumar

Course Title: Microcontrollers and Roll No: CH.EN.U4ECE21016


cascasc Interfacing
Semester: 5th
Course Faculty: Dr. C Ganesh Kumar
Academic Year: 2023-2024

Lab Report – 1
Introduction to Assembly Language
Aim

To develop an assembly code to perform operations for the following functions.

Software Used

General Instruction

1. MOV: Moves 16-bit data to the register.


2. AREA: Assigns and instructs the assembler to assemble the code.
3. END: To denote the completion of the program.
4. CODE: To specify whether it is code or data sec􀆟on.
5. READONLY: To make it viewable but not editable.
Arithmetic Operations

1. Addition (ADD)
2. Addition with carry (ADC)
3. Subtraction (SUB)
4. Subtraction with carry (SBC)
5. Reverse subtract (RSB)
6. Reverse subtract with carry (RSC)
7. Logical shift left (LSL)
8. Logical shift right (LSR)
9. Arithmetic shift right (ASR)
10. Rotate right (ROR)
11. Multiplication (MUL)

Addition (ADD)

Source Code

AREA arithmatical, CODE, READONLY


MOV R1, #0X00000008
MOV R2, #0X00000004
ADD R3, R1, R2
END

Output
Inference

Overall, the code initializes two registers, R1 and R2, with the values 8 and 4, respectively. Then
it adds the values in R1 and R2 together and stores the result in R3. After execution, the code
stops.
We can identify that R1 and R2 have the value that we designed them, and R3 contains the result
of addition,
Addition with carry (ADC)

Source Code

AREA arithmatical, CODE, READONLY


MOV R1, #0X00000008
MOV R2, #0X00000004
ADC R3, R1, R2
END

Output
Inference

Overall, the code initializes two registers, R1 and R2, with the values 8 and 4, respectively. Then
it performs an addition with carry operation, adding the values in R1 and R2 along with the carry
flag (if set) and stores the result in R3. Finally, the program ends.

Subtraction (SUB)

Source Code

AREA arithmatical, CODE, READONLY


MOV R1, #0X00000008
MOV R2, #0X00000004
SUB R3, R1, R2
END

Output
Inference

Overall, the code initializes two registers, R1 and R2, with the values 8 and 4, respectively. Then
it performs subtraction with the carry operation, subtracting the values in R1 and R2 along with
the carry flag (if set) and stores the result in R3. After execution, the code stops

Subtraction with carry (SBC)

Source Code

AREA arithmatical, CODE, READONLY


MOV R1, #0X00000008
MOV R2, #0X00000004
SBC R3, R1, R2
END

Output
Inference

Overall, the code initializes two registers, R1 and R2, with the values 8 and 4, respectively. Then
it performs a subtraction with borrow operation, subtracting the value in R2 from the value in R1
along with the borrow flag (if set), and stores the result in R3. After execution, the code stops

Reverse subtract (RSB)

Source Code

AREA arithmatical, CODE, READONLY


MOV R1, #0X00000008
MOV R2, #0X00000004
RSB R3, R1, R2
END

Output
Inference

Overall, the code initializes two registers, R1 and R2, with the values 10 and 6, respectively.
Then it performs a reverse subtraction operation, subtracting the value in R2 from the value in
R1, and stores the result in R3. It performs R3 = R2 - R1.After execution, the code stops

Reverse subtract with carry (RSC)

Source Code

AREA arithmatical, CODE, READONLY


MOV R1, #0X00000008
MOV R2, #0X00000004
RSC R3, R1, R2
END

Output
Inference

Overall, the code initializes two registers, R1 and R2, with the values 8 and 4, respectively. Then
it performs a reverse subtraction with the carry operation, subtracting the value in R2 from the
value in R1 along with the carry flag (if set), and stores the result in R3. After execution, the
code stops.

Logical shift left (LSL)

Source Code

AREA arithmatical, CODE, READONLY


MOV R1, #0X00000008
MOV R2, #0X00000004
LSL R3, R1, R2
END

Output
Inference

Overall, the code initializes two registers, R1 and R2, with the values 8 and 4, respectively. Then
it adds the values in R1 and R2 together and performs a left shift by 3 bits on the result. Finally,
the shifted result is stored in R3, after execution the code stops.

Logical shift right (LSR)

Source Code

AREA arithmatical, CODE, READONLY


MOV R1, #0X00000008
MOV R2, #0X00000004
LSR R3, R1, R2
END

Output
Inference

Overall, the code initializes two registers, R1 and R2, with the values 8 and 4, respectively. Then
it adds the values in R1 and R2 together and performs a logical right shift by 2 bits on the result.
Finally, the shifted result is stored in R3, after execution, the code stops.

Arithmetic shift right (ASR)

Source Code

AREA arithmatical, CODE, READONLY


MOV R1, #0X00000008
MOV R2, #0X00000004
ASR R3, R1, R2
END

Output
Inference

Overall, the code initializes two registers, R1 and R2, with the values 8 and 4, respectively. Then
it adds the values in R1 and R2 together and performs an arithmetic right shift by 2 bits on the
result. Finally, the shifted result is stored in R3, after execution the code stops.

Rotate right (ROR)

Source Code

AREA arithmatical, CODE, READONLY


MOV R1, #0X00000008
MOV R2, #0X00000004
ROR R3, R1, R2
END

Output
Inference

Overall, the code initializes two registers, R1 and R2, with the values 8 and 4, respectively. Then
it adds the values in R1 and R2 together and performs a rotate right operation by 2 bits on the
result. Finally, the rotated result is stored in R3 after execution, and the code stops.

Multiplication (MUL)

Source Code

AREA arithmatical, CODE, READONLY


MOV R1, #0X00000008
MOV R2, #0X00000004
MUL R3, R1, R2
END

Output
Inference

Overall, the code initializes two registers, R1 and R2, with the values 8 and 4, respectively. Then
it multiplies the values in R1 and R2 together and stores the result in R3. After execution, the
code stops.
We can identify that R1 and R2 have the value that we designed them, and R3 contains the result
of addition,

You might also like