HITEQUEST
technical interview Q & A for high-tech professionals
 
 
Interview Questions
Electronics Hardware
Computer Software
Intel screening questions
QA Software
Quick Thinking Tests
General questions
Phone screening questions
Submit your Q or A

Resources
Technical articles
Ask an Expert
How to get a job in Silicon Valley
Useful tips

Break point
Written Exam
Logic Tests
Professional Test
Tomato company
Cup of coffee
How stock market works
Engineering jokes

About Hitequest
About Hitequest
Home page

 
 
 
 
 
 

 
=Electronics Hardware Questions=

   
   

Q:
Your system has CPU, ALU and two 8bit registers. There is no external memory. Can you swap the contents of the registers ?

A: solution by hbegin
XOR has the unique property of giving you the original value if you XOR it twice: ((A XOR B) XOR B) = A
So... the answer:
Note: values on the left side, showing contents of the registers, happen after the step listed at right.
REG1       REG2
======================================
A       B
A XOR B     B Step 1:"XOR R1,R2" #R1 <= R1 XOR R2
A XOR B      B XOR (A XOR B) = A Step 2:"XOR R2,R1" #R2 <= R2 XOR R1
(A XOR B) XOR A = B A Step 3:"XOR R1,R2" #R1 <= R1 XOR R2

hbegin