{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

PS06-soln - R5 keeps track of column start in target ADD R5...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 109 Spring 2010 Name:__________________________________________ Section:______________________ Apr 5-8, 2010 1 Problem Session 6 Write your subroutine here and turn in this page only make sure to write your name and section on this page before you turn it in. There are several possible solutions, of course. Here s one. TRANS ST R0, TR0 ; save registers ST R1, TR1 ST R2, TR2 ST R3, TR3 ST R4, TR4 ST R5, TR5 ; R0 is pointer into source matrix ; R1 is pointer into target matrix ; R2 is row counter how many rows have been copied? ; R3 is inner counter which row element are we on? ; R4 is used for temporary storage
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ; R5 keeps track of column start in target ADD R5, R1, #0 TLOOP LD R3, TR2 ; initialize inner counter TL1 LDR R4, R0, #0 ; get row element STR R4, R1, #0 ; store to column in target ADD R3, R3, #-1 ; count down until zero BRz TL2 ADD R0, R0, #1 ; next row element LD R4, TR2 ; next col element ADD R1, R1, R4 BRnzp TL1 TL2 ADD R0, R0, #1 ; start of next row ADD R5, R5, #1 ; start of next column ADD R1, R5, #0 ADD R2, R2, #-1 ; decr row counter BRp TLOOP LD R0, TR0 ; restore registers LD R1, TR1 LD R2, TR2 LD R3, TR3 LD R4, TR4 LD R5, TR5 RET TR0 .BLKW 1 TR1 .BLKW 1 TR2 .BLKW 1 TR3 .BLKW 1 TR4 .BLKW 1 TR5 .BLKW 1...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online