Author Topic: How to work with NASMX  (Read 18575 times)

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
How to work with NASMX
« on: February 05, 2012, 03:07:10 AM »
I don't have any answers to this, I just thought I'd try to get a discussion going. Alfonso mentioned the other day in the "Forum and Website" section that he'd appreciate a "successful example". Perhaps the include examples were not "successful"?

The first step would be to download the NASMX package. The "home page" for NASMX is:

http://www.asmcommunity.net/projects/nasmx

... but that will direct you to SourceFrog for the current version:

http://sourceforge.net/projects/nasmx/

If you just hit the "download" button, SF will autodetect your OS and give you the "right" version (I think).  Clicking on "browse all files" will give more options.

My funky old browser is about to crash... or OOMKILLER will kill it. Gotta restart it. I'll get back to this - remind me if I don't...

Best,
Frank


Offline avcaballero

  • Full Member
  • **
  • Posts: 133
  • Country: es
    • Abre los Ojos al Ensamblador
Re: How to work with NASMX
« Reply #1 on: February 07, 2012, 04:55:18 PM »
Hello, Frank, sorry for answer late... What I meant is that I'd like a NasmX example that paints a bmp/ico in anywhere, main frm, button...

Examples include in NasmX package compile and works well.

Thank you
« Last Edit: February 07, 2012, 04:58:34 PM by avcaballero »

Offline Bryant Keller

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 360
  • Country: us
    • About Bryant Keller
Re: How to work with NASMX
« Reply #2 on: February 08, 2012, 11:21:29 PM »
NASMX itself has nothing to do with drawing bitmaps and such, what you are wanting is an Xlib tutorial. Xlib is a C library for communicating with the X11 server used on GNU/Linux and BSD operating systems. There is an example (DEMO6) in the NASMX Linux examples that shows how to use Xlib to draw a button on the display surface. As for Bitmaps specifically, Xlib covers that as well. XReadBitmapFile() can, well.. read a bitmap file. XCreatePixmapFromBitmapData() creates a nice pixmap (the default image type of Xlib) from the bitmap data read from a bitmap file. A good tutorial to learn this stuff from is at http://www.kerguelen.org/x. This tutorial is written in C, but given the information available in linux/demo6 and x11/demo1 as part of NASMX, you should be able to get the hang of it fairly easily.

About Bryant Keller
bkeller@about.me

Offline Mathi

  • Jr. Member
  • *
  • Posts: 82
  • Country: in
    • Win32NASM
Re: How to work with NASMX
« Reply #3 on: February 09, 2012, 08:12:13 PM »
If you were looking for MS windows example,
Here is a sample program which shows a bmp image on a button.
This program uses nagoa macros.

PFA the zip file.
« Last Edit: February 09, 2012, 08:14:05 PM by Mathi »

Offline avcaballero

  • Full Member
  • **
  • Posts: 133
  • Country: es
    • Abre los Ojos al Ensamblador
Re: How to work with NASMX
« Reply #4 on: February 10, 2012, 07:55:01 AM »
Sure, Nagoa, but what about NasmX?... I have proved several times, but cannot get a successful example. I have done some windows examples on assembly on masm32, NasmX and fasm, but cannot achieve paint bmp/ico using NasmX.

http://www.abreojosensamblador.net/Productos/AOE/html/Pags_en/Chap20.html

Regards.

Offline Mathi

  • Jr. Member
  • *
  • Posts: 82
  • Country: in
    • Win32NASM
Re: How to work with NASMX
« Reply #5 on: February 10, 2012, 06:27:48 PM »


I could see from the screenshot that the LoadIcon  api call has returned the error ERROR_RESOURCE_DATA_NOT_FOUND
Which means the resource file (.rc) file is not proper or not created.

with say,

100          ICON           "small.ico"
101          ICON           "truck.ico"

If we use GoRC to compile the resource file and then link the obj file , it should work fine.
Plz update on what was done in the resource file. The page doesn't have details on that.

Thanks,
Mathi.

Offline avcaballero

  • Full Member
  • **
  • Posts: 133
  • Country: es
    • Abre los Ojos al Ensamblador
Re: How to work with NASMX
« Reply #6 on: February 14, 2012, 09:44:05 AM »
Hi, Mathi, sorry for answer late, I attach a file with all sources.

Thank you

Offline Mathi

  • Jr. Member
  • *
  • Posts: 82
  • Country: in
    • Win32NASM
Re: How to work with NASMX
« Reply #7 on: February 14, 2012, 06:03:22 PM »
In VentWN1.asm,

proc    Entrada
...
....
    invoke   WinMain, dword wc + WNDCLASSEX.hInstance, dword NULL, dword CommandLine, dword SW_SHOWNORMAL

plz change it to..

invoke   WinMain, dword [wc + WNDCLASSEX.hInstance], dword NULL, dword CommandLine, dword SW_SHOWNORMAL

so that the value of application instance is passed not the address location which holds the application Instance value.

It works fine after that change.

Regards,
Mathi.

Offline avcaballero

  • Full Member
  • **
  • Posts: 133
  • Country: es
    • Abre los Ojos al Ensamblador
Re: How to work with NASMX
« Reply #8 on: February 14, 2012, 06:09:37 PM »
 :D

Ok, Thank you very much Mathi, now works fine!. I will update my page as soon as I can.

Regards

Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 429
  • Country: us
Re: How to work with NASMX
« Reply #9 on: February 16, 2012, 02:34:32 AM »

You may not be thinking of it now, but you may eventually want to port your applications to native 64-bit.
The NASMX macros ptrdiff_t and size_t will help you tremendously in your endeavors.
Everywhere in your code that deals with handles or pointers you'll want to use ptrdiff_t.
The macros simply expand to the appropriate size depending on target platform.

Using the same line of code that Mathi corrected above now becomes:

Code: [Select]
   invoke   WinMain, ptrdiff_t [wc + WNDCLASSEX.hInstance], ptrdiff_t NULL, ptrdiff_t CommandLine, dword SW_SHOWNORMAL

That one line will now assemble properly for either 32 or 64 bit Windows.  8)

Offline avcaballero

  • Full Member
  • **
  • Posts: 133
  • Country: es
    • Abre los Ojos al Ensamblador
Re: How to work with NASMX
« Reply #10 on: February 16, 2012, 08:28:22 AM »
Yes, I have not started with programming in 64 bits, but what you mention sounds great.

Thank you.