How many people would actually be interested in a set of tutorials based on NASM32 involving the Standard C Library (LibC), the Win32 API, and X11 Window Programming???

The idea is to create an entire set of tutorials for Windows and *nix/X11, showing the respective process of creating CLI/GUI applications in assembly language.

Let me know what you think :)
Posted on 2006-05-22 20:40:28 by SpooK
Truth is, I've been wanting to do this for a long time now. Unfortunately other things keep getting in the way, we've talked about that... The next update (which I have a few more things I want to add) will support local variables using a LOCALS/ENDLOCALS block (despite my best efforts) I can't find any other way to support local types than putting them in a block themselves. Also, which is what I'm having trouble implementing, it hopefully will support a TCHAR macro which will generate UNICODE or ASCIIZ depending on if the _UNICODE_ directive is turned on. The latter might not ever see the light of day though since my attempts have so far been all but total failure. If you do decide to write the tutorial, get with me on MSN and I'll send you a copy of the new NASM32.INC file I'm currently working on.

Regards,
Bryant Keller
Posted on 2006-05-23 00:57:09 by Synfire
If you're going to do a LOCALS/ENDLOCALS block (which IMHO would be a bit cleaner than the way locals are specified in masm), it would be nice if you could make it support aligned locals (useful for SSE datatypes), while still allowing argument access as well. And perhaps locals+args support for naked functions through ESP and with push/pop counting... would be a challenge, but pretty nice :)
Posted on 2006-05-23 05:38:36 by f0dder
Right now I can access local variables like I do with arguments. just a different macro. Here's a quick example:


%include "\nasm32\inc\windows.inc"
%include "\nasm32\inc\user32.inc"
%include "\nasm32\inc\kernel32.inc"
%include "nasm32.inc"

entry NTest

_DATA
; TCHAR - If _UNICODE_ is defined, String is encoded in UNICODE format, if not it's ASCIIZ
TCHAR uString, "Unicode Support Enabled"
TCHAR uTitle, "Nasm32 Test"

_CODE
PROC NTest
    INVOKE MyProcedure, uString, uTitle
    INVOKE ExitProcess, EAX
ENDPROC

PROC MyProcedure, lpString, lpTitle
LOCALS
    LOCAL handle, DWORD
    LOCAL settings, DWORD
ENDLOCALS
    mov VAR(settings), dword MB_OKCANCEL
    mov VAR(handle), dword NULL
    INVOKE MessageBoxA, VAR(handle), ARGV(lpString), ARGV(lpTitle), VAR(settings)
    IF EAX, !=, 0
        xor eax, eax
    ENDIF
    leave
    ret
ENDPROC


For now, the TCHAR macro is only good for ASCIIZ, that's what I'm working on now. Once I get Unicode support going, you won't have to use MessageBoxA/W you will just have to use MessageBox :)

I'll see if I can't get aligned locals support, for now it only supports DWORD, WORD, BYTE size variables, I'll fix that too. I was thinking of possibly doing a rewrite of the entire PROC, ENDPROC, LOCALS, ENDLOCALS macros to have them generate the stack frame using a huge STRUC/ENDSTRUC block, but so far this doesn't seem very realistic due to the order that the preprocessor generates it's code (STRUC/ENDSTRUC is preformed before %macro/%endmacro). As always, I'll accept any suggestions and if I can get time, and if it's possible, I'll do my best to add support.

Regards,
Bryant Keller
Posted on 2006-05-23 14:45:52 by Synfire
Sounds good. What do you think about un-defining "leave" at endproc as well as ret; do you think it would make troubleshooting more easy or more difficult?

As for IM, I am not sure I am off of work in time to talk to you, time to invoke e-mail/PM chat :)
Posted on 2006-05-23 15:46:30 by SpooK
I just naturally use leave and ret, but ret is a macro which auto inserts leave if it's not present, so that code didn't require a leave instruction... I could probably setup the same thing for ENDPROC to check if ret has been called, but then that wouldn't be any good for routines like


PROC myProc, myarg
  mov eax, ARGV(myarg)
  IF eax, NOT_EQUAL, 0
      ret
  ENDIF
ENDPROC


In this case the ENDPROC would notice the previous ret declariation and wouldn't insert a ret. See the problem? I've thought about this several times and if I can arse I'll see what I can't pull together.
Posted on 2006-05-23 18:42:35 by Synfire
I only offer to make the tutorials because it is only a bit more work than what I am doing now anyway. It would be just a simple documentation of what I am learning myself (never programmed X11 before).

I wouldn't mind if it is a collaboration. I'll start with your basic examples, maybe read a bit of Icz, and see what I can work up on my behalf :)
Posted on 2006-05-23 18:56:47 by SpooK
Started work on include files for X11. I will release example code when it is ready. I will the completed material to Synfire for official inclusion into his project, if he so chooses :)
Posted on 2006-05-25 20:32:07 by SpooK
Sure thing mate, if you can't get me on MSN email it to me (any email address). I've been offline a bit lately as I've been in and out of the hospital again. I should be around more in a few days.
Posted on 2006-05-25 20:49:38 by Synfire