flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > HLL macros |
Author |
|
Tomasz Grysztar 25 Apr 2005, 22:43
Have you tried the standard ".if" macro that is provided with the fasmw's includes? With the old method of including (which you used in your sample above), you can get it with:
Code: include '%fasminc%\macro\if.inc' And when you use WIN32AX/WIN32WX or WIN32AXP/WIN32WXP includes, it is included by default. The syntaxes are like: Code: .if eax,e,4 ; if eax equal to 4 ; some code .elseif eax,ge,7 ; if eax greater or equal to 5 ; some code .elseif ebx ; if ebx is not 0 ; some code .endif .while [var],b,1000 ; while [var] is below 1000 ; some code .endw .repeat ; some code .until eax ; until eax is not 0 |
|||
25 Apr 2005, 22:43 |
|
Octavio 25 Apr 2005, 23:28
OzzY wrote: But I think people usually change from FASM to MASM32 because of the HLL macros like .IF, .WHILE, etc... Quote:
For programing in HLL is better to use a HLL . Quote:
Yes , you mean that you don´t like assembly because is not like C. |
|||
25 Apr 2005, 23:28 |
|
OzzY 26 Apr 2005, 01:01
Octavio: I prefer asm, but sometimes I need rapid app develop with the power of asm. And I know that C compilers of today are very optimized. Under windows C can produce 1024 bytes exe with a good linker. But I like the power of asm.
Privalov: Thanks a lot! FASM is great! And the macro capability of Fasm is just perfect!! I tested and it works very good: Code: format PE GUI 4.0 include '%fasminc%\win32a.inc' include '%fasminc%\macro\if.inc' start: invoke MessageBox,0,msg,ttl,MB_YESNO .if eax,e,IDYES invoke MessageBox,0,answer,ttl,0 .else mov esi,answer .while byte[esi],ne,'Y' inc esi .endw mov word[esi],'No' add esi,2 mov byte[esi],0 invoke MessageBox,0,answer,ttl,0 .endif ret msg db 'Yes or no?',0 ttl db 'HLL macros test with fasm',0 answer db 'Answer: Yes',0 data import library user32,'user32' include '%fasminc%\apia\user32.inc' end data Everytime I ask on this board I'm more happy with Fasm! =) Thanks! |
|||
26 Apr 2005, 01:01 |
|
vid 26 Apr 2005, 09:39
OzzY: By the time, you will learn to code not structured code (with .if, .while), but what i call "linear code", where you have (kind-of) independent blocks of code linked with jumps. Right now i have problems coding structured code, because you just can't use it to create "natural" solution for program flow, you have to workaround everything. (For example here:
Code: for a=1 to 10 { for b=1 to 10 { ... <part1> if something goto OutOfLoop ... <part2> } } OutOfLoop: In "proper" structured code you have to emulate end-conditions (a:=10, b:=10) instead of goto, and put rest of code (<part2>) under another if, which really just messes the code. But try to say it to some structured-code purist, he will tell you that "your concept is wrong" and it will result in completely different conditions on loop as it was meant for. This was just an example, both coding styles have pluses and minuses, you will learn by yourself. |
|||
26 Apr 2005, 09:39 |
|
JohnFound 26 Apr 2005, 11:25
vid wrote: OzzY: By the time, you will learn to code not structured code (with .if, .while), but what i call "linear code", where you have (kind-of) independent blocks of code linked with jumps. IMHO, more precise definition is: Structured programming is not "block based" programming, neither if..then..while..etc. HLL operators. Structured programming is beyond all these syntax conventions. It is a way of thinking and methods of program design. You can write unstructured program in Pascal or C and highly structured program in pure assembler or even HEX. And I don't think "if..then" is more readable or more structured than "cmp jcc" - all is a matter of habits. Regards. |
|||
26 Apr 2005, 11:25 |
|
pelaillo 26 Apr 2005, 12:38
and large and nested if..then blocks are less readable/maintainable and more error prone.
|
|||
26 Apr 2005, 12:38 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.