0% found this document useful (0 votes)
17 views21 pages

Mpca Lab1a Introduction To Armsim

The document outlines the course structure for a Microprocessor and Computer Architecture Laboratory, detailing weekly assignments focused on ARM assembly language programming. It includes tasks such as arithmetic operations, logical operations, and string manipulations, as well as an introduction to the ARMSim simulator for executing ARM programs. Additionally, it covers hardware programming, pipelining, and hazards in computer architecture.

Uploaded by

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

Mpca Lab1a Introduction To Armsim

The document outlines the course structure for a Microprocessor and Computer Architecture Laboratory, detailing weekly assignments focused on ARM assembly language programming. It includes tasks such as arithmetic operations, logical operations, and string manipulations, as well as an introduction to the ARMSim simulator for executing ARM programs. Additionally, it covers hardware programming, pipelining, and hazards in computer architecture.

Uploaded by

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

MICROPROCESSOR AND

COMPUTER ARCHITECTURE
LABORATORY
4TH Semester(UE19CS256)

INTRODUCTION CLASS1-ARMSIM
Saturday, March 15, 2025

Prof Deepti C
Computer Science and Engineering
Microprocessor & Computer Architecture Laboratory
Course Information

WEEK 1 1. Write an ALP using ARM instruction set to add and subtract two 32 bit numbers .Both numbers are in
registers.
2. Write an ALP to demonstrate logical operations. All operands are in registers.
3. Write an ALP to add 5 numbers where values are present in registers.
4. Write an ALP using ARM instruction set to check if a number stored in a register is even or odd.
5. Write an ALP to compare the value of R0 and R1, add if R0 = R1, else subtract
6. Based on the value of the number in R0, Write an ALP to store 1 in R1 if R0 is zero, Store 2 in R1 if R0
is positive, Store 3 in R1 if R0 is negative

WEEK 2 1. Write an ALP to add two 16 bit numbers loaded from memory and store the result in memory.
2. Write an ALP to copy n numbers from Location A to Location B.
3. Write an ALP to find the factorial of a number stored in R0. Store the value in R1 (without using LDR
and STR instructions)
4. Write an ALP to find the GCD of given numbers (both numbers in memory).Store result in memory.
5. Write an ALP to add an array of ten 32 bit numbers from memory.
6. Add array of ten 16 bit numbers taking data from memory location stored as byte data (use .byte to
store the data instead of .word)

WEEK 3 1. Generate Fibonacci Series and store them in an array.


2. Write an ALP to find smallest number in an array of n 32 bit numbers
3. A) To perform Convolution using MUL instruction (Addition of multiplication of respective numbers of loc
A and loc B)
4. B) To perform Convolution using MLA instruction (Addition of multiplication of respective numbers of loc
A and loc B).
5. Write an ALP to find mul (add( a,b),c)
6. Write an ALP to find factorial using subroutine
7. Write an ALP to perform multiplication using shift method (without using MUL)
Microprocessor & Computer Architecture Laboratory
UE19CS256
Course Information

WEEK 4 1. Write an ALP to add two 16 bit numbers loaded from memory and store the result in memory.
2. Write an ALP to copy n numbers from Location A to Location B.
3. Write an ALP to find the factorial of a number stored in R0. Store the value in R1 (without using
LDR and STR instructions)
4. Write an ALP to find the GCD of given numbers (both numbers in memory).Store result in
memory.
5. Write an ALP to add an array of ten 32 bit numbers from memory.
6. Add array of ten 16 bit numbers taking data from memory location stored as byte data (use .byte
to store the data instead of .word)

WEEK 5 1. Write an ALP to implement B=a[i][j]


2. Write an ALP to implement C[k]=a[i]+b[j]
3. Write an ALP to implement Sum[i]+=a[i][j]
Write an ALP to find the length of a given string
WEEK 6 Write an ALP to copy string from one location to another
Write an ALP to find whether a given character is present in a string.
Write an ALP to find how many times a given character is present in a string

Department of Computer Science and Engineering


Microprocessor & Computer Architecture Laboratory
UE19CS256
Course Information

WEEK 7 Hardware Programming


WEEK 8 Hardware Programming
WEEK 9 Hardware Programming
WEEK 10 Pipelining
WEEK 11 Pipelining
WEEK 12 Hazards and their Solutions

Department of Computer Science and Engineering


Architecture
Profile
A
M
(Architecture) (Microcontroller)

Images courtesy https://developer.arm.com/architectures/instruction-sets

Department of Computer Science and Engineering


The Apple A7 and Raspberry Pi both use implementations of the Armv8 architecture.
Images courtesy of Wikipedia's Apple_A7 and Raspberry_Pi articles.

Department of Computer Science and Engineering


ARM
REGISTER
S

Department of Computer Science and Engineering


FORMAT OF ARM
INSTRUCTIONS
• MNEMONIC{S} {condition} {Rd}, Operand1, Operand2

Where, MNEMONIC : Short name of the instruction

{S} : An optional suffix. If S is specified, the condition


flags are updated on the result of the operation.

{Condition} : Conditions that has to be met for the execution of the


instruction.

{Rd} : Destination of the register for storing the output


of the instruction.

Operand1 : First register (either can be a register or an


immediate value).

Operand2 : Second (Flexible) operand (can be a register or an


Department ofvalue
immediate Computer Science
with a level and Engineering
of shift).
MNEMONICS IN ARM
Instruction Description Instructio Description
n
MOV Move data POP Pop on stack
ADD Addition SUB Subtraction
MUL Multiplication LSL Logical shift left
LSR Logical shift right ASR Arithmetic shift right
ROR Rotate right CMP Compare
AND Bitwise AND ORR Bitwise OR
EOR Bitwise XOR LDR Load
STR Store LDM Load multiply
STM Store multiply PUSH Push on stack
B Branch BL Branch with link
BX Branch with BLX Branch with
exchange link and
exchange
SWI/SVC System call MVN Move 2’s complement

Department of Computer Science and Engineering


INSTRUCTION
EXAMPLES
Rx, LSR n Register x with logical shift right by n bits (1 = n =
32)
Rx, RRX Register x with rotate right by one bit, with extend
ADD R0, R1, R2 Adds contents of R1 (Operand1) and R2 (Operand2
in a form of register) and stores the result into R0
(Rd).
MOVLE R0, #5 Moves number 5 (Operand2, because the
compiler treats it as MOVE R0, R0, #5) to R0 (Rd)
ONLY if the condition LE (Less Than or Equal) is
satisfied.

Department of Computer Science and Engineering


Department of Computer Science and Engineering
CONDITIONAL EXECUTION
• Branches can also be executed conditionally and used for branching to a
function if a specific condition is met.
Meaning
Condition Status of
Code (for cmp or subs) Flags
EQ Equal Z==1
NE Not Equal Z==0
Signed Greater Than
(Z==0) &&
GT (N==V)
Signed
LT Less Than N!=V
Signed Greater Than or Equal
GE N==V
Signed Less Than or Equal
(Z==1) ||
LE (N!=V)
Unsigned Higher or Same (or
Carry Set)
CS or HS C==1
Unsigned Lower (or Carry Clear)
CC or LO C==0
LOAD AND STORE
• ARM uses Load-store model for memory access
• On ARM data is must be moved from memory into
registers before being operated on.
• This means that incrementing a 32-bit value at a particular
address into register, increment it within the register, and
store it back to the memory from register.

Department of Computer Science and Engineering


BRANCHES
Branches (Jumps) allow us to jump to another code segment. This is
useful when we need to skip (or repeat) blocks of codes or jump to a
specific function. Best examples of such a use case are IFs and Loops.
There are three types of branching instructions:
• Branch (B)
• Simple jump to a function
• Branch link (BL)
• Saves (PC+4) in LR and jumps to function
• Branch exchange (BX) and Branch link exchange (BLX)
• Same as B/BL + exchange instruction set (ARM <-> Thumb)
• Needs a register as first operand: BX/BLX reg
Department of Computer Science and Engineering
ARMSIM
• ARMSim is a desktop application, it allows users to simulate the
execution of ARM assembly language programs on a system based
on the ‘ARM7TDMI’ processor.
• ARMSim includes both an assembler and a linker. When a file is
loaded, the simulator automatically assembles and links the program
However editor is not there, so file must be loaded into the
application.
• The file to be opened must be a source (.s) file or an object (.o) file.
• The window of ARMSim# program can be divided into three parts;
code view (displaying code), stack view (displaying stacks) and
register view (displaying 16 general purpose registers).

Department of Computer Science and Engineering


ARMSIM INSTALLATION ON WINDOWS

ARMSim# version 2.1 for Windows

https://webhome.cs.uvic.ca/~nigelh/ARMSim-V2.1/Windows/index.html
https://www.youtube.com/watch?v=roJ7D9wMyOk

Windows Installer
•Download and execute this file using an account
with Administrator privileges:
Installer.msi

Department of Computer Science and Engineering


ARMSIM INSTALLATION ON LINUX

https://webhome.cs.uvic.ca/~nigelh/ARMSim-V2.1/Linux/
ArmSimOnLinuxInstall.pdf

ARMSim# version 2.1 for Mac OS X


Unfortunately ARMSim# no longer works on Mac OS X.
The best alternatives are to either set up BootCamp on the Mac to run
Windows (and use the Windows version of ARMSim# of course),
or install virtual machine software to provide Linux or Windows as the
guest operating system.

Department of Computer Science and Engineering


LAB 1: Introduction to ARM Simulator

• Running the First ARM Assembly Language


Program
• Your first assembly program adds two
numbers. The numbers, 3 and 5, are assumed
to be in register 0 and register 1, respectively,
while the result is to be stored in the memory
location whose address is in register 3.

Department of Computer Science and Engineering


First assembly program
MOV R0,#3 @ Move the value 3 into register R0
MOV R1,#5 @ Move the value 5 into register R1
MOV R3,#0x3000 @ Move the address of the result into R3
ADD R2, R0, R1 @ Add the content of R0 and R1, keep result
in R2
STR R2,[R3] @ Store the content of R2 at the address in R3
.END

Department of Computer Science and Engineering


Follow the steps below to run the above program in
ARMSim#:
• (i) Write the program in note or text pad and save
as .s (source) or .o (object) extension.
• (ii) Open the simulator and select File.
• (iii) Choose Load by specifying the location of your
file and the file will be executed automatically.
• (iii) You can view the content of the registers that you
used in the program in the left side of your working
window or register view area

Department of Computer Science and Engineering


THANK YOU

Deepti C

Department of Computer Science and


Engineering
[email protected]

You might also like