From 5d6783a9bc4faf3e826b223c8e34d5583325133c Mon Sep 17 00:00:00 2001 From: cnlohr <lohr85@gmail.com> Date: Tue, 14 Mar 2023 07:35:53 -0400 Subject: [PATCH] Add note about the nop in the self-modifying code --- examples/self_modify_code/self_modify_code.c | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/self_modify_code/self_modify_code.c b/examples/self_modify_code/self_modify_code.c index 40f0940..bad54d8 100644 --- a/examples/self_modify_code/self_modify_code.c +++ b/examples/self_modify_code/self_modify_code.c @@ -22,6 +22,7 @@ uint32_t ReadCSRSelfModify( uint16_t whichcsr ) // instructions in this way. Otherwise, the compiler will try // to optimize the code and inline the assembly int something where // our global handle into assembly code becomes meaningless. + // Annoyingly, it has to contain at least one instruction :( asm volatile( "nop" ); // 000026f3 is csrrs a3, 0x000, x0; So, we modify it, placing the -- GitLab