Thurs, 29th Oct 2015, 19:45 Some help for lab 2

My students,

In class late on Wednesday, I tried to give you some hints that would help
you with lab2, but we ran out of time.  So I thought I would provide this
email.  Feel free to ask your TA anything about it in discussion tomorrow,
and/or any of the TAs during office hours.  For those of you who had
discussion session today and want to simply show up to another session
tomorrow, please do so.

What I am providing below are a number of snippets of LC-3 code, each of
which does something that you might find useful in writing your program to
solve the problem of lab2.

Recall in class, we identified two locations: VALUE and ADDR.  VALUE was to
contain a value that we were going to check the linked list to see if it
exists.  ADDR was to contain the address of the list head.

VALUE .FILL <<the value>>
ADDR  .FILL x4000  ; If the listhead is at location x4000

Both of these will come after the TRAP x25 in your program.

Now then, what does the following snippet of code do?

ADD R0,R0,#1

It would be good to look at the figure of the linked list at the bottom of
the lab assignment as you follow these snippets of code.  What I would like
you to do is see what each does with respect to that figure.



LDR R4,R2,#1
ADD R4,R4,R0


LDR R5,R2,#0
STR R5,R1,#0

In the lab we do not have a single VALUE.  Instead we have a second linked list
where each value (i.e., drivers license) in the second linked list has to be
checked against the values in the first linked list.

Finally, you need to put those nodes that are present in both lists at the
end of a third linked list, whose listhead is in location x4002.

Suppose you have just discovered a person who is both a millionaire and a
professor.  You have already removed him/her from both linked lists.  Now you
have to insert him/her at the end of the third linked list, whose listhead is
at x4002.  Let's say that the node at x8050,x8051 has just been removed
from the two lists.  You have a register pointing to it, say R5.  That is,
R5 = x8050.  You also have a register pointing to the node you previously
last added to the third list.  Say that register contains xB000.  Then you
know the contents of xB000 = x0000.  Your job is to put x8050 into location
xB0000, and x0000 into location x8050, thereby inserting this node at the
end of the third list.

I will leave it for you to write the snippet of code to do that task.

By the way, when your program starts, there are no elements in the third
list.  Therefore what are the contents of x4002, the listhead for the third

Good luck with lab 2.

Yale Patt