Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 17th, 2009, 10:32 PM   #1
lilfindley
Newbie
 
Join Date: Mar 2009
Posts: 3
Rep Power: 0 lilfindley is on a distinguished road
Need help with LC-3 rotate bit pattern program

Requirements,
A program that rotates a bit pattern to the left by a certain amount, (again a number between 0 and 16, including 0 and 16). The bit pattern is found in location x3100 with the rotate amount in memory location x3101. As before, the result is to be placed in location x3102. The program starts at location x3000. The difference between a rotate and a shift is that the bits that would have been lost in the shift are 'wrapped' around and moved into the right side of the pattern. For example, if the original pattern is 1101000100001011 and the rotate amount is 0000000000001100 (decimal 12), the result in x3102 should be, 1011110100010000.

Here is what I have so far,
0011 0000 0000 0000 ; program starts at location x3000
0010 001 100000000 ; load bit pattern to left rotate
0010 010 100000001 ; load number of times to rotate
0000 010 000001011 ; branch to done if count is 0
0101 011 011 1 00000 ; clear r3
0001 001 001 1 00000 ; set condition code based on value in r1
0000 011 000000111 ; branch if positive or zero
0001 011 011 1 00001 ; most significant bit is 1
0001 001 001 000 001 ; left shift by one
0001 001 001 000 011 ; add back in shifted out bit
0001 010 010 1 11111 ; decrement count
0000 111 000000010 ; branch to top of loop
0011 001 100000010 ; store shifted result
1111 0000 00100101 ; halt the simulator

Then this is my actual code but I need help finishing it.
ST
LD, R1, NOT SURE WHAT GOES HERE
LD, R2, NOT SURE WHAT GOES HERE
BRz DONE
ADD R3,R3, #0
ADD R1,R1, ....NOT SURE WHAT TO PUT HERE
BRzp ????
ADD R3,R3,#1
ADD R1,R1,#1
ADD R1,R1,#3
ADD R2,R2, ?
BRnzp ???
ST R1 ??
TRAP x25
lilfindley is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Will pay for LC-3 assembly language program help lilfindley Paid Job Offers 0 Mar 17th, 2009 10:24 PM
bingo pattern matching lectricpharaoh Software Design and Algorithms 9 Jul 12th, 2008 6:36 PM
hello, I'd like to write a program for my work. blake_jl Community Introductions 13 Nov 23rd, 2007 4:31 PM
Language display in program Prm753 C++ 3 May 30th, 2006 5:45 PM
Creating a program to test a program sixstringartist C 8 Jan 21st, 2006 1:15 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:09 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC