flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Tomasz Grysztar 05 Mar 2006, 11:40
If you need calculations, use assembler, not preprocessor:
Code: repeat 8 new = % * 4 if new=4 display "..." end if end repeat |
|||
![]() |
|
lilainst 05 Mar 2006, 23:20
In order not to bother everyone here, I didn't post all my intention in the first post. Sorry.
Actually, I wanna write a Macroinstruction to display values of some constants. Of course, there's an example in manual pages which displays 32bit value, however, I intend to write a macro which could display the value of constant in spite of its length. I wrote the following code: Code: macro output value { display "0x" repeat 16 ; 64bit number tmp = (value shr ((% - 1) * 4)) nybble = tmp and 0xf if tmp <> 0 if nybble > 9 char = 'A' + nybble - 9 - 1 else char = '0' + nybble end if display char end if end repeat } output 0xabcdef1234567890 The problem is "output" macro will display the value in reverse order. As I remembered there's an example of 'append' macro in the manual, which could help build macro args, I change the code to : Code: list equ macro append item { match any, list \{ list equ list, item\} match , list \{list equ item\} } macro display_nybble [arg] { reverse display arg } macro output value { display "0x" repeat 16 ; 64bit number tmp = (value shr ((% - 1) * 4)) nybble = tmp and 0xf if tmp <> 0 if nybble > 9 char = 'A' + nybble - 9 - 1 else char = '0' + nybble end if ; append char to list append char end if end repeat } output 0xabcdef1234567890 match params, list {display_nybble params} It doesn't work either, cause the 'match' is processed before the calculations. Should I think in another way? Thanks in advance. |
|||
![]() |
|
Tomasz Grysztar 05 Mar 2006, 23:27
The outputting code is written in the assembler's language, while the "macro" and "match" are the things of preprocessor - you cannot mix those two worlds in this way.
You should instead modify the assembler's algorithm to produce the digits in the reverse order. Replacing (% - 1) by (16 - %) should be enough in this case. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.