flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
IronFelix 10 Jan 2009, 12:55
Sorry,
[code] if Function1 <> OutOfCodeAddress [\code] must be [code] if Function1 = OutOfCodeAddress [\code] to display correct message, but it does not make this code work ))))) |
|||
![]() |
|
LocoDelAssembly 10 Jan 2009, 14:56
That is because, since you are allowing the code to be relocated at run-time, the address of Function1 cannot be known at compile-time so it is not possible to tell if Function1 is equal to OutOfCodeAddress or not.
|
|||
![]() |
|
LocoDelAssembly 10 Jan 2009, 15:08
Perhaps you need this?
Code: CODE_BLOCK_BEGIN: Tmp_Lab: retn ; or some other code Function1 = foo ;... CODE_BLOCK_END: foo: macro isInsideCode address* { if address >= CODE_BLOCK_BEGIN & address < CODE_BLOCK_END display "Yes, ", `address, " is inside the code!",13,10 else display "No, ", `address, " is not inside the code...", 13, 10 end if } isInsideCode Tmp_Lab isInsideCode foo |
|||
![]() |
|
IronFelix 10 Jan 2009, 19:28
Thanks for your explanation LocoDelAssembly! But I have next question,
but first - code: Code: OutOfCode = $$ - 1 asd: A = asd B = OutOfCode if A <> OutOfCode display "A is in code.",13,10 end if if B = OutOfCode display "B is out of code.",13,10 end if The question is - will "OutOfCode" be really out in such case? Thanks. _________________ Flat Assembler is the best! |
|||
![]() |
|
LocoDelAssembly 10 Jan 2009, 23:25
Yes, since it will be one byte behind the base address.
However, if you really want to test if some label (or some label added/subtracted by a constant) belongs to some byte defined by the source code (either instruction bytes or data bytes), then the macro would be this one: Code: macro isInsideCode address* { if (address >= $$) & (address < END_OF_SOURCE) display "It is inside", 13, 10 else display "It is outside", 13, 10 end if } Note that it is assumed you will not use the ORG directive anywhere, not only because it kills relocations, but also because the testing of an address gets more complicated (it has to account for every ORG directive used on the source). Testing for labels defined inside virtual blocks won't work properly neither. |
|||
![]() |
|
IronFelix 10 Jan 2009, 23:44
Thanks for explanation! It is quite enough for me to work fine with just equal comparison, without range checking.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.