flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Feature request Fasm1: scaleof & elementof

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 806
Location: Russian Federation, Sochi
ProMiNick 17 Dec 2024, 18:19
1st. Backport of scaleof, elementof

I made assumption that base register usualy met as 2nd register encoded in 20bit expression operand, while the first one is indexed register, so order scalar,2nd(suppose base register),1st(suppose index register)

wanted syntax:
"0 scaleof eax*8+ebx+100" with result 100
"1 scaleof eax*8+ebx+100" with result 1
"2 scaleof eax*8+ebx+100" with result 8

"0 elementof eax*8+ebx+100" with result 1
"1 elementof eax*8+ebx+100" with result ebx
"2 elementof eax*8+ebx+100" with result eax

how this operators could be realized:
Code:
calculate_scaleof:
        cmp     dword[edi+4],0             
        jne     value_out_of_range         
        mov     eax,[edi]                  
        sub     eax,2                      
        ja      value_out_of_range         
        jnp      clear_nonscalar           
      scaleof_fromreg:                     
        mov     al,[eax+ebx+10]            
        jnc     done_scaleof               
        cmp     al,0                       
        jz      scaleof_fromreg            
      done_scaleof:                        
        cbw                                
        cwde                               
        cdq                                
        mov     [ebx],eax                  
        mov     [ebx+4],edx                
        mov     [ebx+13],dl                
      clear_nonscalar:                     
        mov     dword[ebx+8],0             
        mov     byte[ebx+12],0             
        mov     dword[ebx+16],0
        ...

calculate_elementof:
        cmp     dword[edi+4],0             
        jne     value_out_of_range         
        mov     eax,[edi]                  
        sub     eax,2                      
        ja      value_out_of_range         
        jnp     scalar_element ;np scale0 ;s scale 1
        jns     @F
        cmp     byte[ebx+11],1
        jb      @F
        mov     al,[ebx+9]
        mov     [ebx+8],al
      @@:
        and     al,[ebx+8]
        jz      @F
        add     eax,1 shl 16
        mov     [ebx+8],eax
      @@:
        xor     eax,eax
        mov     [ebx],eax
        jmp     done_elementof
      scalar_element:
        xor     eax,eax
        or      al,[ebx+13]
        or      eax,[ebx]
        or      eax,[ebx+4]
        sbb     eax,eax
        neg     eax
        mov     [ebx],eax
        xor     eax,eax
        mov     [ebx+8],eax
      done_elementof:
        mov     [ebx+4],eax
        mov     [ebx+12],eax
        mov     [ebx+16],eax
        ...    


2nd. Analog to match for replacement but for special characters

Syntax
replace spec_character,spec_character2,... with character_or_text,character_or_text2,.. { here is expression where replacements take effect}keywords are "replace" & "with"

3rd.
true|false expression "encodable instr" where its instr is acts like it compiled in another thread with same code bitness, inherited tree of symbols that instr depend on and enclosed in virtual block, and result of expression as result of such compilation.

4th.
Presence of special preprocessor word to make user defined expression operators

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 17 Dec 2024, 18:19
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.