We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
i am wondering how to give back a value of a subroutine to the calling routine and use a register when using scxt.
example:
SCXT CP,#0FC40h
NOP
CALLS something
CMP R10, ONES
JMP CC_NE, somewhere
POP CP
the problem is i would like to pop cp direktly afer the subroutine returns, but in this case R10 is lost.
You can access the registers of any register bank as internal RAM locations. In your example register R10 of the bank at 0FC40H is the RAM word at address 0FC54. Of course you are then limited to the commands supporting direct memory word access. You would have to change the command:
CMP R10,ONES
to
CMP 0FC54H,ONES
However, it would be better to use symbolic names for the register banks:
?C_MAINREGISTERS REGDEF R0 - R15 ;the default register bank (see START167.ASM) ALT_REGS REGDEF R0 - R15 ;your alternate register bank ;Alternate bank RAM addresses ALT_R0 EQU (ALT_REGS+0) ALT_R1 EQU (ALT_REGS+2) . ALT_R10 EQU (ALT_REGS+20) . ALT_R15 EQU (ALT_REGS+30)
Now you could write:
CMP DPP3:ALT_R10,ONES
The advantage in this approach is that you don't need to worry where in RAM the registers are actually located.
I doubt that you don't really need all 16 registers in the alternate register bank. If this is true, you could only allocate as many registers as you actually need (see the REGDEF documentation).
Sauli
P.S. Don't ask me what the difference between REGDEF and REGBANK is - I don't know.