flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > fasmg tests and bugs

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 02 May 2021, 10:02
jacobly wrote:
This creates a file with a funny name: (...)
Thanks for the report, the fix is up.

jacobly wrote:
Is there a way to parse a conditional expression stored in a variable from calm since check only supports normal expressions inside variables? I can't just assemble an if since I'm trying to jump based on the result.
I'm afraid not, there is no code path that could allow this, CHECK expects all condition logic to be pre-parsed.

However, as long as your CALM code executes during an active assembly (that is: not unconditionally inside a definition of a macro, or a skipped block) you can execute several lines to process a complete IF block and then CHECK the value set up by that block to jump accordingly.

It is also possible to add a specialized CALM instruction that could do that for you - but I'm not sure if it would be worth to have in general.
Nonetheless, the implementation could be quite simple, something like:
Code:
calm_determine:
        lodsd
        mov     ebx,eax
        call    get_available_value
        jc      calm_undefined_symbol
        mov     al,[edx+ValueDefinition.type]
        cmp     al,VALTYPE_SYMBOLIC
        jne     calm_invalid_value
        push    esi
        call    clear_line_embeddings
        mov     esi,[edx+ValueDefinition.value]
        mov     [line_start],esi
        mov     ecx,[edx+ValueDefinition.value_length]
        add     ecx,esi
        mov     [line_end],ecx
        call    get_condition_value
        mov     [calm_result],al
        pop     esi
        jmp     calm_execution_unit    
with additional snippets to plug it into the CALM engine:
Code:
alm_determine:
        mov     [value],calm_determine
        jmp     assemble_alm_operation_on_variable    
Code:
--- source/tables.inc
+++ source/tables.inc
@@ -593,10 +593,13 @@
   db 7,'compute',SYMCLASS_INSTRUCTION,VALTYPE_NATIVE_COMMAND,VAL_INTERNAL,0
   dd alm_compute

   db 5,'check',SYMCLASS_INSTRUCTION,VALTYPE_NATIVE_COMMAND,VAL_INTERNAL,0
   dd alm_check
+
+  db 9,'determine',SYMCLASS_INSTRUCTION,VALTYPE_NATIVE_COMMAND,VAL_INTERNAL,0
+  dd alm_determine

   db 4,'jyes',SYMCLASS_INSTRUCTION,VALTYPE_NATIVE_COMMAND,VAL_INTERNAL,0
   dd alm_jyes

   db 3,'jno',SYMCLASS_INSTRUCTION,VALTYPE_NATIVE_COMMAND,VAL_INTERNAL,0    
Post 02 May 2021, 10:02
View user's profile Send private message Visit poster's website Reply with quote
jacobly



Joined: 04 Feb 2016
Posts: 44
jacobly 12 Dec 2021, 04:59
The jip5 release breaks my a bunch of my infrastructure. I reduced the sources, found a change in behavior, and since I can't decide if it was intentional or not I'll post it and let you decide.
Code:
macro init if
        calminstruction test arg
                local line
                match =if?, arg
                jyes old
                arrange line, =display? 'new behavior', 10
                jump new
        old:
                arrange line, =display? 'old behavior', 10
        new:
                assemble line
        end calminstruction
end macro

init if

test if
test IF    
Code:
flat assembler  version g.jg8x
old behavior
old behavior

1 pass, 0 bytes.
flat assembler  version g.jip5
new behavior
new behavior

1 pass, 0 bytes.    
I note that removing the ? on line 4 half fixes it and adding one on line 15 fully fixes it, so I will probably still be able to fix my code regardless.
Edit: Oh yeah, I can also use IF on line 4 to not match the parameter, but I always hate doing that.
Post 12 Dec 2021, 04:59
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 12 Dec 2021, 09:28
It is just a new bug introduced while fixing the previous one. I'm correcting it immediately.

BTW, the previous problem that I needed to fix was that a pattern like "if=?" was incorrectly treated the same as "if?".
Post 12 Dec 2021, 09:28
View user's profile Send private message Visit poster's website Reply with quote
jacobly



Joined: 04 Feb 2016
Posts: 44
jacobly 12 Dec 2021, 16:08
Tomasz Grysztar wrote:
It is just a new bug introduced while fixing the previous one. I'm correcting it immediately.

BTW, the previous problem that I needed to fix was that a pattern like "if=?" was incorrectly treated the same as "if?".
Thanks, everything works now!
Post 12 Dec 2021, 16:08
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
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


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.