当前位置:网站首页>How to stack double and float in the bottom layer of C language

How to stack double and float in the bottom layer of C language

2022-06-10 20:02:00 [email protected]

I have been wondering why printf It can be used %f Output double and float type , Because one is 8 Byte one is 4 byte , How to correctly pop the stack ?
In the reading arm Found after assembly code :
1. Variable length parameter list must be preceded by 1 Parameters , Stack pressing starts from this parameter , And stack pressing from right to left also corresponds to this mechanism ;( Finally press the left , So for the full decrement stack ,sp The address is the antecedent parameter before the variable parameter , stay vprintf You don't need to know how many are passed before )
2. about float, Will also press 8 Bytes ,double Pressed 8 Bytes all make sense ,float Will press 4 No meaningful bytes before pressing 4 Meaningful bytes , This meaningless byte is not randomly generated after testing , Relating to the encoding of meaningful bytes , There have been 0xc0000000,0x40000000,0x0, I speculate that it is possible that float When passed as a variable parameter , The default parameter will be promoted ,float Promoted to double;( Generally, parameter transfer will not be promoted by default , Only the implicit parameter list will )

原网站

版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206101740272110.html