{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# HW3 - BRA NEXT Check next item LISTY MOVE.B-1(A1(A2 Copy...

This preview shows pages 1–2. Sign up to view the full content.

ECE 662 (Sp 2009) Homework 3 Solutions Problem 1 (a) This program finds the location of the smallest element in a list whose starting address is stored in MEM1, and size in MEM2. The smallest element is stored in location DESIRED. (b) 16 words are required to store this program. We have assumed that the assembler uses short absolute addresses. (Long addresses are normally specified as MEM1.L, etc.) Otherwise, 3 more words would be needed. (c) The expression for memory accesses is T = 16 + 5n + 4m. Problem 2 A 68000 program to compare two byte lists at locations X and Y, putting the larger byte at each position in a list starting at location LARGER, is: MOVEA.L #X, A0 MOVEA.L #Y, A1 MOVEA.L #LARGER, A2 MOVE.W N, D0 SUBQ #1, D0 Initialize D0 to [N]-1 LOOP CMP.B (A0)+, (A1)+ Compare lists and advance pointers BGT LISTY MOVE.B -1(A0), (A2)+ Copy item from list X

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: BRA NEXT Check next item LISTY MOVE.B -1(A1), (A2)+ Copy item from list Y NEXT DBRA D0, LOOP Continue if more entries 17 Problem 3 A 68000 program to reverse the order of bits in register D2: MOVE #15, D0 Use D0 as counter CLR D1 D1 will receive new value LOOP LSL D2 Shift MSB of D2 into X bit ROXR D1 Shift X bit into MSB of D1 DBRA D0, LOOP Repeat until D0 reaches &1 MOVE D1, D2 Put new value back in D2 Problem 4 a. The program scans through the list starting location \$AC0000 to find the 17 th negative number in the list. b. Machine code Location Code \$AB0000 \$4280 \$AB0002 \$207C \$AB0004 \$00AC \$AB0006 \$0000 \$AB0008 \$3218 \$AB000A \$6CFC \$AB000C \$5280 \$AB000E \$0C40 \$AB0010 \$0011 (= 17) \$AB0012 \$6DF4 \$AB0014 \$33E8 \$AB0020 \$FFFE (=-2) \$AB0022 \$00AA \$AB0024 \$FFFE The last four words could be just three words: \$AB0014 \$33E0 \$AB0020 \$00AA \$AB0022 \$FFFE...
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

HW3 - BRA NEXT Check next item LISTY MOVE.B-1(A1(A2 Copy...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online