flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [fasmg] Lucas Prime Test

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



Joined: 16 Jun 2003
Posts: 7887
Location: Kraków, Poland
Tomasz Grysztar
bitRAKE wrote:
Maybe a useful perspective?
Code:
previous value:

        N/A             discarded       preserved       brought back    /w transfer

        :=              =               =:              restore
                        reequ           equ             restore
                        redefine        define          restore
        macro:                          macro           purge           mvmacro
                                        struc           restruc         mvstruc    

In the last column for expression-class symbols you could perhaps put "[CALM] take".
Post 14 Sep 2020, 19:49
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3194
Location: vpcmipstrm
bitRAKE
The term "symbol" has always tripped me up. "=-+!%" are symbols, but named variables are "identifiers". This is a personal problem of navigating the abstractions as all identifiers are symbols.

Thanks for the addition - CALM hasn't been integrated into my thinking about fasmg. I've converted a couple macro/struc, but not enough.
Post 14 Sep 2020, 20:37
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3194
Location: vpcmipstrm
bitRAKE
Code:
; Create static bit vector:
; + ignore value set duplicates
; + invert value set when bit length is negative
struc(name) BITVECTOR bits,values&
        local result,offset,char,inverted,_bits
        virtual
                offset = $
                db values ; string or byte array
                result = 0
                while offset < $
                        load char:1 from offset
                        offset = offset + 1
                        result = result or (1 shl char)
                end while
        end virtual
        if bits < 0
                _bits = -bits
                inverted = (1 shl _bits) - 1
        else
                _bits = bits
                inverted = 0
        end if
        if result shr _bits
                err 'value exceeds bit vector size'
        end if
        name: emit (_bits + 7) shr 3 : (result xor inverted)
end struc

align 32
InvalidFileNameChars BITVECTOR -256,"!#$%&'()-@^_`{}~+,.;=[]0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"


FileNameValid__RSI:
        xor eax,eax
.more:
        lodsb
        test eax,eax ; CF=0
        jz .done
        bt [InvalidFileNameChars],eax
        jnc .more
.done:
        retn
; CF: file name has invalid characters


FileNameValid__RSI__ECX: ; ECX > 0
.more:
        dec ecx ; requres previous CF result on exit
        js .done
        movzx eax,byte[rsi+rcx]
        bt [InvalidFileNameChars],eax
        jnc .more
.done:
        retn
; CF: file name has invalid characters


macro ValidateFileName reg0,reg1
        local more,done
more:   dec reg32.#reg1 ; requres previous CF result on exit
        js done
        movzx eax,byte[reg0+reg1]
        bt [InvalidFileNameChars],eax
        jnc more
done:
end macro    

_________________
¯\(°_o)/¯ unlicense.org
Post 29 May 2021, 03:11
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3

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

Website powered by rwasa.