Always switch Stack Segment to 32 bit after entering Protected Mode.
Posted: Sat Jul 20, 2024 2:28 pm
It is not a question but a piece on information for those who may have encountered the same problem as i.
If your software enters Protected Mode you shall not leave Stack Segment in 16bits. The problem is that C language works perfectly fine with passing finite arguments to functions, but as soon as you start using variardic arguments things will break: va_arg will either give garbage or zeroes and would not work as intended.
It is no more than hypothesis, but it may be caused by SS not being equal 0 while C assumes flat memory model. This leads to push and pop instructions work fine but direct access to the stack top breaks somehow.
If your software enters Protected Mode you shall not leave Stack Segment in 16bits. The problem is that C language works perfectly fine with passing finite arguments to functions, but as soon as you start using variardic arguments things will break: va_arg will either give garbage or zeroes and would not work as intended.
It is no more than hypothesis, but it may be caused by SS not being equal 0 while C assumes flat memory model. This leads to push and pop instructions work fine but direct access to the stack top breaks somehow.