NASM - The Netwide Assembler

NASM Forum => Summer of Code Ideas => Topic started by: uncle Richard on May 07, 2019, 07:42:06 AM

Title: Nasm is still quite stupid enough
Post by: uncle Richard on May 07, 2019, 07:42:06 AM
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
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]
 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
[section .bss]
[common num 200]
[common AtMeTwo 4]
[common AtMeToo 4]
[common LookAtMe 4]
[extern printf]
[section .rdata]
 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 Windows32, 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:
Title: Re: Nasm is still quite stupid enough
Post by: uncle Richard on May 10, 2019, 09:32:56 AM
Three days have passed. But H. Peter Anvin, Cyrill Gorcunov, Chang Seok Bae, Jim Kukunas, Frank B. Kotler are silent. So. The main problem with Nasm is that it does not have a linker. And if it is not needed in Linux, in Windows it is absolutely necessary. TCC is a C compiler and a satisfactory linker for the elf format, simultaneously. But no one can guarantee on how correct this TCC is.

A bunch of Gcc+Yasm+TCC brings a result of 87, too. Thus, Gcc and TCC can be defective, and Nasm can be normal. The earlier Nasm will acquire its own linker and IDE, the better. Fasm popularity is the best proof of this.

It should be only one regret. MSVC, GCC, TCC, DmC, Pelle C, PCC, NASM, FASM, YASM, GOASM, UASM, MASM are excellent compilers, each in its own way. And this is good. The bad thing is that they are completely incompatible with each other. Even at the 'Hello World' level. And they will not.

Pelle C is closest to me. I wrote a small converter Pelle -> NASM + TCC. Everything works, except comm variables. Even Agner Fog does not know what to do with them.
Title: Re: Nasm is still quite stupid enough
Post by: Frank Kotler on May 10, 2019, 11:58:46 PM
Hi uncle Richard,

Welcome to the forum.

I am terribly sorry you had trouble with Nasm.