Hi folks,
Just something I discovered today that may be useful (although I guess many people will already know about it). I was having some strange problems with MikeOS after building it on Ubuntu 11.04 (my test box had been running Ubuntu 9.04 before that). It turns out that NASM 2.09, released last year, enables the -Ox optimisation flag by default, which was doing funny things to my executables.
Using "-O0" (dash oh zero) fixed that and left the resulting binaries as intended. Just thought I'd note it here in case anyone has similar problems in the future and suspects it's something else in eg Linux/QEMU that's at fault (like I did for a few hours!).
Cheers,
Mike
NASM 2.09 turns on optimisation by default
-
- Member
- Posts: 155
- Joined: Fri Oct 27, 2006 5:11 am
- Location: Oberbayern
- Contact:
NASM 2.09 turns on optimisation by default
MikeOS -- simple, well-documented x86 real-mode OS written in assembly language
http://mikeos.sourceforge.net
http://mikeos.sourceforge.net
Re: NASM 2.09 turns on optimisation by default
They need to update the wording then. I just did a 'nasm -h' with 2.09.09:
-O<digit> optimize branch offsets
-O0: No optimization (default)
-O1: Minimal optimization
-Ox: Multipass optimization (recommended)
-Ian
-O<digit> optimize branch offsets
-O0: No optimization (default)
-O1: Minimal optimization
-Ox: Multipass optimization (recommended)
-Ian
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly
Re: NASM 2.09 turns on optimisation by default
Hi,
Given that NASM's optimiser doesn't really do much (optimises short/near jump offsets and simplifies a few operands); I'd be tempted to use the same logic for NASM - e.g. "enabling optimisations breaks my code" probably means your code is broken (e.g. missing "strict" qualifier somewhere, making assumptions about the length/s of instruction/s, etc).
Cheers,
Brendan
For high level languages like C, when someone says "enabling optimisations breaks my code" it almost always means their code is wrong (e.g. missing "volatile" somewhere, use of uninitialised data, etc).M-Saunders wrote:It turns out that NASM 2.09, released last year, enables the -Ox optimisation flag by default, which was doing funny things to my executables.
Given that NASM's optimiser doesn't really do much (optimises short/near jump offsets and simplifies a few operands); I'd be tempted to use the same logic for NASM - e.g. "enabling optimisations breaks my code" probably means your code is broken (e.g. missing "strict" qualifier somewhere, making assumptions about the length/s of instruction/s, etc).
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
-
- Member
- Posts: 155
- Joined: Fri Oct 27, 2006 5:11 am
- Location: Oberbayern
- Contact:
Re: NASM 2.09 turns on optimisation by default
Hi,
Ian: I just saw it here: http://www.nasm.us/doc/nasmdocc.html
"Make -Ox the default optimization level. For the legacy behavior, specify -O0 explicitly."
Brendan: Oh absolutely, and I suspect that this is symptomatic of another problem in my code. Still, with different people on the MikeOS mailing list having different kernels, going back to -O0 will have us all "singing from the same hymn sheet" and we can look at it from there.
Cheers,
Mike
Ian: I just saw it here: http://www.nasm.us/doc/nasmdocc.html
"Make -Ox the default optimization level. For the legacy behavior, specify -O0 explicitly."
Brendan: Oh absolutely, and I suspect that this is symptomatic of another problem in my code. Still, with different people on the MikeOS mailing list having different kernels, going back to -O0 will have us all "singing from the same hymn sheet" and we can look at it from there.
Cheers,
Mike
MikeOS -- simple, well-documented x86 real-mode OS written in assembly language
http://mikeos.sourceforge.net
http://mikeos.sourceforge.net