You are on page 1of 12

19CSE303 – EMBEDDED SYSTEMS

LAB REPORT 1

TITLE OF THE EXPERIMENT: INTRODUCTION TO KEIL

NAME OF THE STUDENT: LAKSHMI SAHITHI UPPU

REGISTRATION NUMBER: CH.EN.U4CSE19105

FACULTY NAME: Dr. SIVASUNDER

DATE OF LAB: 30-07-2021

DATE OF REPORT SUBMISSION: 07-08-2021

DEPARTMENT: COMPUTER SCIENCE AND ENGINEERING, AMRITA


VISHWA VIDYAPEETHAM, CHENNAI

1|Page
ABOUT KEIL SOFTWARE :

DESCRIPTION:

Keil Micro Vision is a free software which solves many of the pain points
for an embedded program developer. It is comprehensive software
solution to create, build, and debug embedded applications for ARM
based microcontrollers. This software is an integrated development
environment (IDE) to solve the complex problems facing embedded
software developers. When starting a new project, simply select the
microcontroller you use from the Device Database and the µVision IDE
sets all compiler, assembler, linker, and memory options for us.

This software can be downloaded from net. Here are the two links to
download the MDK-ARM software and the software for MDK Version 5:

https://www.keil.com/download/product/

Once the software is installed, legacy should be installed. Given below is


the link to install legacy.

https://www2.keil.com/mdk5/legacy

After installing legacy , Keil software shortcut will be available on desktop.


Click on the shortcut to open the IDE.

To create a new project in this software we have to: -

 Go to the main menu located on the top.


 Main Menu → Project → New µVision Project.
 Create a folder and provide a suitable name for the project.
 A pop-up window appears.
 In device click dropdown → select Legacy Device Database
 In Search select LPC2148 under NXP and press OK.
 And then add startup( extension ‘.s’ ) file which are necessary and
initializes ARM Core Peripherals, define stack program, Interrupt
vectors and will be in assembly language only.
 New Project is been created.
Steps after creating a new project:

 After a program is written save it. Go to Project → Build target


 If any errors , rectify them and rebuilt the target.
 Once the program has been implemented successfully, debug it.

ARM programmer model:

• The state of an ARM system is determined by the content of visible


registers and memory.
• A user-mode program can see 15 32-bit general-purpose registers (R0
- R14), program counter (PC) and CPSR.
• Instruction set defines the operations that can change the state.

*****************************************************************************

ARM INSTRUCTIONS:

The ARM processor contains a powerful instruction set.

These instructions are divided into 6 types

1. Data processing
2. Branch
3. Load and store ( that all arithmetic and logical instructions take only
register operands )
4. Status register transfer
5. Exception generating
6. Coprocessor

ARM Register Set:

USER MODE:

1. r0-r12 is a general purpose


2. Cpsr- current program status
3. Spsr- saved program status
Examples of 10 instructions:

ARM instructions follow a format “ Label Op-code operand1, operand2,


operand3 ; comment.

1. ADDITION instruction:
 ADD: ADD r0,r1,r2

// implies that r0=r1+r2. The values of register r1 and r2 are added


and the result is stored in r0.

 ADDS: ADDS R0,R1,R2


// implies that r0=r1+r2. The values of registers r1 and r2 are
added and the result is stored in r0 and flags get updated.

2. SUBTRACTION instruction:
 SUB: SUB R0,R1,R2

// implies that r0=r1-r2. The values of registers r1 and r2 are


subtracted and the result is stored in r0.

 SUBS: SUBS R0,R1, #50


// implies that r0=r1-50. Here 50 is subtracted from R1and the
result is stored in r0 and sets the flags on result.

3. REVERSE SUBTRACTION instruction:


 RSB R5, R5, #20

// implies that R5= 20-R5. 20-subtracted from the value stored in


register R5 and the final result is stored in R5.

4. MULTIPLY instruction:
 MUL: MUL R5,R6,R7

// implies that R5=R6*R7 .The values in registers R6,R7 are


multiplied and the result is stored in R5.

 UMULL: R1,R2,R3,R4

//Implies unsigned (R2,R1) = R3*R4.

 SMLAL: SMLAL R1,R2,R3,R4


//implies that signed (R2,R1) = (R2,R1) + R3*R4

5. DIVISION instruction:
 SDIV: SDIV R3,R4,R5
//SDIV instruction implies signed divide and the operation
performed is R3=R4/R5. The values stored in register R4 and R5 are
divided and the result is stored in R3.

 UDIV: UDIV R5, R5, R1

//UDIV implies unsigned divide and the operation is performed R5


= R5/R1. The values stored in register R5 and R1 are divided and
the result is stored in R5.

6. MOV instruction:
 MOV: MOV R5, #25

//this instruction writes the value of 25 to the register R5.

 MOVS: MVOS R5, R10

//this instruction writes the value in R10 to the register R5 and


flag gets updated.

 MVNS: MVNS R5, #0xF

// this instruction writes the value of 0xFFFFFFF0 (bitwise inverse


of 0xF) to the R5 and update flags.

7. LOAD instruction: LDR R10, NUM


//this instruction loads R10 with the value of NUM in memory.

8. STORE instruction: STR R5, [R3]

//Store the value in R5 to NUM.

9. LOGICAL SHIFT instruction:


 Logical shift right ( LSR ): LSR R5, R10, #10

//this instruction implements Logical shift right by 10 bits

 Logical shift left ( LSL ): LSL R1, R2, #5

//This instruction implements logical shift left by 5 units.

 Rotate right by value ( ROR ): ROR R2, R3, R5


//This instruction rotate right by the value in the bottom byte of
R5

 Rotate right with extend ( RRX ): RRX R1, R2


//Rotate right with extend (one bit only)

 Logical shift left (LSLS): LSLS R1, R2, #5

//Logical shift left by 5 bits with flag update.


10. LOGICAL OPERATION:
 AND: AND R10, R2, R1

//The logical AND instruction does the operation → R10=R2 AND


R1. And operation is applied to the register R1 and R2 and the
result is stored in R10.

 ORR: ORR R10, R2, R1

//The logical ORR instruction does the operation → R10=R2 OR


R1. And operation is applied to the register R1 and R2 and the
result is stored in R10.

 EOR: EOR R1, R2, R3

//The logical EOR instruction does the operation → R1=R2 XOR


R1. And operation is applied to the register R1 and R2 and the
result is stored in R1.

*****************************************************************************

TITLE: Assembly Language ADD program

OBJECTIVE: To investigate arithmetic Operations and implement them in keil


uvision using assembly language.

TOOLS UTILIZED:

 Software used: Keil micro vision


 Programming Language used: assembly language

PROCEDURE:

Program:
AREA arithmetic1, CODE, READONLY

//AREA is directive which instructs the assembly to assemble a new


code. CODE contains machine instructions. READONLY is a default
keyword.

MOV R1, #0x0000000A

//MOV instruction copies the value of #0x0000000A into R1 (rd


destination-register, memory. #0x0000000A - hexademical literal
( assembly dependant syntax)

MOV R2, #0x00000006

//MOV instruction copies the value of #0x0000000 into R2 (rd


destination-register, memory. #0x0000000A - hexademical literal
( assembly dependant syntax)
ADD R3, R1, R2

// adds the values in R1,R2 and stores the result in R3.

END

// end of program

RESULT:

R1 = 0x0000000A

R2 = 0x00000006

R3 = 0x00000010

DATA:

Input Instructions Output

r1,r2,r3 MOV, ADD r1=0x0000000A,


r2=0x00000006
r3=0x00000010

INFERENCE:

On the basis of the program written above , the conclusion has been clearly
explained through the result. The register values of r1 and r2 have been
added and the result is stored in another register r3.

******************************************************************

TITLE: Assembly Language MOV program

OBJECTIVE: To investigate MOV instruction and implement them in keil


uvision using assembly language.

TOOLS UTILIZED:

 Software used: Keil micro vision


 Programming Language used: assembly language

PROCEDURE:

Program:
AREA movinstruction, CODE, READONLY

//AREA is directive which instructs the assembly to assemble a new


code. CODE contains machine instructions. READONLY is a default
keyword.

MOV r5, #5

//MOV instruction copies the value of 5 into r5(rd-destination-


register, memory). #5 is a literal

MOV r7, #8

//MOV instruction copies the value of into r7(rd-destination-


register, memory). #8 is a literal

MOV r7, r5

//MOV instruction copies the value of r5 into r7(r5=r7). #5 is a


literal.

END

// end of program

RESULT:

r5 = 0x00000005

r7 = 0x00000005

DATA:

Input Instructions Output

r5,r7 MOV r5=0x00000005


r7=0x00000005

INFERENCE:

On the basis of the program written above , the conclusion has been clearly
explained through the result. The mov instructions copies the value of one
register into another which implies that the value of r5 is copied to r7.

******************************************************************

TITLE: Assembly Language REVERSE SUBTRACTION program


OBJECTIVE: To investigate reversesubtract instruction and implement them in
keil uvision using assembly language.

TOOLS UTILIZED:

 Software used: Keil micro vision


 Programming Language used: assembly language

PROCEDURE:

Program:
AREA reversesubtract, CODE, READONLY

//AREA is directive which instructs the assembly to assemble a new


code. CODE contains machine instructions. READONLY is a default
keyword.

MOV r5, #0x00000000

//MOV instruction copies the value of r5 into rd(destination-


register, memory). #0x00000000- hexadecimal literal ( assembly
dependant syntax)

MOV r6, #0x00000000

//MOV instruction copies the value of r6 into rd(destination-


register, memory). #0x00000000- hexadecimal literal ( assembly
dependant syntax)

MOV r7, #0x00000077

//MOV instruction copies the value of r7 into rd(destination-


register, memory). #0x00000077- hexadecimal literal ( assembly
dependant syntax)

RSB r5, r7, r6

// RSB means reverse subtract without carry. RSB {Rd} ,Rn, operand2.
Rd is the destination register, Rn is the register holding first
operand, operand2 is the second operand. The instruction subtracts
the value in r7 from the value of r6 and stores in r5.

END

// end of program

RESULT:
r5 = 0xffffff89
r6 = 0x00000000

r7 = 0x00000077

DATA:

Input Instructions Output

r5,r6,r7 MOV, RSB r5=0xffffff89


r6=0x00000000
r7=0x00000077

INFERENCE:

On the basis of the program written above , the conclusion has been clearly
explained through the result. The value in r6 is subtracted from value in r7.
This can be seen can performed in keil IDE.

******************************************************************

You might also like