flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Something Like C's Data Declaration... |
Author |
|
revolution 20 Dec 2013, 13:58
I expect that using match can give you that functionality:
Code: macro float [arg] { forward match a==b,arg \{ a dq b \} } |
|||
20 Dec 2013, 13:58 |
|
system error 22 Dec 2013, 06:23
revolution wrote: I expect that using match can give you that functionality: |
|||
22 Dec 2013, 06:23 |
|
m3ntal 23 Dec 2013, 12:46
I've provided endless macros like this for X86+ARM. Example: This supports standard C declarations: char, short, int, float, double:
Code: macro verify e { if ?s eq 0 display `e 'Error: ' e end if } ; define variable of type, name, value macro !DV type, name, value { local l l=$ name type value ; example: msg db 'Hello' name#.$=$-l ; size } ; define b/w/d/q/t variable macro !D1 a, b { !DV db, a, b } macro !D2 a, b { !DV dw, a, b } macro !D4 a, b { !DV dd, a, b } macro !D8 a, b { !DV dq, a, b } macro !DF a, b { !DV dt, a, b } ;;;;;;;;;;;;;; DEFINE HL VARIABLE ;;;;;;;;;;;;;;;; ; define X. syntax: type then any a/a=b ; sequence/s separated with ,s. example: ; NUMBER x, y, w=320, h=240 ; variables=0 if there is no initial value macro !D type, [p] { common if p eq 'Name expected' end if forward define ?s 0 match =0 a==b, ?s p \{ ; a=b type a, b define ?s 1 \} match =0 a=,, ?s p \{ ; a, (next) type a, 0 define ?s 1 \} match =0 a, ?s p \{ ; a (end) type a, 0 define ?s 1 \} verify variable } ; HL variable names macro char [a] { !D !D1, a } macro short [a] { !D !D2, a } macro int [a] { !D !D4, a } macro float [a] { !D !D4, a } macro double [a] { !D !D8, a } Code: ; verify size of block/text/array macro verify.size n { if n eq 'Size must be specified' else if ~ n eqtype 0 'Size must be numeric' else if n eq 0 'Size cannot be zero' end if } ; define byte array. BLOCK b(size) macro BLOCK [p] { forward define ?s 0 match =0 (size), ?s p \{ verify.size size db size dup(0) define ?s 1 \} match =0 name(size), ?s p \{ verify.size size !DV db, name, size dup(0) define ?s 1 \} verify BLOCK } ; create HL 'text' variable/s. TEXT t='X'. ; note: (n) is the size macro TEXT [p] { forward local l define ?s 0 ; TEXT t(n)='abc' match =0 name(size)==text, ?s p \{ l=$ verify.size size !DV db, name, <text,0> times (size-($-l)) db 0 define ?s 1 \} ; TEXT t(n) match =0 name(size), ?s p \{ verify.size size !DV db, name, size dup(0) name\#.$=size define ?s 1 \} ; TEXT t='abc' match =0 name==text, ?s p \{ !DV db, name, <text,0> ; name db 't', 0 define ?s 1 \} ; TEXT t match =0 name, ?s p \{ 'Size must be specified:' name define ?s 1 \} verify TEXT } |
|||
23 Dec 2013, 12:46 |
|
system error 18 Jan 2014, 17:28
m3ntal wrote: I've provided endless macros like this for X86+ARM. Example: This supports standard C declarations: char, short, int, float, double: Too much for me, but thanks. |
|||
18 Jan 2014, 17:28 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.