Hey guys, I'm writing three small programs to get started out, one to shift a bit value in R0 right by the value in R1 also the same principle but rotating the Bits left and right, and I was wondering if anyone could give any code snippets or plain english pointers on how to do it.
Posted on 2010-11-25 10:59:07 by wolfy200222
Okay i have the shift right sorted after alot of pain and fiddling :) could someone hint to what the rotate right and left like... operators are? Maybe its not the right word but, shift right is a divide, what are the rotates equivalent to?
Posted on 2010-11-25 12:44:25 by wolfy200222
Read the description here.
Posted on 2010-11-26 09:34:08 by SpooK
Thanks for your reply but we dont have the RCL or any rotate commands using the LC3 - I have some code which is buggy, if you could help with that, that would be awesome.

.ORIG x3000;
MASK .FILL x8000;
ADD R0, R0, #0; check R0 is positive
BRp IS_POSITIVE ; if the value is negative or zero, this code will be skipped
LOOP LD R3, MASK; store mask in register
AND R2, R3, R2; stores the leftmost bit in R2
ADD R0,R0,R0; ADD R0 to iteslf
ADD R2, R2, R2; restores the check for leftmost bit
IS_POSITIVE; will execute if positive value in R0
ADD R0, R0, #1;
LDR R4, R1, #0; R4 used for counter
ADD R4,R4, #-1; decrement counter
;  If counter < R1 , go back to start of loop ???

The question mark bits are where im stuck, the mask is used to find the most significant bit... Basically R0 needs to be rotated by the amount specified in R1
I get an error saying Invalid instruction at PC=X3000; RTI executed with user mode privilege
Posted on 2010-11-28 07:11:46 by wolfy200222