Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Practical-2

Write an ALP to perform following task: ​1. ​Transfer data from one register to
another ​2. ​Store two numbers in register and perform addition operation. ​3.
Store two numbers in register and perform subtraction operation ​4. ​Store two
numbers in register and perform multiplication operation ​5. ​Store two

numbers in register and perform logical operations like AND, ​OR XOR. 6.

Take 3 numbers and perform multiply and accumulate. ​7. ​Square a number.

Introduction to Keil
Programming

• ​Step1: Original in Startup File:


Useful to create link between startup file and main file
Remove from the startup file.

Introduction to Keil
Programming

• ​Modified Startup File:

Replace _main by start


(not mandatory)

Introduction to Keil
Programming
• ​AREA <File Name>:
• ​It is a software defined mnemonics.
• ​It uses to define text file area where we write our program followed by
our ASM file name.

• ​CODE,READONLY:
• ​It defines the code which we are going to execute and it must be read
only at execute time.

• ​AREA pr1, code, readonly


• ​Export start
• ​Export is used in main program to create link between the startup file
and main file.

Registers of ARM7

• ​13 general-purpose registers R0-R12.


• ​One ​Stack Pointer (​ SP) R13
• ​One ​Link Register ​(LR) R14
• ​Register R14 is used as the subroutine ​Link Register (​ LR).
• ​Register R14 receives the return address when a ​Branch with Link ​(BL or BLX)
instruction is executed.

• ​One ​Program Counter ​(PC) R15


• ​Saved Program Status Register
• ​This contains the condition code flags, status bits, and current mode bits saved as
a result of the ​exception that caused entry to the current mode.

Instructions

• ​MOV:
• ​Transfer data from source to destination.
• ​MOV destination, Source
• ​MOV R1,R3 ; copy contents from R3 to R1
• ​MOV R1,#15 ; load immediate value in decimal
• ​MOV R1,#&15 ; load immediate value in hexadecimal
• ​ADD:
• ​Add source operand1 and source operand2 and store the result in
destination.
• ​ADD destination, operand1, operand2
• ​ADD R0, R1, R2 ; R0=R1+R2

Instructions

• ​SUB:
• ​Subtract source operand2 from source operand1 and store result in destination.
• ​SUB destination, operand1, operand2
• ​SUB R0, R1, R2 ; R0=R1-R2
• ​MUL:
• ​Multiply source operand1 and source operand2 and store the result in destination.
• ​MUL destination, operand1, operand2
• ​MUL R4, R3, R2 ; R4=R3 X R2
• ​MLA:
• ​Multiply source operand1 and source operand2 and then accumulate soure operand3 and store the
result in destination.

• ​MLA destination, operand1, operand2, operand3


• ​MLA R4, R3, R2, R1 ; R4= (R3 X R2)+R1
Instructions

• ​AND:
• ​Perform bitwise ANDing of source operand1 and source operand2 and store result in
destination.
• ​AND destination, operand1, operand2
• ​AND R0, R1, R2 ; R0=R1 AND R2
• ​ORR:
• ​Perform bitwise ORing of source operand1 and source operand2 and store result in
destination.
• ​ORR destination, operand1, operand2
• ​ORR R0, R1, R2 ; R0=R1 OR R2
• ​EOR:
• ​Perform bitwise Ex-ORing of source operand1 and source operand2 and store result in
destination.
• ​EOR destination, operand1, operand2
• ​EOR R0, R1, R2 ; R0=R1 Ex-OR R2

You might also like