Without setting up a database of every sample online, I don't see how you can detect plagiarism. I learned x86 by looking at sample code, reading manuals and datasheets, etc, and rewriting code with extensive commenting. Being a mathematician helped me learn a lot, and made writing new code rather easy.