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
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

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

VALUE .FILL <<the value>>

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

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

LD R0,VALUE
NOT R0,R

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,R2,R2,#0

Next,

LDR R4,R2,#1

Next,

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
list?

Good luck with lab 2.

Yale Patt

```