Hello,
I’m currently working with the RL78/G23 microcontroller using IAR Embedded Workbench (EWRL78) version 5.10.3, and I need some assistance with inline assembly, specifically with the CLR1 and SET1 instructions.
I want to perform bit manipulation directly within my C code. Ideally, I’m looking to achieve something similar to the ICCRX inline assembly syntax:
asm volatile("BSET %1, [%0]" : : "r" (sfr8_ptr), "r" (bit_num));
However, I’m not sure how to translate this into the correct syntax for EWRL78. Could someone guide me on how to use CLR1 and SET1 within the IAR EWRL78 environment to clear and set bits in a Special Function Register (SFR)?
Currently, I get Syntax Error message even for asm("clr1 IF0L_bit.no0");
This is an example of my C routine that I am trying to use inline assembly instead.
Has anyone come across this before? Why the example that is stated in R01UH0896EJ0130 Rev.1.30 page 1097 cannot be implemented in EWRL78?
Any examples or pointers to relevant documentation would be greatly appreciated!
Thank you in advance for your help!
Unfortunately the IAR inline assembler does not support the GNU syntax for inline assembly that accepts arguments.
Your test of asm("clr1 IF0L_bit.no0"); fails because "IF0L_bit" is not defined to the IAR assembler. The following works b/c the address and the bit position is known to the assembler::
asm("clr1 0xFFFE0.0");
When I compile the C-code:
#include "ior7f100gsn.h" // SFR definitions ... IF0L &= 0xFE;
The compiler does generate the 1-bit instruction, but this must be verified as optimization level may affect the generated output.
Thank you Jim.
I thought I was missing something in the syntax. We verified the usage of the direct address and that worked.
Hi Jim,
Just seen this in this forum and makes me wonder if the this inline assembly was supported in the first generation of RL78 and it is no longer supported?IAR RL78 implementing assembler instruction clear-1-bit - Forum - RL78 MCU - Renesas Engineering Community
If the assembler would recognize the symbol "IF0L" which is simply the address of the SFR, the syntax for the asm("clr1 IF0L.0"); insn would be fine. If your only objective was to get that simple syntax working, that is doable. Your use case was a fair bit more complex in using the GNU inline assembly syntax with arguments etc. Defining symbol names to the compiler does not automatically define them to the assembler.