NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: shaynox on February 16, 2015, 01:47:09 PM

Title: [SOLVED] Label & Preprocessor
Post by: shaynox on February 16, 2015, 01:47:09 PM
Hello, I have a problem, I would like to put a label and directive in same line, but nasm give me an error:

Code: [Select]
rhino_3D: %include "1.ASM\HackEngine\WinAPI\data\world\Rhino.3D"

give me:
Quote
error: parser: instruction expected
Title: Re: Label & Preprocessor
Post by: Frank Kotler on February 16, 2015, 03:23:04 PM
Hi shaynox.

Apparently Nasm doesn't care what you'd like, but expects an instruction or nothing after a label. Putting the "%include" directive on the line after the label should solve this problem, but unless "Rhino.3D" is in Nasm syntax it isn't going to work anyway. You might possibly have better results with "incbin", but I doubt that'll work either. What kind of file is "Rhino.3D"?

Best,
Frank

Title: Re: Label & Preprocessor
Post by: shaynox on February 16, 2015, 04:15:40 PM
^^ apparently yes, the .3D file is just my own file format of 3D object.

And about incbin, it work when I putting it next to my label, but it doesn't work functional side, nothing happen.
I mean when I try to show the rhino, I didn't see anything compare when I wrote %include.
And i verified around the size of executable and found a lesser weight than %include.
Title: Re: Label & Preprocessor
Post by: shaynox on March 14, 2015, 03:47:28 AM
Good new, I have found how to do this.

It just needed to use this macro, and call it before the include.

Macro:
Code: [Select]
;===============================================================================.
; _  (multi line)                                                              |
; Purpose : Give the possibility to write multiple instructions in single line.|
;===============================================================================.
; %0 = number of parameters received
; %1 = 1st parameter received
%macro _ 1-*

%rep (%0) ; Reapet %0 times
%1
%rotate  1 ; Rotate element right to left for scanning all element parsing in macro.
%endrep

%endmacro
;===============================================================================.
; / _ (multi line)                                                            |
;===============================================================================.

Example:
Code: [Select]
rhino_3D:        _%include "1.ASM\HackEngine\Resource\obj3D\Rhino.3D"


Enjoy !