1) Is there a way to define multiline comments in NASM? GOD let there be a way. I tried COMMENT as in TASM and MASM but it did not work.
2) I have written the below INVOKE macro:
The last line of the code (CALL), calls the first argument. What I need to do is for the INVOKE to try to realize whether a location that it is calling is actually a defined procedure/label. So INVOKE 0xBADBADBA for example should not work. Does anybody have any idea how I can do this?
Thanks in advance.
2) I have written the below INVOKE macro:
%MACRO INVOKE 1-*
%REP %0 - 1
%ROTATE -1
PUSH DWORD %1
%ENDREP
%ROTATE -1
CALL %1
%ENDMACRO
The last line of the code (CALL), calls the first argument. What I need to do is for the INVOKE to try to realize whether a location that it is calling is actually a defined procedure/label. So INVOKE 0xBADBADBA for example should not work. Does anybody have any idea how I can do this?
Thanks in advance.
1) Is there a way to define multiline comments in NASM? GOD let there be a way. I tried COMMENT as in TASM and MASM but it did not work.
AFAIK, NASM doesn't do anything "multi-line" with the exception of MACROS... which are a bunch of single-line statements anyhow. NASM is an assembler, not a compiler ;)
2) I have written the below INVOKE macro:
%MACRO INVOKE 1-*
%REP %0 - 1
%ROTATE -1
PUSH DWORD %1
%ENDREP
%ROTATE -1
CALL %1
%ENDMACRO
The last line of the code (CALL), calls the first argument. What I need to do is for the INVOKE to try to realize whether a location that it is calling is actually a defined procedure/label. So INVOKE 0xBADBADBA for example should not work. Does anybody have any idea how I can do this?
Thanks in advance.
Take a look at NASM32.INC from The NASM32 Project, it should give you some idea of what to do ;)
SpooK, do you remember conditional assembling?
I use my own macros where invoke/cdecl always uses external, and call (macro) uses local labels.
%if 0
bla bla bla
%endif
and as well, you can use c-style /* */ if you are able to modify tokenize() funkction in nasm sources.I use my own macros where invoke/cdecl always uses external, and call (macro) uses local labels.
SpooK, do you remember conditional assembling?
%if 0
bla bla bla
%endif
and as well, you can use c-style /* */ if you are able to modify tokenize() funkction in nasm sources.I use my own macros where invoke/cdecl always uses external, and call (macro) uses local labels.
I would opt for the second one, the first one would not look too pretty.
Thank you guys. Appreciate it. Though not supporting multiline comments is really bad in my opinion by I can live with single line comments too.
Well, you should be able to use the "if 0" trick with standard nasm, so in a way it does support multi-line comments. sapero's solution of modifying the source to do /**/ is better imho, and shouldn't be too hard.
Thank you guys. Appreciate it. Though not supporting multiline comments is really bad in my opinion by I can live with single line comments too.
Image the case of *standard* asm file processing with color syntax. The semicolon allows for obvious unique coloring. I'm sure some ASM IDEs take note of the unique case of MASM/TASM's "COMMENT".
If you want a compromise, I would suggest indenting any "sub" comments, like so...
;<COMMENT>
;This is a really long comment
; that expands multiple lines
;</COMMENT>
It does get annoying. There are times I wish there was multi-line processing in NASM. Perhaps... some day :)
Here is the format that I have chosen for my kernel's documents. It doesn't look good with single-line comments. It could be really better if we had multi-line comments. I want multi line comments. I want the comments. I want them multi line. I really do. Somebody give me multi line comments. What? Oh sorry.
Here is the format that I have chosen for my kernel's documents. It doesn't look good with single-line comments. It could be really better if we had multi-line comments. I want multi line comments. I want the comments. I want them multi line. I really do. Somebody give me multi line comments. What? Oh sorry.
Well, I am actually in communication with those in charge of NASM development and I will add that to my "list" and we will see what arises :)
That'd be great, thank you so much. In the meantime, I guess I should write a program that eliminates multi-line comments from my source codes and then passes the result to NASM. This way I will have my multi-line comments and NASM will not notice it.
That'd be great, thank you so much. In the meantime, I guess I should write a program that eliminates multi-line comments from my source codes and then passes the result to NASM. This way I will have my multi-line comments and NASM will not notice it.
Just modify the nasm sources and add multi-line comments.
That'd be great, thank you so much. In the meantime, I guess I should write a program that eliminates multi-line comments from my source codes and then passes the result to NASM. This way I will have my multi-line comments and NASM will not notice it.
Just modify the nasm sources and add multi-line comments.
It's easier to centralize development, but that is a good temporary solution :)
Alright, now this is weird. I was coding some stuff today and came around this weird NASM behavior. Look at the below code:
Normally, the Comment Line 1 should be a comment but after putting that little back slash at the end of the comment line, all other lines get commented until NASM finds a blank line or another single line comment. So PUSH EAX, EBX, ECX are also commented. What the hell is NASM doing here? Is backslash really supposed to work while commented?
; Comment Line 1 \
PUSH EAX
PUSH EBX
PUSH ECX
;
PUSH EDX
Normally, the Comment Line 1 should be a comment but after putting that little back slash at the end of the comment line, all other lines get commented until NASM finds a blank line or another single line comment. So PUSH EAX, EBX, ECX are also commented. What the hell is NASM doing here? Is backslash really supposed to work while commented?
Alright, now this is weird. I was coding some stuff today and came around this weird NASM behavior. Look at the below code:
; Comment Line 1 \
PUSH EAX
PUSH EBX
PUSH ECX
;
PUSH EDX
Normally, the Comment Line 1 should be a comment but after putting that little back slash at the end of the comment line, all other lines get commented until NASM finds a blank line or another single line comment. So PUSH EAX, EBX, ECX are also commented. What the hell is NASM doing here? Is backslash really supposed to work while commented?
I've been playing around with the assembler portion, not the parser nor evaluator, so I am not fully familiar with every operation... and you may have found one of your answers ;)
It is more weird than it is helpful I guess. Normally when you write documentations and multi-line comments, you have to put some blank lines in there to separate some lines from each other while using this "trick", if I should call it, the blank lines cause the whole comment block to be kind of terminated and you have to do another "trick". I wish somebody could confirm whether this is a bug in NASM or this behavior is by design.
Alright, now this is weird. I was coding some stuff today and came around this weird NASM behavior. Look at the below code:
; Comment Line 1 \
PUSH EAX
PUSH EBX
PUSH ECX
;
PUSH EDX
Normally, the Comment Line 1 should be a comment but after putting that little back slash at the end of the comment line, all other lines get commented until NASM finds a blank line or another single line comment. So PUSH EAX, EBX, ECX are also commented. What the hell is NASM doing here? Is backslash really supposed to work while commented?
Once again, Sorry for being so behind on threads lately. I've been away for a while. What version of NASM are you using? I have version 0.98bf and I can't seem to replicate what you are doing. I put the instructions in the code section, built, then opened it in a disassembler and the opcodes where there. So those PUSH instructions where not being commented out in the version I have. If you have a different version, post the version number here I would like to play around with this. It would definately be a bug.
Regards,
Bryant Keller
Posted on 2007-03-21 00:40:30 by XCHG
Yea, your version is newer than mine. I can only assume this is a recently added bug (or an attempt to add multi-line support through the '\' character). I've just came into possession of two barely used P3 computers today, for free, so I've spent most of the day cleaning out all the old owners garbage files/software. When I've finished that I'll update my copy of NASM and try again. Thanks.
No, thank you for your attempt to confirm this. I appreciate it.
XCHG,
I've played around and this isn't a bug. From what I can tell this is supposed to be a primative form for mutiline support by use of the '\' token. Take the following code for example:
I heard the development team was working on various multiline issues thanks to the popularity boost of the NASM32 project after Keith took over, which is why I'm not too suprised about this. A lot of users were complaining about how INVOKE couldn't be span'd over multiple lines and I remember Frank mentioning he would work on it, this must be a side effect of that. As you can see in the above code, the multiline character now breaks up the INVOKE without errors on the new version of NASM (I'm very happy about that, it'll clean up a lot of those API calls). But I must admit I was wrong, this is most definately a feature addition.
Regards,
Bryant Keller
I've played around and this isn't a bug. From what I can tell this is supposed to be a primative form for mutiline support by use of the '\' token. Take the following code for example:
%include '\nasm32\inc\win32\windows.inc'
%include '\nasm32\inc\win32\kernel32.inc'
%include '\nasm32\inc\win32\user32.inc'
%include '\nasm32\inc\nasm32.inc'
; \
Multiline comment support \
is now enabled in The Netwide \
Assembler. \
\
PS: This code is from the NASM32 \
Project \
;
entry demo1
proc demo1
invoke my_p, dword szContentTwo, dword szTitleTwo
invoke MessageBoxA, dword NULL, dword szContent, \
dword szTitle, dword MB_OK
invoke ExitProcess, dword NULL
ret
endproc
proc my_p
sz_Content argd
sz_Title argd
invoke MessageBoxA, dword NULL, dword argv(sz_Content), dword argv(sz_Title), dword MB_OK
ret
endproc
_data
szTitle: db 'Demo1', 0x0
szTitleTwo: db 'Demo1 Procedure', 0x0
szContent: db 'Hello from the Application!', 0x0
szContentTwo: db 'Hello from the Procedure!', 0x0
I heard the development team was working on various multiline issues thanks to the popularity boost of the NASM32 project after Keith took over, which is why I'm not too suprised about this. A lot of users were complaining about how INVOKE couldn't be span'd over multiple lines and I remember Frank mentioning he would work on it, this must be a side effect of that. As you can see in the above code, the multiline character now breaks up the INVOKE without errors on the new version of NASM (I'm very happy about that, it'll clean up a lot of those API calls). But I must admit I was wrong, this is most definately a feature addition.
Regards,
Bryant Keller