Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Raise an Illegal Instruction in RISC-V on Purpose

What is the simplest, most readable and straightforward way to raise an illegal instruction in RISC-V on purpose?

I know that per spec any "full zero" instruction (so 32/16 bits only zeros) is a "Defined Illegal Instruction" (section 12.5, user spec). But I have no idea if there exists an asm shorthand for that (at least I could not find any) that I could then use in inline asm in C code.

There must surely be a portable and reliable way to always cause an illegal instruction exception? I personally find writing to read-only registers or similar hacks quite offputting, as they are not very explicit. But maybe this is just how its done?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thank you in advance

>Solution :

The mnemonic for it is unimp. It is documented in the RISC-V asm manual, so it should be portable.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading