0% found this document useful (0 votes)
79 views2 pages

Assignment 4 (10 Marks) : Online Submission Is Accepted ONLY. You May Scan Your Submission and Upload in BB

This document provides instructions for Assignment 4 in the course CME331: Microprocessor for Term 1. It contains 4 questions - the first asks to fill a table with register values after assembly code instructions, the second asks to fill a table calculating additions of 8-bit values, the third identifies addressing modes in instructions, and the fourth provides a subroutine to multiply an input by 12 using shift and add instructions.

Uploaded by

MahirChoudhury
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)
79 views2 pages

Assignment 4 (10 Marks) : Online Submission Is Accepted ONLY. You May Scan Your Submission and Upload in BB

This document provides instructions for Assignment 4 in the course CME331: Microprocessor for Term 1. It contains 4 questions - the first asks to fill a table with register values after assembly code instructions, the second asks to fill a table calculating additions of 8-bit values, the third identifies addressing modes in instructions, and the fourth provides a subroutine to multiply an input by 12 using shift and add instructions.

Uploaded by

MahirChoudhury
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/ 2

CME331: Microprocessor, 2018-19, Term 1

Assignment 4 (10 marks)


Online submission is accepted ONLY. You may scan your submission and upload in BB.

Q1. [3.5 marks] Fill out the table below with new value of Registers R0, R1, and R2 after the
execution of each assembly code. Write the value in 32-bit Hexadecimal.

mem1 .field 0x20001000, 32


mem2 .field 0x20000FFC, 32
mem3 .field 0x20001006, 32
Instruction R0 R1 R2

LDR R0, mem1 0x20001000

LDR R1, [R0] 0x20001000 0x0120DC1F

LDR R2, [R0], #4 0x20001004 0x0120DC1F 0x0120DC1F

LDRSB R2, [R0] 0x20001004 0x0120DC1F 0x00000078

LDR R0, mem2 0x20000FFC 0x0120DC1F 0x00000078

LDR R1, [R0, #4] 0x20000FFC 0x0120DC1F 0x00000078

LDR R0, mem3 0x20001006 0x0120DC1F 0x00000078

LSR R2, R1, #4 0x20001006 0x0120DC1F 0x00120DC1

ASR R1, R1, #4 0x20001006 0x00120DC1 0x00120DC1

Memory map for Q1


content address

0x20000FF8

0x80008001 0x20000FFC

0x0120DC1F 0x20001000

0x12345678 0x20001004

0x1F2DFD5C 0x20001008

0xABCDEF98 0x2000100C

0x20001010

Page 1 of 2
CME331: Microprocessor, 2018-19, Term 1

Q2. [2 marks] Fill out the table below for an 8-bit system.
A B R=A+B N-Z-V-C

10 100 110 or 0x6E 0-0-0-0

0x40 0xA2 226 or 0xE2 1-0-0-0

0xC3 0x6F 50 or 0x32 0-0-0-1

100 156 0x00 0-1-0-1

115 -115 0x00 0-1-0-1

Q3. [1.5 marks] What are the addressing modes used in the following instructions?

Instructions Addressing modes

LDR R1, [R0] indexed

ADD R0, R1, R2 immediate

MOV R0, #0x36 Immediate

LDR R0, mem2 PC relative

B loop PC relative

Q4. [3 marks] Write an assembly subroutine, called Mul12, that multiplies an input by 12 using
only shift and add instructions (do not use MUL instruction). The input is passed to the subroutine
by value in Register R0, and the output is returned in Register R0.
Hint: If a is a variable, then 12a = 8a + 4a

Mul12 LSL R1, R0, #3 // R1= R0*8


LSL R2, R0, #2 // R2= R0*4
ADD R0, R1, R2 // R0= R0*12
BX LR // Return from sub

Page 2 of 2

You might also like