flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Macro and access of data |
Author |
|
cod3b453 17 Mar 2012, 21:16
Not sure I understand this fully but it looks like there's a few things you can do:
- Define macros containing the asm before the code and provide the macro name as a parameter, which then gets used in "val" - Use something like "file `val" to include an external file containing the asm - Use a list/table of locations to load/store code between locations (you can load from a virtual address space and store in actual address space) Hope that helpful |
|||
17 Mar 2012, 21:16 |
|
shutdownall 18 Mar 2012, 18:47
cod3b453 wrote: Not sure I understand this fully but it looks like there's a few things you can do: I think you did understand right. Exactly I want to define the code at the end of the program but put in the output file somewhere in the beginning or middle of other data. That's why I thought about "virtual" which I did use before. Your last proposal sounds very good to me. "Use a list/table of locations to load/store code between locations (you can load from a virtual address space and store in actual address space) " Can you or anybody else provide a simple example of that technique ? I think this is exactly what I want. Does it work with ORG statement ? So give an ORG to virtual adress space ? I don't like to separate the code to other files. Maybe optional but could be solved by includes. In general you have in many cases only a few basic lines to invoke the code and the rest of the file would be ASM code. |
|||
18 Mar 2012, 18:47 |
|
cod3b453 19 Mar 2012, 18:13
OK I tried using the list example from the FASM manual but that didn't work seems that a constructed list can't be used to feed macro parameters the way I thought.
Here's an idea of what I meant for the first version: Code: macro REM line,val { local .x,.length,.len db line shr 8 ; line number of REM statement db line and $FF ; line number of REM statement if val eq virtual at 0 _asm_#line .len = $ end virtual dw .len+2 ; lenght of line db $EA ; REM statement (token code) _asm_#line else db .length+2 db $EA ; REM statement (token code) .x db val .length = $-.x db NEWLINE end if } macro _asm_20 { LD BC,$1234 RET } REM 10,'Some text to identify program' REM 20, REM 30,'any following statement |
|||
19 Mar 2012, 18:13 |
|
shutdownall 19 Mar 2012, 23:09
cod3b453 wrote:
Thanks, look good but didn't you miss something ? How to get _ams_20 into the first macro ? Maybe put the "call" in line 20 ? |
|||
19 Mar 2012, 23:09 |
|
cod3b453 19 Mar 2012, 23:26
In this case leaving the second parameter blank automatically tries to use macro "_asm_#line" -> _asm_20. You can add another parameter to do the same thing:
Code: macro REM line,val,str { local .x,.length,.len db line shr 8 ; line number of REM statement db line and $FF ; line number of REM statement if str eq virtual at 0 val .len = $ end virtual dw .len+2 ; lenght of line db $EA ; REM statement (token code) val else db .length+2 db $EA ; REM statement (token code) .x db str .length = $-.x db NEWLINE end if } macro _asm_20 { LD BC,$1234 RET } REM 10,,'Some text to identify program' REM 20,_asm_20 REM 30,,'any following statement' |
|||
19 Mar 2012, 23:26 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.