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

The instructions for two subroutines written in mips assembly language. The first subroutine is for filling in the blanks of a given .lst file, and the second one is for converting a decimal number less than 1000 to binary coded decimal (bcd). The document also includes a header for the second subroutine meant to be called from c.

Typology: Exams

Pre 2010

Uploaded on 05/14/2009

angularmomentum
angularmomentum 🇺🇸

5

(2)

74 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

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

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