Author Topic: Nasm source does not work  (Read 21384 times)

Offline Manos

  • Jr. Member
  • *
  • Posts: 24
  • Country: gr
Nasm source does not work
« on: August 27, 2014, 03:08:58 PM »
Hello.
 
I downloaded the source of nasm2.07, nasm2.09 and nasm2.11
and I builded these successfully using VC++2005 express.
But when I try to assemble some simple projects for testing,
in some cases I take error messages, like: error: label or instruction expected at start of line.
If I assemble the same source code but using pre-built Nasm executables that I downloaded, no problem.
Could someone explain me what is happening ?
 
Thank you,
Manos.
 

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Nasm source does not work
« Reply #1 on: August 27, 2014, 05:18:21 PM »
Hi Manos,

I think you're going to have to provide us with a sample of the source code that's giving you this error.

If Nasm "appeared" to compile sucessfully from source, it probably did... but there could be some subtle error. I think we're going to need more information on exactly what you did and exactly what happened before we can help you.

Thanks for any feedback you can supply.

Best,
Frank


Offline Manos

  • Jr. Member
  • *
  • Posts: 24
  • Country: gr
Re: Nasm source does not work
« Reply #2 on: August 27, 2014, 06:57:58 PM »
Thank you Frank Kotler for reply.

Send me your email to send you the attacment of the source of nasm207 that I builded
with VC++2005.
In the subfolder Bin you will find the nasm.exe and an asm example.
You can rebuild the project.
If you try to assemble this example with your prebuild nasm207.exe,
it will work OK, but with my nasm207 you will  receive errors messages.

P.S.
I am interesting to work with nasm for Win32 only.

Thank you,
Manos.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Nasm source does not work
« Reply #3 on: August 27, 2014, 08:02:12 PM »
My email is fbkotler@myfairpoint.net However, I don't "do Windows" (personal prejudice, not for "engineering" reasons), so I won't be able to evaluate your build of nasm-2.07 for Windows. I'd still like to see the asm file that's causing you problems. You can send me the whole thing, if that's easier.

In general, nasm-2.07 would be considered "obsolete" at this point. We're more interested in fixing bugs/problems with "current" versions. It's still an "interesting puzzle" why this should be happening...

Thanks again for the feedback!

Best,
Frank


Offline Manos

  • Jr. Member
  • *
  • Posts: 24
  • Country: gr
Re: Nasm source does not work
« Reply #4 on: August 27, 2014, 08:22:28 PM »
In general, nasm-2.07 would be considered "obsolete" at this point. We're more interested in fixing bugs/problems with "current" versions. It's still an "interesting puzzle" why this should be happening...

Frank

The same problem happen and with nasm211.
I sent you my email.

Manos.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Nasm source does not work
« Reply #5 on: August 27, 2014, 09:56:19 PM »
Got it, thank you. As expected, I'm not able to see any problem with it. Your "Demo.asm" assembles fine for me (Linux build of Nasm, but assembling to "-f win32")... but we knew that...

I can't imagine what VC++2005 could possibly be doing to Nasm's source code such that it would build without errors(?), but spit up a parsing error on a legitimate (if somewhat unusual) file. Anyone more familiar with Windows and/or VC++2005 want to take a guess at this?

Best,
Frank


Offline Manos

  • Jr. Member
  • *
  • Posts: 24
  • Country: gr
Re: Nasm source does not work
« Reply #6 on: August 28, 2014, 07:56:19 AM »
Hello Frank.

I think that maybe the problem is in file: outform.h.
Maybe I have not written the right #define
I am interesting for win32 only.
Could you correct the outform.h file that I sent you,
via email, so that to works on win32 ?

Thank you,
Manos.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Nasm source does not work
« Reply #7 on: August 28, 2014, 01:57:21 PM »
Oh, I see! You've been tinkering with the Nasm source without knowing what you're doing. You didn't tell us that. Still a pretty strange error to be getting...

If you want an assembler that only works on Winduhs, rather than cripple Nasm, why not just use Masm? Well... I suppose you have your reasons...

What you've emailed me appears to be outform.h from 2.07, unmodified. At least I can't see what you've done to it. I strongly suggest you work with the latest version, if you insist on doing this. It has changed quite a lot. In "USER MODIFIABLE PART", add:
Code: [Select]
#define OF_ONLY
#define OF_WIN32
That's untested - you might also need to define OF_DEFAULT. Probably not, where you only anticipate a single output format...

However, as I understand the idea, it is anticipated that one could create a custom build of Nasm without modifying the source at all. Simply define what you want on the command line to the compiler - "-DOF_ONLY -DOF_WIN32", or so. I don't know how you'd do that for VC++2005. Although the feature has been there since the beginning - one of Julian Hall's contributions, I think - I'm not sure anyone has actually used it.

If you succeed, please don't distribute the result without plainly identifying it as a crippled version of Nasm. Thanks.

Best,
Frank



Offline Manos

  • Jr. Member
  • *
  • Posts: 24
  • Country: gr
Re: Nasm source does not work
« Reply #8 on: August 28, 2014, 03:21:18 PM »
Frank,

I sent you outform.h. unmodified, as I downloaded to see this.
Of cource I have done changes, but none of them works correctly.
Your words are ironic, but you should know that I program about
16 years in C/C++ and Assembly.
You tell me not to distribute my result because it would be a  crippled version of Nasm.
I could say that NASM itself is a crippled assembler.

Thank you,
Manos.

Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 429
  • Country: us
Re: Nasm source does not work
« Reply #9 on: August 28, 2014, 03:43:49 PM »
If I assemble the same source code but using pre-built Nasm executables that I downloaded, no problem.

So... what's the crippled part?  Nasm assembles your source fine but doesn't assemble after you rebuild it with changes you've made.
Without further information the source of the problem would appear to exist between the chair and the keyboard.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Nasm source does not work
« Reply #10 on: August 28, 2014, 03:54:35 PM »
Quote
You tell me not to distribute my result because it would be a  crippled version of Nasm.

Correction: I ask you not to do so - I do not delude myself that I have the power to tell you what to do.

Quote
I could say that NASM itself is a crippled assembler.

You could indeed say so. Help yourself!

Best,
Frank


Offline Manos

  • Jr. Member
  • *
  • Posts: 24
  • Country: gr
Re: Nasm source does not work
« Reply #11 on: August 28, 2014, 07:36:35 PM »
So... what's the crippled part?  Nasm assembles your source fine but doesn't assemble after you rebuild it with changes you've made.

Not with my changes, but after I ascertained that the original source does not works properly,
I tried to do my changes.
But in all cases the result was the same.

I don't wish to build my own NASM fork.
I am implementing my own C compiler for Win32 and I thinked
to use NASM as a back end, since it is open source.
I thinked to include a portion of nasm source in my C compiler,
instead of using nasm separately, to increase the compilation speed
and to reduce the size by excluding the unnecessary source code,
writting of cource the credits and including the nasm license.
But before I do this work, I thinked to test NASM as a separate project.
The first time I tried to build the NASM from command line
using your makefile for VC++2005 exress, but I failed.
MS C compiler sent me error messages.
Then I tried to build NASM by opening the makefile with VC++2005,
but VC++2005 could not converted the makefile.
Then I tried to build NASM as follow:
I created with VC++2005 an empty console project and I included
all source files that are written in your makefile.
I managed to build NASM.exe, but this .exe in some cases works
and in other cases no.
Of cource, when build NASM, I take 549 warnings,
like: warning C4244: '=' : conversion from 'int64_t' to 'uint8_t', possible loss of data

This is the history.
I can not think what is happening:
Is it an error by me or nasm open source is incomplete ?

Manos.
« Last Edit: August 28, 2014, 07:44:19 PM by Manos »

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Nasm source does not work
« Reply #12 on: August 29, 2014, 03:54:57 AM »
Okay, I thought we might need some more information about exactly what you did. As I think I mentioned, I know "--" about VC++2005. As a start, I did:
Code: [Select]
grep -r "VC++" *
in the Nasm source directory. There are several references in "ChangeLog", "INSTALL", "Mkfiles/msvc.mak" (particularly the reference to inttypes/inttypes.h - those warnings?), and "contrib/vsrules". Are any of these relevant to ya?

Then we want to know exactly what happened. You sent me this file:
Code: [Select]
[global _main]
[section .text]
_main:
push edi
push ebp
mov ebp,esp
sub esp,byte 4
lea edi,[(L2)]
push dword edi
call _puts
add esp,4
push dword 3
push dword 2
call _GetSum
add esp,8
mov dword [ebp + (-4)],eax
mov eax,0
L1:
mov esp,ebp
pop ebp
pop edi
ret
[global _GetSum]
_GetSum:
push esi
push edi
push ebp
mov ebp,esp
%define P_x 16
%define P_y 20
mov edi,dword [ebp + (P_x)]
mov esi,dword [ebp + (P_y)]
lea eax,[esi + edi]
L3:
mov esp,ebp
pop ebp
pop edi
pop esi
ret
[extern _puts]
[section .data]
times ($-$$) & 0 db 0
L2:
db 'hello world', 10, 0
Which lines are giving you the complaints?

... anything else you can think of... (What happened when you tried to use the makefile? - it claims to have been tested on VC++2005express specifically...)

Best,
Frank



Offline Manos

  • Jr. Member
  • *
  • Posts: 24
  • Country: gr
Re: Nasm source does not work
« Reply #13 on: August 29, 2014, 09:15:45 AM »
If I try from command line to build the source without modifications
I take:
 
C:\Visual Studio 2005\nasm-2.07>nmake /f Mkfiles/msvc.mak
Microsoft (R) Program Maintenance Utility   Version 6.00.9782.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
 cl /c /O2 /Ox /Oy /W2 /I./inttypes /I. /I. /DHAVE__SNPRINTF /DHAVE__VSNP
RINTF /Fonasm.obj nasm.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

nasm.c
./inttypes\inttypes.h(38) : error C2059: syntax error : 'bad suffix on number'
./inttypes\inttypes.h(38) : warning C4067: unexpected tokens following preprocessor directive - expected a newline
./inttypes\inttypes.h(50) : fatal error C1189: #error :  "Neither long nor long
long is 64 bits in size"
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.


If I do changes in inttypes.h and outform.h I take:

C:\Visual Studio 2005\nasm-2.07>nmake /f Mkfiles/msvc.mak

Microsoft (R) Program Maintenance Utility   Version 6.00.9782.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

        cl /c /O2 /Ox /Oy /W2 /I./inttypes /I. /I. /DHAVE__SNPRINTF /DHAVE__VSNP
RINTF /Fonasm.obj nasm.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

nasm.c
./inttypes\inttypes.h(40) : error C2059: syntax error : 'bad suffix on number'
./inttypes\inttypes.h(40) : warning C4067: unexpected tokens following preproces
sor directive - expected a newline
./inttypes\inttypes.h(40) : warning C4067: unexpected tokens following preproces
sor directive - expected a newline
./inttypes\inttypes.h(43) : error C2632: 'long' followed by 'long' is illegal
./inttypes\inttypes.h(44) : error C2632: 'long' followed by 'long' is illegal
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.

Note:
Because I have installed both VStudio 6.0 and VC++ 2005,
NMAKE uses VStudio 6.0.

If I build nasm source with VC++2005, as I said in my previous post,
I managed to build NASM.exe, but when I try to assemble the Demo.asm
I take:
Demo.asm:29: error: label or instruction expected at start of line
Demo.asm:30: error: label or instruction expected at start of line


I have done the following changes:
In outform.h

#define OF_ONLY
#define OF_DOS

#ifdef OF_DOS
#ifndef OF_OBJ
#define OF_OBJ
#endif
#ifndef OF_BIN
// #define OF_BIN
#endif
#ifndef OF_COFF
// #define OF_COFF         /* COFF is used by DJGPP */
#endif
#ifndef OF_WIN32
#define OF_WIN32
#endif
#ifndef OF_WIN64
// #define OF_WIN64
#endif
#endif

#ifndef OF_DEFAULT
#define OF_DEFAULT of_win32
#endif


In file inttypes.h I have done:
#define LLONG_MAX 9223372036854775807LL

But, you could inform me which Tools you use for build your nasm.exe
for win32 and to send me the applicable makefile.

Manos.

« Last Edit: August 29, 2014, 09:18:15 AM by Manos »

Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 429
  • Country: us
Re: Nasm source does not work
« Reply #14 on: August 29, 2014, 04:23:40 PM »
So... what's the crippled part?  Nasm assembles your source fine but doesn't assemble after you rebuild it with changes you've made.

Not with my changes, but after I ascertained that the original source does not works properly,
I tried to do my changes.
But in all cases the result was the same.

I think what you're really trying to state is that Nasm doesn't work the way YOU want it to.

I don't wish to build my own NASM fork.
I am implementing my own C compiler for Win32 and I thinked
to use NASM as a back end, since it is open source.

I thinked to include a portion of nasm source in my C compiler,
instead of using nasm separately, to increase the compilation speed
and to reduce the size by excluding the unnecessary source code.

Using Nasm as an external assembler is not an issue if your C compiler emits proper Nasm assembly source code.
However, it would appear you are attempting to modify Nasm in order to use it like a back-end .DLL and that's not easy.
Perhaps a look at this site will give you some ideas: http://yasm.tortall.net/