flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > who can post a "For" macro? thank! |
Author |
|
Tomasz Grysztar 02 Sep 2003, 17:41
Maybe something like:
Code: macro for var,min,instr,max { mov [var],min local loop,end loop: _for_var equ var _for_limit equ max _for_instr equ instr _for_origin equ loop _for_exit equ end } macro endfor { cmp [_for_var],_for_limit je _for_exit _for_instr [_for_var] jmp _for_origin _for_exit: restore _for_exit restore _for_origin restore _for_limit restore _for_instr restore _for_var } to fix ,inc, downto fix ,dec, use it like here: Code: for a,1 to 10 for b,10 downto 1 ; ... endfor endfor It should be easy to extend it with more functions. |
|||
02 Sep 2003, 17:41 |
|
zjlcc 03 Sep 2003, 02:00
thank Privalov because my bad english, so i study "Macro" syntax very difficulty anyways, thank Privalov again!!! |
|||
03 Sep 2003, 02:00 |
|
wakalabis 17 Dec 2004, 08:24
Privalov, (or anybody else)
Why does using multiple levels of this macro work ? Code: for a,1 to 10 for b,10 downto 1 for c, 2 to 5 endfor ; ... endfor endfor when you have something like this: Code: macro my_macro var{ _var equ var ... } macro my_macro_end { _restore _var } // code my_macro 1 my_macro 2 when my_macro is called for the second time, what happens to "_var" ? is it redefined, this time assuming value '2', clearing the old value '1' ? or is there some kind of context created once for each time 'my_macro' is expanded ? does the new value '2' get "pushed" at each equ and "poped" at each restore ? |
|||
17 Dec 2004, 08:24 |
|
Nikolay Petrov 17 Dec 2004, 14:58
i use very often next code
Code: include '%fasminc%\macro\if.inc' ;for a:=1 to 10 do begin mov [a],1 .repeat ;........ inc [a] .until [a],e,11 dec [a] ;for a:=10 downto 1 do begin mov [a],10 .repeat ;...... dec [a] .until [a],e,0 inc [a] i didn't tested next code, but i think it's going to work. Code: ;for a,1 to 10 ;for b,10 downto 1 ;for c, 2 to 5 ;endfor ; ... ;endfor ;endfor mov [a],1 mov [b],10 mov [c],2 .repeat .repeat .rapeat ;code third cycle inc [c] .until c,e,6 mov [c],2 ;code second cycle dec [b] .until b,e,0 mov [b],10 ;code first cycle inc [a] .until a,e,11 dec [a] |
|||
17 Dec 2004, 14:58 |
|
beppe85 18 Dec 2004, 22:08
Yes, you have gotten the idea!
wakalabis wrote: Privalov, (or anybody else) See this example: Code: macro teste var { _myvar equ var } macro endt { restore _myvar } teste 'a' display _myvar teste 'b' display _myvar endt display _myvar endt display _myvar The last display causes an error, because _myvar gets restored to its very first meaning, that is, _myvar per se. |
|||
18 Dec 2004, 22:08 |
|
wakalabis 19 Dec 2004, 02:04
beppe85, você é brasileiro ?
Valeu pela resposta ! Translation: beppe85, are you Brazilian ? Thanks for replying ! |
|||
19 Dec 2004, 02:04 |
|
beppe85 19 Dec 2004, 06:19
wakalabis, com certeza, sou sim.
Translation: Sure I am. |
|||
19 Dec 2004, 06:19 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.