I have tried to compile IAR port with different data and code models and it works for small code model only.
Meduim and large code models does not works; same as large data model.
I have found that all models was supported in 1.5, so something was broken or this is IAR issue?
Now it working with Small/Medium only, so something different happens when using Medium/Medium or Medium/Large, or Large/Large..
Can you give me advice how to make it working with at least Large Data Model and Medium Code Model (I cannot understand how large data model can make port not working)?
Thank you in advance!
update: As I understand, if Medium code model is used, we should use RETF in _port_switch instead of just RET.
With Large data model parameters of _port_switch given not in X MCU register, but in ?e0 virtual register (because it is 24-bit variable), that cannot fit into 16-bit register.
So, as I understand, it is needed to make #ifdef switch inside chcore_stm8.s. Can you give me edvice how to make this (i.e how to add code that works with ?e0 to existing code)?
update2: I have found solution. Despite of solution was found, I will do not remove previous lines, may be somebody will found it useful.
1. It is needed to add __near to declaration of _port_switch:
Code: Select all
void _port_switch(Thread __near * otp);
This will force compiler to use 16-bit pointer (not so bad, because all thread structs placed in RAM, i.e. below 0xFFFF), so parameter will be passed in X register in all cases (Small, Medium and Large models). We can use X register as parameter always.
2. In Medium and Large models it is needed to change RET instruction in _port_switch to RETF.
3. In Large model it is needed to add one asm("POP A") in _port_thread_start, because we need to remove 3 bytes of pointer from stack, not only 16.
I have attached changed files, I have checked in (Code-Data) SM/SL/MM/MKL/LM/LL models and found that it is working for a first look, but I will test it more.
p.s. what about adding STM8S i2c_hal driver?