Replies: 4 comments
-
You can access a register indirectly through the register address space. Unfortunately the decompiler will emit a ton of warnings about ignoring this indirection (which is what you want). Assuming that the scenario in which the default register bank is not used is rare, you can use a context register to control whether or not they are accessed indirectly. You will need to use a table for all your registers in every constructor though. An example of the register table and accessing the registers indirectly through the register address space can be seen here. https://github.com/astrelsky/RL78_sleigh/blob/master/data/languages/rl78_tables.sinc Setting the register bank context register can be seen here. https://github.com/astrelsky/RL78_sleigh/blob/master/data/languages/rl78_map2.sinc#L556 |
Beta Was this translation helpful? Give feedback.
-
Whilst this might work, the issue here is that with the C166 does not use defined banked GPRs. The GPR registers can be ANYWHERE in memory, using the Context Pointer as the address to start from. The |
Beta Was this translation helpful? Give feedback.
-
It depends on how the registers are being used by the code. Given the fact that it's a context pointer, is it primarily being used for context switching? You may try not modeling it at all and seeing how the code looks if you just leave the registers as normal registers - this would work if most of the context switching occurs around functions. You can also model them one step further as updating the register values as a memory read for each context switch. For
Have a separate constructor for You could also look at how the pic16 does register banking with the |
Beta Was this translation helpful? Give feedback.
-
To clarify, i think this explains it better. R0-R15 are the 16 General purpose registers on the CPU CP = 0xF200R0 is at address 0xF200 CP = 0xFC00R0 is at address 0xFC00 Its worth pointing out CP register can be any arbitrary value, so using defined banks would not work. |
Beta Was this translation helpful? Give feedback.
-
I am trying to improve @esaulenka C166 module, to add support for Infineons C167 CPU.
One of the main issues that I am facing is that the CPU has banked registers, where setting the CP register will determine where in memory these registers lay. Currently, the definitions of these registers are set to the default value of the CP register (0xFC00):
Is there any way to let sleigh change the offset of these registers on the fly? It should be noted that the value of the CP register can be set to any value, so I can't just define a large bank of registers which would be a colossal mess anyway.
There is a specific instruction
scxt
which changes the value stored in the CP register.Beta Was this translation helpful? Give feedback.
All reactions