Purebasic Inline Assembly, Hello world example.

Just starting out? Need help? Post your questions and find answers here.
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

Purebasic Inline Assembly, Hello world example.

Post by LJ »

Using Purebasic Inline Assembly, I'm having trouble creating a hello world program. I'd like to create another tutorial in the Purebasic Inline Assembly tutorial that deals with opening a Window titled Hello World in Purebasic Inline assembly code. The only thing that anyone has been able to create in inline assembly is a message box that pops up.

Does anyone know how to create a simple window in Purebasic Inline assembly using pure assembly?

The only thing that anyone has been able to accomplish is Chris_B and the code below. Does anyone know how to modify this code to make it open a Window instead of a message box?:

Code: Select all

; Remember to enable Inline ASM support 
caption.s="Win32 Assembly" 
message.s="Hi! I'm the example program!" 
!extrn "__imp__MessageBoxA@16" as MessageBox:dword 
PUSH 0 
PUSH caption 
PUSH message 
PUSH 0 
CALL [MessageBox] 
end 
BalrogSoft
Enthusiast
Enthusiast
Posts: 203
Joined: Sat Apr 26, 2003 6:33 pm
Location: Spain
Contact:

Post by BalrogSoft »

hi...

take a look to fasm: http://flatassembler.net/ and download the windows version, it have an example called template that open an empty window...
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

Opening a window in purebasic inline assembly.

Post by LJ »

@Balrog,

Who hasn't read this? Everybody has this and can do it in FASM. My message specifically said in Purebasic Inline Assembly.

As it stands, it appears that not enough functionality exists in Purebasic Inline Assembly to allow for the creation of a Window.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

All the FASM commands are available trough the '!' operand so I don't know what you mean with 'As it stands, it appears that not enough functionality exists in Purebasic Inline Assembly to allow for the creation of a Window..'
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

Post by LJ »

@Fred,

What I mean is exactly what I said it does not appear possible to create a simple Window in Purebasic Inline Assembly. Simply using the '!' does not fix the problem. I don't feel like typing a long message explaining why Purebasic Inline Assembly doesn't allow certain !extrn command calls because the symbol is already defined, or that segmenting assembly code into a text section, data section, etc... gives all sorts of errors even with the '!' command and so using the FASM docs does not help, did I mention that the FASM uses macros which totally skews the code from being directly imported into Purebasic Inline Assembly? But you already know this.

I even gave code showing that a message requestor can be created in Purebasic Inline Assembly, and asking if anyone knows how to do the same with a Window.

As it stands, no one has been able to create a hello world program in purebasic inline assembly or to just create a window on the screen in purebasic inline assembly, hence it appears that this fuctionality does not exist. If I'm wrong, do post some code showing how to open a window in purebasic inline assembly.

Thanks,
Lj
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

I don't like the way you asking things. I don't do it because it's really useless and waste of time. Learn API programming in ASM before going any further..
Hi-Toro
Enthusiast
Enthusiast
Posts: 269
Joined: Sat Apr 26, 2003 3:23 pm

I agree

Post by Hi-Toro »

You're coming over very rudely, LJ, considering you're asking for help.
James Boyd
http://www.hi-toro.com/
Death to the Pixies!
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

@Fred

Post by LJ »

@Fred,

I can't do this anymore with you Fred, I don't like your personality too much. You come off as being nice at first, but then it changes over time.

I'm pulling my support from your Purebasic community. Please delete the sticky message thread in Tips and Tricks with my work on Purebasic Inline Assembly. I will not be contributing to this community any longer.
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Post by sec »

Calm down mans,

i don't deal much with api but you can must use some struc,...better to google for "Iczelion" example , after port it to PureBasic

HTH
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

LJ, man you really need to calm yourself down. You're always jumping bad on people.

Rudeness is the #1 way to *not* get help - you have to know that.. If you don't that then you really need to develop some people skills.
I don't feel like typing a long message explaining why Purebasic Inline Assembly doesn't allow certain !extrn command calls because the symbol is already defined, or that segmenting assembly code into a text section, data section, etc...
Ok, so you ask for help but "don't feel like" explaining the problems? You can't possibly expect people to offer their time an expertise when you talk to them like that. You saying Fred isn't nice is the pot calling the kettle black.

If you're not interested in the PureBasic community anymore then you're snide comments aren't going to be missed - your good contributions will be (the ASM tutorial and anything else useful you've posted).

Adios!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

> I'd like to create another tutorial in the Purebasic Inline Assembly
> tutorial that deals with opening a Window titled Hello World in Purebasic
> Inline assembly code.

> Does anyone know how to create a simple window in Purebasic Inline
> assembly using pure assembly?

So, you are basically telling us, that you want to write a tutorial, about
something you don't know how to do it, and you want us to explain it to
you?
Well, why don't we just write that tutorial ourselves then?

I don't get the point anyway, why do you want to create a window with
InlineASM? Why make things complicated, when there is such an easy
to use Window management in PB ?
The point of InlineASM in PB was never to do GUI programming with it,
but more to do some tricks & optimisations in the code.

Anyway, I was thinking about helping... Although I didn't know the answer
myself, I would have searched for it, but after reading your replies to
BalrogSoft and Fred, I don't really think it is worth it anymore.

> As it stands, it appears that not enough functionality exists in Purebasic > Inline Assembly to allow for the creation of a Window.

But hey, just to make the point... here you go:

Code: Select all

!extrn _CreateWindowExA@48 
!extrn _DefWindowProcA@16 
!extrn _RegisterClassA@4 


; comment these 3 out if you use the debugger!!
!extrn _GetMessageA@16
!extrn _TranslateMessage@4
!extrn _DispatchMessageA@4

Procedure.l Callback(Window.l, Message.l, wParam.l, lParam.l)
  MOV ebx, [esp+4]
  CMP ebx, #WM_CLOSE
  JE l_ProgramEnd
  CALL _DefWindowProcA@16
  SUB esp, 16
  ProcedureReturn
EndProcedure

#styles = #WS_CAPTION|#WS_SYSMENU|#WS_VISIBLE
class.WNDCLASS
message.MSG

MOV dword [v_class+4], _Procedure0
MOV dword [v_class+16], PB_Instance
MOV dword [v_class+28], #COLOR_BTNFACE
ADD dword [v_class+28], 1
MOV dword [v_class+36], l_classname

PUSH v_class
CALL _RegisterClassA@4

PUSH dword 0
PUSH PB_Instance
PUSH dword 0
PUSH dword 0
PUSH dword 200
PUSH dword 400
PUSH dword 100
PUSH dword 100
PUSH #styles
PUSH l_title
PUSH l_classname
PUSH dword 0
CALL _CreateWindowExA@48

StartLoop:
PUSH dword 0
PUSH dword 0
PUSH dword 0
PUSH v_message
CALL  _GetMessageA@16

PUSH v_message
CALL _TranslateMessage@4

PUSH v_message
CALL _DispatchMessageA@4

JMP l_StartLoop


ProgramEnd:
End


DataSection
classname: Data.s "PureBasic TestClass"
title:     Data.s "Hello World"
EndDataSection
So tell me, what is it that PB is missing that makes it inpossible to do?


> I'm pulling my support from your Purebasic community.

Well, if what I read here in this post (and some others as well) is what
you call "my support from your Purebasic community", then !please!
pull that away.

Good bye then...

Timo
quidquid Latine dictum sit altum videtur
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Damn Timo, nice!!

Thanks!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

@LJ,

Considering that lately you have been making a habit of jumping from topic to topic on this forum and insulting members of the PureBasic community, I have only one thing to say to you...

Bu-Bye :)
Image Image
newbie
Enthusiast
Enthusiast
Posts: 296
Joined: Tue Jul 29, 2003 5:47 pm
Location: FRANCE
Contact:

Post by newbie »

awesome freak, thanks !
8O
- Registered PB user -

Using PB 4.00
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Post by TronDoc »

I get a 6176 byte .exe from compiling the
source with inline asm turned on and the
debugger turned off.

It seems to compile fine, but when
executed it just disappears into
digital oblivion. I have to do
ctrl-alt-del to see it in the
"close program" window
and then I can "end task"
O.K.

Does anyone else have it working
on windows 98 first edition?
I'm just wondering in case I'm
doing something wrong.
The cutNpaste of the code
seems to match the posting..

Thanks.
Joe
edit:
um....I got it to compile and run in"console" mode
....is that what I was doing wrong? :oops:
edit2:no, that just shows an empty
console...no "hello world". and have to close it as a
DOS box with Ctrl-C.
Locked