Sorry I did not make it clear. Throughout the program, I will only be executing the code in either block1 or block2 (both have the same local label names) based on a condition (ie, one of them will not be used during the entire execution). So throughout the program instead of checking every time whether block1 is to be used or block2 I simply want to call the local labels using block.labelname
You can't jump to the respective block's sub by just storing one value. Jump instructions store offsets to the respective location (either relative, if direct jump, or absolute, if indirect).
Since I assume block1 and block2 are different pieces of code, then their subs are definitely different code, thus different sizes. You can't do, for example, block+x, where x is block1.sub1-block1, because then it would fail on block2.sub1, assuming it has a different offset (relative to block2) which is probably the case...?
However, you can store an index to a table, or simply offset to the table as you did in your second attempt, the table holding offsets for the sub1 and sub2 for each block etc.
Your discussion with a friend as you mentioned it does indeed use that method, which works fine. Any problems with it or did you just post because you found the solution?
Don't worry about it, it is the best solution if you have many such blocks or many conditions, that's how you can make "objects" in C or asm (which don't have abstract OOP things), because basically those offsets are "function pointers" (if you know C).
Of course in asm you have more control and they don't have to be functions (you use jmp instead), as long as they all have same entry conditions it should work fine.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum