I used the word "format" in my previous post, what I meant to say was
encoding. Perhaps the file was encoded differently than what nasm.exe expects to read (Pure Ascii vs Unicode vs a mix of pure text, html and what not)
The encoding might be bad. I opened the include file in notepad++ to see what encoding it detects, and it is pure ansi. I tried opening the file in a hex editor to see if the file contains "unwanted" characters, couldn't find anything. The include file has clean "pure text encoding".
If I create a new include file from scratch, the same problem persist with clean text files too. My next suspicion may be that the assembler does something differently based whether you use SEGMENT or SECTION in your source code which perhaps has consequences on how it interpretes include files. I'm not sure about that, can't tell.
The code I used to include the file looks exactly like this:
%include 'z:\nasm\include\test.inc'
%include 'z:\nasm\include\macros.asm'
global start
extern ExitProcess
extern Int2Msg
secton .data use32
_caption db 'Temporary program',0
section .text use32
start:
stdcall Int2Msg, 100, _caption
invoke ExitProcess, 0
Ignore the Int2Msg, it's just to print numbers in message boxes, I use it to see what is in registers from time to time. That is not what causes any errors, if I remove it, the problem with the include file persists.
The parameters I use on the command line is:
This is what is inside the batch file I use to compile
@echo off
nasm -f win32 -Ox Temp.asm
golink /entry start Temp.obj z:\nasm\include\coff\Int2Msg.obj kernel32.dll user32.dll
I normally use make files, but I have a test folder where I have a template for "messing around with any code", so I use a batch file to compile that one. The batch file is clean, everything assembles and links well, the final executable is of "proportional size". But the coff file is widely out of proportions.
The macros.asm file is not what causes the problem either, it's just a few custom macros I made, I can put it in here:
; Direct call through embedded symbols
%macro stdcall 1-*
%if %0 > 1
%rep %0-1
%rotate -1
push %1
%endrep
%rotate -1
%endif
call %1
%endmacro
; Indirect call through imports (Use greedy macro parameters, last parameters gets lumped into one)
%macro invoke 1-2+
stdcall [%1],%2
%endmacro
; Indirect comcall [objptr, method, args]
%macro cominv 2-*
%if %0 > 2
%rep %0-2 ; arg0 is always amount of arguments passed to macro (skip object and method [-2])
%rotate -1 ; rotate last argument into %1
push %1 ; push in reverse order
%endrep
%rotate -2 ; get the order back to normal again so that original arg1 is arg1
%endif
mov eax,[%1]
push eax
mov eax,[eax]
call dword [eax+%2]
%endmacro
; Push many registers in straight order
%macro pushm 1-*
%rep %0
push %1
%rotate 1
%endrep
%endmacro
; Pop many registers in straight order
%macro popm 1-*
%rep %0
pop %1
%rotate 1
%endrep
%endmacro
The test.inc can be downloaded
here and I'm using nasm version 2.11.05 (compiled on May 21, 2014)
nasm.exe hashes:
MD5:
6407f2f8527b6a7676498198a0dd9114
SHA-1:
5b4fa8ded7ae7b82234b70ac4396c8777fbd5189