flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Windows > Return Value Of Function

Goto page 1, 2, 3  Next
Author
Thread Post new topic Reply to topic
Trentie89



Joined: 01 Feb 2017
Posts: 26
Location: Perth, Australia.
Return Value Of Function
Hi All,

Thanks so much for letting me sign up, ASM is the only language
I want to use when coding, as well as PHP. I Know everything about
PHP, but very little about ASM. Here is a simple question for you, I will
say execute the function FindWindow to find a window that is open, my code
is this. :


Code:



include 'win32ax.inc' ; you can simply switch between win32ax, win32wx, win64ax and win64wx here

.code

  start:
       FindWindow,NULL,"Example Window"
       invoke  MessageBox,HWND_DESKTOP,"Window Found!. " ,invoke GetCommandLine,MB_OK

.end start
              



I Want the messagebox to say "Window Found" only if it is found, can you
correct my code for me please.?. I Would be very very thankful indeed. Smile.

Trent.

_________________
I Am the greatest.!. ( NOT YET ).
Post 01 Feb 2017, 03:33
View user's profile Send private message Reply with quote
Walter



Joined: 26 Jan 2013
Posts: 115

Code:

;******************
;* FindWindow.asm *
;******************

include 'win32ax.inc'

.code 

  start
       invoke  FindWindow,NULL,"MyFile.txt - Notepad"

       .if eax <> 0
       invoke  MessageBox,HWND_DESKTOP,"Window Found!" ,"FindWindow",MB_OK
       .endif

.end start                                                    


Post 01 Feb 2017, 04:07
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14577
Location: 2014-JO25
You'll need to call ExitProcess also else your code will run off the end and probably crash.
Post 01 Feb 2017, 04:37
View user's profile Send private message Visit poster's website Reply with quote
Trentie89



Joined: 01 Feb 2017
Posts: 26
Location: Perth, Australia.
Thanks heaps guys, but now the compiler seems to have gone nuts, when I copy and paste your code, it says error : illegal instruction .code ( Whats happening ????? ) Thanks so much for your help.
Post 01 Feb 2017, 07:32
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14577
Location: 2014-JO25

Trentie89 wrote:
... but now the compiler seems to have gone nuts, when I copy and paste your code, it says error : illegal instruction .code ( Whats happening ????? ) Thanks so much for your help.

Yup:

revolution wrote:
You'll need to call ExitProcess also else your code will run off the end and probably crash.

Post 01 Feb 2017, 07:38
View user's profile Send private message Visit poster's website Reply with quote
Trentie89



Joined: 01 Feb 2017
Posts: 26
Location: Perth, Australia.
I'm a bit of a newbie with ASM, I have tried this and it still doesn't work, still says error.


Code:
;******************
;* FindWindow.asm * 
;****************** 

include 'win32ax.inc' 

.code  

  start:  
       invoke  FindWindow,NULL,"MyFile.txt - Notepad" 

       .if eax <> 0 
       invoke  MessageBox,HWND_DESKTOP,"Window Found!" ,"FindWindow",MB_OK 
       .endif

         invoke  ExitProcess,0
.end start 

Post 01 Feb 2017, 10:26
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14577
Location: 2014-JO25
Works okay for me in WinXP and Win7
Post 01 Feb 2017, 10:35
View user's profile Send private message Visit poster's website Reply with quote
Trentie89



Joined: 01 Feb 2017
Posts: 26
Location: Perth, Australia.
I'm on Windows 10, is that why it wont work I wonder.?. Look at attached screenshot. Thanks so heaps for helping me btw.[/img]


Description:
Filesize: 170.76 KB
Viewed: 731 Time(s)

error.jpg



_________________
I Am the greatest.!. ( NOT YET ).
Post 01 Feb 2017, 12:42
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14577
Location: 2014-JO25
Oh, I thought you were talking about runtime errors. You have an assembly time error.

But I can't understand why include would be an illegal instruction? That doesn't make sense to me. Is your fasmw the original .exe? Did you make any changes to it or something?
Post 01 Feb 2017, 12:55
View user's profile Send private message Visit poster's website Reply with quote
system error



Joined: 01 Sep 2013
Posts: 438
look at your "fasmw.ini".

Things like these could happen if you unzipped the fasm package at location A, run the FASMW there, and then moving that FASM folder to location B. FASMW.ini is set the first time you open FASMW.exe, that includes setting up the default FASM path where you first run it. Changing the content of .ini file would help.

Other than that, you have other problems. Weird problem, I must say.
Post 01 Feb 2017, 15:50
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14577
Location: 2014-JO25
system error: If the path is wrong then you still don't get an "illegal instsruction" error. You'd get a "file not found" error.
Post 01 Feb 2017, 15:55
View user's profile Send private message Visit poster's website Reply with quote
system error



Joined: 01 Sep 2013
Posts: 438
@revo Yeah i know that. I was just being general to potential beginners' problems.

This one is weird though. Getting 'illegal instruction' on an include directive is ... just funny.

I think he's running a script or something, or even a shortcut with wrong configuration.
Post 01 Feb 2017, 16:09
View user's profile Send private message Reply with quote
Trentie89



Joined: 01 Feb 2017
Posts: 26
Location: Perth, Australia.
Should I download fasm again and unzip it at a new location? I Havent modified anything from memory.
Post 02 Feb 2017, 01:37
View user's profile Send private message Reply with quote
Trinitek



Joined: 06 Nov 2011
Posts: 249

Trentie89 wrote:
Should I download fasm again and unzip it at a new location? I Havent modified anything from memory.

It's worth trying. I have no clue what's going on.
Post 02 Feb 2017, 04:07
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 868
Trentie89
If the error persists, would you please zip the source file you're trying to compile and attach it here?

_________________
Faith is a superposition of knowledge and fallacy
Post 02 Feb 2017, 14:16
View user's profile Send private message Reply with quote
Trentie89



Joined: 01 Feb 2017
Posts: 26
Location: Perth, Australia.
Hello Guys,

I Tried unzipping fasm to a new location, fresh from my downloaded one. It still says same error. Which file would you like me to zip, the asm file you mean.?.

Or my entire fasm file?

Thanks so much guys.
Post 03 Feb 2017, 02:05
View user's profile Send private message Reply with quote
KevinN



Joined: 09 Oct 2012
Posts: 161
I haven't used asm or fasm much and in a while but I don't remember ever using double quotes with fasm.. just single quotes
Post 03 Feb 2017, 06:52
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 453
Location: Belarus
Double quotes are OK. Just tried to compile the example as it appears in comments above on Win10 and it's OK. And indeed, after moving fasm dir to another location, I started getting file not found error, but not illegal instruction. My best guess is include directive contains non-latin chars that look like latin
Post 03 Feb 2017, 07:26
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14577
Location: 2014-JO25

zhak wrote:
My best guess is include directive contains non-latin chars that look like latin

But the OP said copy/paste from this thread. Just like I did, just like others did. And there are no non-ASCII characters in there. Also can/does fasmw display Unicode/UTF8 correctly?
Post 03 Feb 2017, 08:12
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14577
Location: 2014-JO25

Trentie89 wrote:
Which file would you like me to zip, the asm file you mean.?.

Or my entire fasm file?

I assume your .asm file. We all already have the fasm download file.
Post 03 Feb 2017, 08:13
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2, 3  Next

< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.