flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > .break/.continue in HL macros in FASM Classic

Author
Thread Post new topic Reply to topic
AsmGuru62



Joined: 28 Jan 2004
Posts: 1657
Location: Toronto, Canada
AsmGuru62 16 May 2020, 16:30
Hello.
I know there are some header files with the ability to break loops or jump to loop starting point, but it would be so nice to have this "out of the box". Like if I get new version of FASM - the features would be there already.

Code:
.while [numrecs] < MAX_RECS
    .if (...)
        ;
        ; want to get out of loop
        ;
        mov     [numrecs], MAX_RECS     ; had to do it instead of ".break"
                                        ; and sometimes I need the [numrecs] after the loop
    .else
        ;
        ; do something here
        ;
        inc     [numrecs]
    .endif
.endw
    
Post 16 May 2020, 16:30
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20401
Location: In your JS exploiting you and your system
revolution 16 May 2020, 17:57
You can use jmp
Code:
.while something
 .if
  ;...
  jmp .we_are_done
 .else
  ;...
 .endif
.endw
.we_are_done:    
Post 16 May 2020, 17:57
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1657
Location: Toronto, Canada
AsmGuru62 16 May 2020, 21:43
Indeed.
Post 16 May 2020, 21:43
View user's profile Send private message Send e-mail Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4060
Location: vpcmpistri
bitRAKE 16 May 2020, 22:28
Well for fasmg ...
Code:
; ~\fasmg\packages\x86\include\macro\if.inc

define _if..break? _break

macro _break
        jmp __ENDW
end macro    
Adding .break to .repeat/.until will require more work.

The laziest way I can think of would be to define .break at the start of each .repeat. Then a label needs to be added to _until, and restore prior definition of .break. I'd make some tests and try this out, but I've never really used the dot HLL stuff. I don't mind it, but it's just not my style.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 16 May 2020, 22:28
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: 20401
Location: In your JS exploiting you and your system
revolution 16 May 2020, 23:41
Moved to Macroinstructions forum.

These are implemented in macros, not within the compilers internals.
Post 16 May 2020, 23:41
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1821
Roman 24 Jun 2020, 08:38
From INCLUDE\MACRO\IF.inc
macro .endw {
jmp __WHILE
__ENDW:
restore __ENDW
restore __WHILE }

macro break { jmp __ENDW}
In code use macro break

Code:
.while [count] < 10
         .if eax = 1
               break
         .else
               inc [count]
         .endif
.endw 

    


If .while in proc enought use ret
Code:
.while [count] < 10
         .if eax = 1
               ret
         .else
               inc [count]
         .endif
.endw 
ret
    
Post 24 Jun 2020, 08:38
View user's profile Send private message 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.