flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > List operations macros. |
Author |
|
MHajduk 03 Feb 2007, 20:21
I hope, that this set of macros designed for list operations will be interesting for You, because I haven't seen similar macros here.
Below is a description of each macro. Note that:
Usage: Head <list> Code: macro Head firstEl, [list] { common Result equ firstEl } Usage: Tail <list> Code: macro Tail firstEl, [list] { common Result equ list } Usage: Element, <el_number>, <list> Code: macro Element n, [list] { common Result equ list rept n \{ match L, Result \\{Tail L\\} \} match L, Result \{Head L\} } Usage: TailFrom <first_sublist_el_num>, <list> Code: macro TailFrom n, [list] { common Result equ list rept n \{ match L, Result \\{Tail L\\} \} } Usage: HeadTo <last_sublist_el_number>, <list> Code: macro HeadTo n, [list] { common Result equ match L, list \{Head L\} headTmp equ Result match L, list \{Tail L\} rept n \{ tailTmp equ Result match L, tailTmp \\{Head L\\} match L, Result \\{headTmp equ headTmp, L\\} match L, tailTmp \\{Tail L\\} \} Result equ headTmp } Usage: SubList <first_sublist_el_num>, <last_sublist_el_num>, <list> Code: macro SubList m, n, [list] { common HeadTo n, list match L, Result \{TailFrom m, L\} } Code: ; Example of using list operations macros ; (run with FASM preprocessor - 'fasmpre.exe'). ; ; (C) Mikolaj Hajduk, 03.02.2007. ; include 'ListMacros.inc' SubList 3,6,a,b,c,d,e,f,g,h Result Code: ;include 'ListMacros.inc' ;macro Head firstEl,[list] ;{ ; common ; Result equ firstEl ;} ;macro Tail firstEl,[list] ;{ ; common ; Result equ list ;} ;macro Element n,[list] ;{ ; common ; ; Result equ list ; ; rept n ; \{ ; match L,Result \\{ Tail L \\} ; \} ; ; match L,Result \{ Head L \} ;} ;macro TailFrom n,[list] ;{ ; common ; ; Result equ list ; ; rept n ; \{ ; match L,Result \\{ Tail L \\} ; \} ;} ;macro HeadTo n,[list] ;{ ; common ; ; Result equ ; ; match L,list \{ Head L \} ; headTmp equ Result ; ; match L,list \{ Tail L \} ; ; rept n ; \{ ; tailTmp equ Result ; ; match L,tailTmp \\{ Head L \\} ; match L,Result \\{ headTmp equ headTmp,L \\} ; ; match L,tailTmp \\{ Tail L \\} ; \} ; ; Result equ headTmp ;} ;macro SubList m,n,[list] ;{ ; common ; ; HeadTo n,list ; match L,Result \{ TailFrom m,L \} ;} ;SubList 3,6,a,b,c,d,e,f,g,h ;HeadTo 6,a,b,c,d,e,f,g,h ;Result equ ;match L,a,b,c,d,e,f,g,h{Head L} ;Head a,b,c,d,e,f,g,h ;Result equ a ;headTmp equ a ;match L,a,b,c,d,e,f,g,h{Tail L} ;Tail a,b,c,d,e,f,g,h ;Result equ b,c,d,e,f,g,h ;rept 6 ;{ ; tailTmp equ Result ; ; match L,tailTmp \{ Head L \} ; match L,Result \{ headTmp equ headTmp,L \} ; ; match L,tailTmp \{ Tail L \} ;} ;tailTmp equ b,c,d,e,f,g,h ;match L,b,c,d,e,f,g,h{Head L} ;Head b,c,d,e,f,g,h ;Result equ b ;match L,b{headTmp equ headTmp,L} ;headTmp equ a,b ;match L,b,c,d,e,f,g,h{Tail L} ;Tail b,c,d,e,f,g,h ;Result equ c,d,e,f,g,h ;tailTmp equ c,d,e,f,g,h ;match L,c,d,e,f,g,h{Head L} ;Head c,d,e,f,g,h ;Result equ c ;match L,c{headTmp equ headTmp,L} ;headTmp equ a,b,c ;match L,c,d,e,f,g,h{Tail L} ;Tail c,d,e,f,g,h ;Result equ d,e,f,g,h ;tailTmp equ d,e,f,g,h ;match L,d,e,f,g,h{Head L} ;Head d,e,f,g,h ;Result equ d ;match L,d{headTmp equ headTmp,L} ;headTmp equ a,b,c,d ;match L,d,e,f,g,h{Tail L} ;Tail d,e,f,g,h ;Result equ e,f,g,h ;tailTmp equ e,f,g,h ;match L,e,f,g,h{Head L} ;Head e,f,g,h ;Result equ e ;match L,e{headTmp equ headTmp,L} ;headTmp equ a,b,c,d,e ;match L,e,f,g,h{Tail L} ;Tail e,f,g,h ;Result equ f,g,h ;tailTmp equ f,g,h ;match L,f,g,h{Head L} ;Head f,g,h ;Result equ f ;match L,f{headTmp equ headTmp,L} ;headTmp equ a,b,c,d,e,f ;match L,f,g,h{Tail L} ;Tail f,g,h ;Result equ g,h ;tailTmp equ g,h ;match L,g,h{Head L} ;Head g,h ;Result equ g ;match L,g{headTmp equ headTmp,L} ;headTmp equ a,b,c,d,e,f,g ;match L,g,h{Tail L} ;Tail g,h ;Result equ h ;Result equ a,b,c,d,e,f,g ;match L,a,b,c,d,e,f,g{TailFrom 3,L} ;TailFrom 3,a,b,c,d,e,f,g ;Result equ a,b,c,d,e,f,g ;rept 3 ;{ ; match L,Result \{ Tail L \} ;} ;match L,a,b,c,d,e,f,g{Tail L} ;Tail a,b,c,d,e,f,g ;Result equ b,c,d,e,f,g ;match L,b,c,d,e,f,g{Tail L} ;Tail b,c,d,e,f,g ;Result equ c,d,e,f,g ;match L,c,d,e,f,g{Tail L} ;Tail c,d,e,f,g ;Result equ d,e,f,g d,e,f,g
|
|||||||||||
03 Feb 2007, 20:21 |
|
dead_body 04 Feb 2007, 19:27
interesting, but where can i use it?
|
|||
04 Feb 2007, 19:27 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.