flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > display polynome internals: variable term used where not exp |
Author |
|
Tomasz Grysztar 23 Jul 2017, 08:49
If you want to display complete tree of the metadata information, you need to use recursion:
Code: macro displaypoly poly local buffer,number buffer = poly number = buffer scale 0 if number < 0 display '-' number = -number end if repeat 1, n:number display `n end repeat repeat elementsof buffer number = buffer scale % if number < 0 display '-' number = -number else display '+' end if if number <> 1 repeat 1, n:number display `n,'*' end repeat end if display '[' displaypoly buffer metadata % display ']' end repeat end macro displaypoly eax+2 Code: macro displaypoly poly local buffer,number buffer = poly number = buffer scale 0 if number < 0 display '-' number = -number end if repeat 1, n:number display `n end repeat repeat elementsof buffer number = buffer scale % if number < 0 display '-' number = -number else display '+' end if if number <> 1 repeat 1, n:number display `n,'*' end repeat end if if buffer metadata % display '[' displaypoly buffer metadata % display ']' else if buffer element % eq x86.reg display 'x86.reg' else display 'unknown' end if end repeat end macro displaypoly eax+ebx*2+3 |
|||
23 Jul 2017, 08:49 |
|
ProMiNick 23 Jul 2017, 09:31
Thanks.
Perfect - I tested on polynomes other than general registers too. One more question polynome element base can be send to display in anyway? I mean value of (buffer element %) extracted itself and displayed? |
|||
23 Jul 2017, 09:31 |
|
Tomasz Grysztar 23 Jul 2017, 10:33
Element by itself has no value, so there is nothing to display there.
|
|||
23 Jul 2017, 10:33 |
|
ProMiNick 23 Jul 2017, 11:09
If I override element macro itself and force defining values
Code: macro element arg& element arg match elem:bs index,arg elem.name equ elem elem.base equ bs else match elem,arg elem.name equ elem elem.base equ end if end macro could (buffer element %).name or (buffer element %).base become available? |
|||
23 Jul 2017, 11:09 |
|
Tomasz Grysztar 23 Jul 2017, 12:51
The variable defined by ELEMENT is like a value of a symbol, and you cannot get back to symbol from the value.
Code: a = 2 ; this defines "a" with known constant value 2 element b ; this defines "b" with unknown (variable) value X c = a + b ; this defines "c" with value "1+X" ; note that "c" no longer has any information about "a" or "b", they were only used to compute the value So all you could do would be to define the elements in such a way that they would contain some information for displaying purposes in their metadata. For example you could catch the definitions of elements with no metadata and insert your own metadata there: Code: element metaname : 'metaname' + metaname macro element? definition match name:metadata, definition element name:metadata else element definition:`definition + metaname end match end macro ; ... macro displaypoly poly local buffer,number buffer = poly number = buffer scale 0 if number < 0 display '-' number = -number end if repeat 1, n:number display `n end repeat repeat elementsof buffer number = buffer scale % if number < 0 display '-' number = -number else display '+' end if if number <> 1 repeat 1, n:number display `n,'*' end repeat end if if buffer metadata % relativeto metaname display string buffer metadata % scale 0 else display '[' displaypoly buffer metadata % display ']' end if end repeat end macro |
|||
23 Jul 2017, 12:51 |
|
ProMiNick 23 Jul 2017, 14:33
Mostly for myself: the way additional info can be added so it don`t touches any behavior of standart macros that is addition as multiplier. Just affect macros described in this post.
Code: element al? : x86.r8*'al' + 0 element cl? : x86.r8*'cl' + 1 element dl? : x86.r8*'dl' + 2 element bl? : x86.r8*'bl' + 3 element ah? : x86.r8*'ah' + 4 element ch? : x86.r8*'ch' + 5 element dh? : x86.r8*'dh' + 6 element bh? : x86.r8*'bh' + 7 |
|||
23 Jul 2017, 14:33 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.