AnsweredAssumed Answered

Subroutines on the 7970 ISA

Question asked by realhet on Jul 21, 2012
Latest reply on Aug 11, 2012 by realhet

Hi again,

 

I'm trying to make subroutines in ISA, right now, I've managed to do it with a one level stack this way:

 

@subRoutine:

    v_mov_b32 v1, 128  //do something

    s_setpc_b64 s[32:33]  //return to caller

 

@main:

  s_getpc_b64 s[32:33]

  s_add_u32 s32,s32,12

  s_addc_u32 s33,s33,0  //calculate return address

  s_branch @subRoutine  //call the subroutine

  ...

 

It's working well, but only with 1 level nesting. I've figured out that using s_movrel or LDS I can make a small stack to expand it.

Then I've found a thing called branch-stack along with the instructions:

s_cbranch_i_fork cond, addr

s_cbranch_join s0   // s0: Saved CSP value.

But it crashed (as expected) since I absolutely don't know what is that 'CSP value'.

If anyone can explain how to use this branch-stack the elegant way, I'd be really thankful.

Outcomes