Page 1 of 2

Purebasic Inline Assembly, Hello world example.

Posted: Sat Aug 30, 2003 7:37 am
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 

Posted: Sat Aug 30, 2003 6:22 pm
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...

Opening a window in purebasic inline assembly.

Posted: Sat Aug 30, 2003 8:44 pm
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.

Posted: Sat Aug 30, 2003 9:24 pm
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..'

Posted: Sun Aug 31, 2003 12:10 am
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

Posted: Sun Aug 31, 2003 12:51 pm
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..

I agree

Posted: Sun Aug 31, 2003 2:58 pm
by Hi-Toro
You're coming over very rudely, LJ, considering you're asking for help.

@Fred

Posted: Sun Aug 31, 2003 5:18 pm
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.

Posted: Sun Aug 31, 2003 5:43 pm
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

Posted: Sun Aug 31, 2003 6:33 pm
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!

Posted: Sun Aug 31, 2003 6:54 pm
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

Posted: Sun Aug 31, 2003 7:07 pm
by Karbon
Damn Timo, nice!!

Thanks!

Posted: Sun Aug 31, 2003 7:41 pm
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 :)

Posted: Sun Aug 31, 2003 11:26 pm
by newbie
awesome freak, thanks !
8O

Posted: Mon Sep 01, 2003 2:34 am
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.