flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > noobie questions |
Author |
|
cod3b453 06 Dec 2012, 22:15
As you understood for (1), the # joins two elements to construct a new identifier.
EDIT: Sorry for the string db "#name#" you actually should do db `name For (2) here is some example usage: Code: macro A a,[b,c] { common db a forward db b+c common db a reverse db b+c } A 1,\ 2,3,\ 4,5 ; db 1 ; db 5 ; db 9 ; db 1 ; db 9 ; db 5 For (3) you can simply add the default in the definition: Code: macro A a,[b=2,c=3] ; ... A 1,\ ,,\ 4,5 ; ... |
|||
06 Dec 2012, 22:15 |
|
baldr 06 Dec 2012, 23:33
Hugh Aguilar,
LISTING program beneath TOOLS folder makes listing, for preprocessed source you'll need PREPSRC tool. Both require .fas file to be generated beforehand ("Run"|"Build symbols" in FASMW; -s filename switch for command-line compiler). |
|||
06 Dec 2012, 23:33 |
|
uart777 12 Dec 2012, 20:52
Quote: I'm totally baffled by COMMON, REVERSE and FORWARD. Can anybody explain these? Any macro that accepts variable arguments ([va]) must specify how to process them; once or as an entire list (common) or separately in a loop (forward/reverse). It helps to imagine them with invisible braces {}. Example: Code: macro pushx [p] { ; push parameters common ; do this once... if ~ p eq ; if any parameters forward ; for (i=0; i<p.n; i++) { pushd p ; push p[i] common ; } ; end forward end if ; once } ; create successive powers of 2 starting ; at BIT0, from right to left macro powers [id] { common local n ; common { local n=0 } n=0 forward ; for (i=0; i<id.n; i++) { id=1 shl n ; id[i]=1<<n n=n+1 ; } } ; create readable bit structure from ; left to right. example: 0000ABCDb. ; powerz A, B, C, D ; A=8, B=4, C=2, D=1 macro powerz [id] { common local n n=1 forward n=n+1 common n=n-2 forward id=1 shl n n=n-1 } ; create a list of incremental values starting ; at 0. like "enum" in C. example: ; numeric A, B=7, D ; here, A=0, D=8 macro numeric [id] { common local n n=0 ; n=0 forward define ?v 0 ; initial value? match a==b, id \{ a=b n=b ; set n define ?v 1 ; yes, specified \} if ?v=0 ; else=n (previous+1) id=n end if n=n+1 ; n++ } numeric YES=1, NO=0, NONE=-1,\ TRUE=1, FALSE=0, NULL=0, DEFAULT=0,\ INVALID=-1, INFINITE=-1, DETECT=-1 Quote: I'm unsure of how the # operator works. # concencates names like ## in C. \ escape symbol/s are used for inner blocks: \#, \\#, \\\#, etc. Code: ; create/initialize "resolution" structures... ; resolution: ; TEXT .name(16) ; NUMBER .w, .h, .bpp macro resolution [p] { common resolutions: forward match name==w*h, p \{ TEXT name\#.name(16)=\`name NUMBER name\#.w=w,\ name\#.h=h, name\#.bpp=32 \} } macro define.resolutions { resolution \ QQVGA = 160*120,\ HQVGA = 240*160,\ QVGA = 320*240,\ WQVGA = 480*272,\ VGA = 640*480,\ NTSC = 720*480,\ WVGA = 800*480,\ SVGA = 800*600,\ WSVGA = 1024*600,\ XGA = 1024*768,\ SXGA = 1280*1024,\ HD720 = 1280*720,\ WXGA = 1280*800,\ WSXGA = 1440*900,\ HD1080 = 1920*1080 } Quote: FASM aborted with an error message on the second invocation of TESTER2. It said that =99 is not a valid instruction. In response to: if b eq (if equals nothing/empty), then b=99 is interpreted as =99. To check if a parameter was sent, use: if ~ b eq (if not nothing) Code: macro tester a, b { if ~ b eq ; if b was sent dd a, b else ; just a dd a end if } tester 1 tester 1, 2 |
|||
12 Dec 2012, 20:52 |
|
fasmnewbie 30 Jul 2013, 23:18
Well, that is no noob's question. Those who responded are no noobs either. I am out of here as fast as I can.
|
|||
30 Jul 2013, 23:18 |
|
AsmGuru62 31 Jul 2013, 02:01
Me too -- these macros make my head spin!
|
|||
31 Jul 2013, 02:01 |
|
fasmnewbie 23 Feb 2014, 09:09
AsmGuru62 wrote: Me too -- these macros make my head spin! Hahaha |
|||
23 Feb 2014, 09:09 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.