Not sure if it is mentioned somewhere, but FreeBasic does save and restore esi edi ebx in a non-naked function. Why that is, no idea, it makes little sense to allow Assembly code but then non trust the coder that he knows what he's doing. I use naked functions only since the moment when I discovered this behaviour.deltarho[1859] wrote:With PowerBASIC EBX, ESI and EDI are automatically pushed at the beginning of a procedure and automatically popped before exiting the procedure. This is to conform to the Windows programming conventions. FreeBASIC does not mention anything about preserving registers.
gcc and asm
Re: gcc and asm
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: gcc and asm
Agreed. PB used to be 16-bit producing 32-bit binaries. It is now 32-bit producing 32-bit binaries. That and the fact that Bob Zale passed away eight years ago last November with PB being frozen ever since may account for some improvements not happening when they should have by now. Having said that, the 'PB thing' may not have changed. Bob had some ideas carved in stone. I moaned about PB's RND for quite a while before he died, but he took no notice even when I showed that PractRand figured it to be one of the worst generators it had ever looked at.marcov wrote:This (the PB thing) is not normal. Normal is that callee saves non-volatile registers only IF these are used, not always. That would be unnecessary slowing, and prevent assembler users from achieving maximum performance.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: gcc and asm
@jj2007
I mentioned "FreeBASIC does not mention anything about preserving registers." in the context of the Naked description.
I mentioned "FreeBASIC does not mention anything about preserving registers." in the context of the Naked description.
Re: gcc and asm
KeyPgAsm → fxm [inside a naked procedure, there is no register preservation]
KeyPgNaked → fxm [inside a naked procedure, there is no register preservation]
KeyPgNaked → fxm [inside a naked procedure, there is no register preservation]
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: gcc and asm
@fxm
Tell me they have just been added otherwise I shall shoot myself.
Tell me they have just been added otherwise I shall shoot myself.
Re: gcc and asm
Yes, I just made these two updates.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: gcc and asm
Flaming heck fxm I had my grandfather's twelve-bore under my chin.
Re: gcc and asm
Yes, your comment was correct, sorry. It was fxm who posted misleading info.deltarho[1859] wrote:@jj2007
I mentioned "FreeBASIC does not mention anything about preserving registers." in the context of the Naked description.
fxm wrote:Not only in naked procedure, but in any asm block
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: gcc and asm
To be fair to fxm I think that it was a badly written statement rather than a misunderstanding because he took on board my comments and quickly added two warnings to the Wiki; which will no doubt appear in the chm file in due course. Had a warning existed in the description of Naked in Help this thread may not have been started. In addition, my code would not have posted because I never intended to go public with it. I would have done had it put pressure on PCG32II.
Re: gcc and asm
Allow me to restore the true context of my sentence in its original post:
- In ASM documentation page:
Therefore, my updates immediately after in the two documentation pages:fxm wrote:Not only in naked procedure, but in any asm block.deltarho[1859] wrote:This thread has been worthwhile because I now know that if we use any of the volatile registers in Naked, then they should be preserved.
Perhaps fxm can mention that in the documentation.
Paragraph already existing on the ASM documentation page:Register Preservation
- When an Asm block is opened, the registers ebx, esi, and edi are pushed to the stack, when the block is closed, these registers are popped back from the stack. This is because these registers are required to be preserved by most or all OS's using the x86 CPU. You can therefore use these registers without explicitly preserving them yourself. You should not change esp and ebp, since they are usually used to address local variables.
- In ASM documentation page:
- In NAKED documentation page:When an Asm block is opened, the registers ebx, esi, and edi are pushed to the stack, when the block is closed, these registers are popped back from the stack. This is because these registers are required to be preserved by most or all OS's using the x86 CPU. You can therefore use these registers without explicitly preserving them yourself. You should not change esp and ebp, since they are usually used to address local variables.
Note: Inside a Naked procedure, there is no such register preservation.
Naked allows the programmer to write procedures without the compiler generating any prolog/epilog code.
This is useful when writing small, fast functions in Asm without any unnecessary overhead (so, no register preservation for such Asm blocks).