flat assembler
Message board for the users of flat assembler.

Index > Windows > [Solved]What's wrong with my code ?

Author
Thread Post new topic Reply to topic
lacamoura



Joined: 12 Dec 2014
Posts: 5
lacamoura 12 Dec 2014, 18:46
Hello,

I'm new to assembler, and decided to use FASM

ok, my first application in FASM was to try if conditional

Code:
include 'win32ax.inc'

.data
    handle db ?

.code

Start:
        invoke  MessageBox, 0, "Are you over 18 ?", "SimpleApp", MB_YESNO
        mov [handle], al
        if handle = IDYES
                invoke  MessageBox, 0, "You are an adult Smile", "SimpleApp", MB_OK
        end if
    
        invoke  ExitProcess, 0
.end Start
    


if I press Yes or No, I don't get the second MessageBox

did I miss something ?

thanks in advance


Last edited by lacamoura on 12 Dec 2014, 20:53; edited 1 time in total
Post 12 Dec 2014, 18:46
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 13034
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 12 Dec 2014, 19:13
if [handle]
maybe?
Post 12 Dec 2014, 19:13
View user's profile Send private message Reply with quote
lacamoura



Joined: 12 Dec 2014
Posts: 5
lacamoura 12 Dec 2014, 19:18
I get
Code:
flat assembler  version 1.71.22  (869198 kilobytes memory)
HELLO.asm [11]:
    if [handle] = IDYES
[b]error: invalid value.[/b]
    
Post 12 Dec 2014, 19:18
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 13034
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 12 Dec 2014, 19:35
ah, so sorry, not much idea,
maybe is AH?
i guess maybe you are correct with if handle = IDYES,
Post 12 Dec 2014, 19:35
View user's profile Send private message Reply with quote
lacamoura



Joined: 12 Dec 2014
Posts: 5
lacamoura 12 Dec 2014, 19:51
sleepsleep wrote:

maybe is AH?


I'm new to assemby, yes. but I know that AL is the least-significant byte, and the AH is the most-significant byte in AX
Confused

and i tried with
Code:
.data
    handle dd ?
    

and
Code:
mov [handle], eax
    


still doesn't work Confused
Post 12 Dec 2014, 19:51
View user's profile Send private message Reply with quote
randomdude



Joined: 01 Jun 2012
Posts: 83
randomdude 12 Dec 2014, 20:22
i think 'if' checks it at compile time, try with '.if'

.if byte[handle] = IDYES
invoke MessageBox, 0, "You are an adult Smile", "SimpleApp", MB_OK
.endif
Post 12 Dec 2014, 20:22
View user's profile Send private message Reply with quote
lacamoura



Joined: 12 Dec 2014
Posts: 5
lacamoura 12 Dec 2014, 20:52
randomdude wrote:
i think 'if' checks it at compile time, try with '.if'

.if byte[handle] = IDYES
invoke MessageBox, 0, "You are an adult Smile", "SimpleApp", MB_OK
.endif


thanks randomdude, you're right about compile time

but FASM gave a lot of errors when I tried .if .... .endif

so tried low level comparaison, and it works

Code:
include 'win32ax.inc'

.data
    handle db ?

.code

Start:
        invoke  MessageBox, 0, "Are you over 18 ?", "SimpleApp", MB_YESNO
    mov [handle], al
    ;if handle = IDYES
    cmp [handle], IDYES
    jne .ExitApp
    invoke      MessageBox, 0, "You are an adult Smile", "SimpleApp", MB_OK
    ;end if
    .ExitApp:
        invoke  ExitProcess, 0
.end Start
    
Post 12 Dec 2014, 20:52
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 767
tthsqe 12 Dec 2014, 22:39
see http://board.flatassembler.net/topic.php?t=7217 for lots of uses of .if .else ect
Post 12 Dec 2014, 22:39
View user's profile Send private message Reply with quote
lacamoura



Joined: 12 Dec 2014
Posts: 5
lacamoura 14 Dec 2014, 17:14
@tthsqe thanks dude
Post 14 Dec 2014, 17:14
View user's profile Send private message Reply with quote
CampTheBoss



Joined: 02 Feb 2015
Posts: 42
Location: A chair
CampTheBoss 02 Feb 2015, 20:32
There is an easy way to do it. (it requires Win32ax)
Code:
invoke MessageBox,0,yourmsg,yourcaption,MB_YESNO
.if EAX = IDYES
jmp good
.endif
invoke ExitProcess,0

good:
invoke MessageBox,0,goodmsg,yourcaptopn,MB_OK
invoke ExitProcess,0    
[/code]
Post 02 Feb 2015, 20:32
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.