Leftrotate program - ADD R3, R1, R3 ;if R2, is negative,...

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

View Full Document Right Arrow Icon
;Mohammad Chauhan ;mmc2762 .ORIG x3000 LD R1, xFF ;load R1 with word N from x3100 LD R2, xFF ;load R2 with amount N is to be rotated by from x3101 BRz x000D ;if R2 is zero branch to store ADD R3, R1, #0 ;Add R1 and 0 to put the same amount R1 into R3 BRn x0005 ;if R2 is negative, branch to x300A (intructions for negative rotations) ADD R3, R1, R3 ;add value in R1 to R3 and store in R3 ADD R1, R3, #0 ;Add R3 and 0 to put the amount R3 into R1 ADD R2, R2, #-1 ;decrement value of counter that was placed in R2 by 1 BRp x-006 ;if R2 in still positive, branch to x3003 and repeat instructions BRz x0006 ;if R2 is now zero, branch to store
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ADD R3, R1, R3 ;if R2, is negative, the program will be branched here. Add value in R1 to R3 and store in R3 ADD R3, R3, #1 ;since R2 is negative add 1 to R3 ADD R1, R3, #0 ;Add R3 and 0 to put the amount R3 into R1 ADD R2, R2, #1 ;add 1 to the value of counter that was placed in R2 BRn x-00C ;if R2 is still negative, branch to x3003 and repeat instructions BRz x-00E ;if R2 is now zero, branch to x3003 and repeat instructions ST R1, xF1 ;Store rotated answer R1 into x3102 TRAP x25 ;Halt the program .END ;End the program...
View Full Document

This note was uploaded on 10/27/2011 for the course BME 14015 taught by Professor Dr.ren during the Fall '10 term at University of Texas at Austin.

Ask a homework question - tutors are online