V850E2 Calling subroutines in Assembler

Hi Guys, just 2 questions. I'm new to the V850E2 but years of experience using Atmel microcontrollers programming in Assembler. 

1. How do I call a subroutine in V850E2 in Assembler? I've looked in the assembler manual and can't find any call command.

Atmel chips use a RCALL/RET command but can't seem to find anything similar on V850E2.

e.g.

LOOP:

          LDI R16,255

          RCALL DELAY ;call delay routine

          RJMP LOOP

DELAY:

             DEC R16

             BRNE DELAY 

             RET ;return from call command

2. Where do I go for V850E2 assembler support?

Thanks guys

Pete.

  • Software manual should be refered to for instruction format.  The assembler you use should have details on things it provides such as macros.

    documentation.renesas.com/.../r01us0001ej0100_v850e2m.pdf

    Never have used this processor but quick look at the manual indicates you should be looking at using the CALLT/CTRET instructions or the JARL/JMP instructions.  These aren't quite as you would expect them as they don't save anything to the stack and rely on you to save any registers that need to be saved.

    Paul.

  • In reply to Paul Brown:

    Thanks Paul for the fast reply. I was hoping that I missed an instruction in the manual but I guess not. So I have to do my own software stack house keeping then in internal ram. I didn't really want to do that but I guess I have no choice. Thanks Paul.  

  • In reply to Peter Adamcik:

    Do you know anywhere where I can get some V850E2 assembler snippets from? I've searched the web but can't seem to find anything.

  • In reply to Peter Adamcik:

    Hello Peter,

    unfortunately you didn't mention which tools you are using. If you are using the IAR Embedded Workbench for V850, please have a look at the runtime library source or in the information center. You find the library source code (some modules are C , some are assembler source code) in the sub-folder V850/src of your EWV850 installation.

    Alternatively you can write some C code and let the compiler generate the corresponding assembler code as an example. Please set the marked option in the GUI:

  • In reply to Fragero:

    Hi Fragero, thanks for your reply. I'm using CS+. I've learned that I have to use jarl label,r31. This saves the return address in register 31.

    Other microcontrollers save the return address on the stack so if I have many nested subroutines all the return addresses is saved on the stack and the cpu handles it.

    Can the V850E2 store the return addresses on the stack? It doesn't have a RET command to tell the CPU to get the last saved address from the stack for the Program Counter.

    Do I have to save every return address manually via R31 every time I jump to a subroutine? I'm not liking that at all.

    Also, I'm not a C+ programmer. I'm an assembler programmer and have been for over 20 years starting with the 6502 CPU's (Atari 800XL). :)

    So far I've studied the assembler commands and all is quite simple. The only thing disappointing is what I've written above. we may have to consider another microcontroller for our product. Hopefully this won't be the case.

    Thanks again Fragero for your reply.

    Pete.