Nasm is still quite stupid enough
Not so long ago, Nasm (version 0.98.38 compiled on Mar 5 2011) could not correctly count near jumps. Now, uninitialized variables still stink, too. Here is a simple program:
//no.c (c) Tereshkov_OE
//sites.google.com/site/excelmidi
extern void printf (const char *_Format,...);
int LookAtMe, AtMeToo, AtMeTwo;
int num[50];
void _start(void)
{
LookAtMe=67; AtMeToo=45; AtMeTwo=29;
LookAtMe = LookAtMe+AtMeToo+AtMeTwo;
printf(" %d\n", LookAtMe);
}
Take Pelles C 8.0 and get:
[global _start]
[section .text]
_start:
push ebp
mov ebp,esp
sub esp,4
mov dword [(LookAtMe)],67
mov dword [(AtMeToo)],45
mov dword [(AtMeTwo)],29
mov eax,dword [(LookAtMe)]
add eax,dword [(AtMeToo)]
mov dword [ebp+(-4)],eax ;stupidity
add eax,dword [(AtMeTwo)]
mov dword [(LookAtMe)],eax
push dword [(LookAtMe)]
push dword (@10)
call printf
add esp,(8+3)&(~3) ;double stupidity
mov esp,ebp
pop ebp
ret
[section .bss]
[common num 200]
[common AtMeTwo 4]
[common AtMeToo 4]
[common LookAtMe 4]
[extern printf]
[section .rdata]
@10:
db ' %d',10,0
[cpu pentium]
Nasm (version 2.14.02 compiled on Dec 26 2018) like compiler. Tcc as linker. Run the program. Result 87. From which it follows that nobody uses Nasm under Windows, including the authors. PureBasic 3.20 was try to use Nasm and then went to Fasm. Why?
The same program for PCC&Yasm like compiler and TCC as linker brings 141. Archive.
(C) Oleg E. Tereshkov. May 2019.