I'm using Borland C and using the build in assembler BASM, but have some general questions.
If a function s not declared something else, is it _cdecl by default?
I read about calling conventions here:
https://en.wikipedia.org/wiki/X86_calling_conventions#cdecl
It says that: Registers EAX, ECX, and EDX are caller-saved, and the rest are callee-saved.
This would imply that BX/EBX should be callee saved. But, a stepping through a function that Borland C compiles shows it using BX in the function without any concern for changing it.
Then, from the chapter 12 of the Borland C++ 3.1 programming guide:
Inline assembly code can freely u~e SI or DI as scratch registers. If
you use SI or DI in inline assembly code, the compiler won't use
these registers for register variables.
It doesn't mention using AX, BX, CX, DX, at all. Is this because it is common knowledge? Why mention SI/DI specifically here and not others?
Then I found this:
https://www.agner.org/optimize/calling_conventions.pdf
It shows on page 10 that AX, BX, CX, DX, ES, and something called ST(0)-ST(7) are scratch registers.
Which ones should be saved if used? Maybe there is a place in the Borland documentation I am missing this.
If a function s not declared something else, is it _cdecl by default?
I read about calling conventions here:
https://en.wikipedia.org/wiki/X86_calling_conventions#cdecl
It says that: Registers EAX, ECX, and EDX are caller-saved, and the rest are callee-saved.
This would imply that BX/EBX should be callee saved. But, a stepping through a function that Borland C compiles shows it using BX in the function without any concern for changing it.
Then, from the chapter 12 of the Borland C++ 3.1 programming guide:
Inline assembly code can freely u~e SI or DI as scratch registers. If
you use SI or DI in inline assembly code, the compiler won't use
these registers for register variables.
It doesn't mention using AX, BX, CX, DX, at all. Is this because it is common knowledge? Why mention SI/DI specifically here and not others?
Then I found this:
https://www.agner.org/optimize/calling_conventions.pdf
It shows on page 10 that AX, BX, CX, DX, ES, and something called ST(0)-ST(7) are scratch registers.
Which ones should be saved if used? Maybe there is a place in the Borland documentation I am missing this.