1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

XOR in LC3

  1. Nov 10, 2016 #1
    1. The problem statement, all variables and given/known data
    Write a sequence of LC-3 instructions (in bits) to set R0 equal to R1 XOR R2. Assume that values have already been placed into R1 and R2 for you. You may not change the values of any other registers (only R0, R1, and R2). Include RTL or assembly comments explaining the action of each binary instruction. Hints: You MAY change R1 and R2. You should only need eight instructions.


    2. Relevant equations
    LC3

    3. The attempt at a solution
    I came up with X XOR Y = [(xy')' & (x'y)']'

    using demorgans, but I can't figure out a way to XOR R1 and R2 using only the 3 registers. R1 and R2 should hold the values to be XOR'd and R0 should store the result. How do I do this?
     
  2. jcsd
  3. Nov 11, 2016 #2

    NascentOxygen

    User Avatar

    Staff: Mentor

    If you post your attempt it may help those who could assist but who aren't familiar with LC-3 instructions.
     
  4. Nov 11, 2016 #3

    jbriggs444

    User Avatar
    Science Advisor

    According to Wiki, LC3 is an assembly language for an 16 bit architecture with a 64K address space and eight general purpose registers, R0 through R7. The instruction set is small with only 15 op codes. The only register to register operations are AND, NOT and ADD. The remaining instructions are for loads, stores

    It is a load-store architecture. But for our purposes, only the register-to-register instructions (AND, NOT and ADD) are relevant.

    There is an opcode for ADD immediate. This takes one register and an immediate literal (specified within the instruction) as input and puts the sum in the designated output register. With a literal #0, this can be used as a register to register move. Similarly, there is an AND immediate which, with a literal #0, could be used as a register clear.

    There is an opcode for ADD. This takes one register, ANDs it with a second and leaves the result in the second.

    There is an opcode for NOT. This takes one register, bitwise complements it and stores the result in another.

    So the problem at hand is how to evaluate this expression while using only three registers. Can you write code to calculate the left hand term: (xy')', leaving the result in R0 and leaving R1 and R2 intact?
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: XOR in LC3
  1. 4 input xor gate (Replies: 2)

  2. Designing an XOR gate (Replies: 2)

  3. XOR gate circuits (Replies: 12)

  4. LC3 question (Replies: 3)

Loading...