Docsity

ECE 2534 Test 1 - Subroutine to Convert Decimal to BCD, Exams of Microprocessors

Toggle sidebar
bg1
ECE 2534 Test 1 2/19/08
1. Fill in the blanks in the .lst file given below.
1 .text
2 .globl subroutine
3 subroutine:
4 0000 00600000 add r3,r0,r0
5 0004 24E00020 ______________
6 label1:
7 0008 BCA50008 bgei r5,label2
8 000c 20630001 addi r3,r3,1
9 label2:
10 ____ ________ add r5,r5,r5
11 ____ 20E7FFFF addi r7,r7,-1
12 ____ ________ bgti r7,label1
13 001c B60F0008 rtsd r15,8
14 0020 80000000 nop
2. Write a header for the subroutine below. It is meant to be called from C.
.text
.globl subroutine
subroutine:
addi r6,r0,8
lwi r5,r1,4
label:
lw r8,r1,r6
add r5,r5,r8
addi r6,r6,4
rsubi r7,r6,40
bgei r7,label
addi r6,r0,10
idiv r3,r6,r5
rtsd r15,8
nop
pf3
pf4
pf5

Partial preview of the text

Download ECE 2534 Test 1 - Subroutine to Convert Decimal to BCD and more Exams Microprocessors in PDF only on Docsity!

ECE 2534 Test 1 2/19/

  1. Fill in the blanks in the .lst file given below. 1 .text 2 .globl subroutine 3 subroutine: 4 0000 00600000 add r3,r0,r 5 0004 24E00020 ______________ 6 label1: 7 0008 BCA50008 bgei r5,label 8 000c 20630001 addi r3,r3, 9 label2: 10 ____ ________ add r5,r5,r 11 ____ 20E7FFFF addi r7,r7,- 1 12 ____ ________ bgti r7,label 13 001c B60F0008 rtsd r15, 14 0 020 80000000 nop
  2. Write a header for the subroutine below. It is meant to be called from C. .text .globl subroutine subroutine: addi r6,r0, lwi r5,r1, label: lw r8,r1,r add r5,r5,r addi r6,r6, rsubi r7,r6, bgei r7,label addi r6,r0, idiv r3,r6,r rtsd r15, nop
  1. Write a subroutine that implements the header below. ####################################################

Description: Converts a positive number known to

be less than 1000 (base 10) to BCD

digits.

Register Usage:

Input: r5 โ€“ number to be converted

Output: r3 โ€“ number of 100โ€™s in input

r4 โ€“ number of 10โ€™s in input

r5 โ€“ number of 1โ€™s in input

Scratch r6-r

####################################################